Class: ShareReReRe::PushReReRe

Inherits:
Object
  • Object
show all
Includes:
GitHelpersMixin, ShareReReReMixin
Defined in:
lib/git_bpf/commands/share-rerere-cache.rb

Instance Method Summary collapse

Methods included from ShareReReReMixin

#options

Methods included from GitHelpersMixin

#branchExists?, #context, #promptYN, #refExists?, #terminate

Instance Method Details

#execute(opts, argv) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/git_bpf/commands/share-rerere-cache.rb', line 62

def execute(opts, argv)
  rerere = Repository.new opts.work_tree
  lines = rerere.cmd("status", "--porcelain").split("\n").map { |a| a.chomp }
  if lines.empty?
    terminate "No resolutions to share."
  end

  lines.each do |line|
    if line =~ /^\?\?\s(\w+)\//
      folder = line.split("\s").last
      message = "Sharing resolution: #{folder}."
      rerere.cmd("add", folder)
      rerere.cmd("commit", "-m", message)
      rerere.cmd("push", "--quiet", opts.remote, opts.branch)
      puts message
    end
  end
end