Class: Command::Merge

Inherits:
Base
  • Object
show all
Includes:
WriteCommit
Defined in:
lib/command/merge.rb

Constant Summary collapse

COMMIT_NOTES =
<<~MSG
  Please enter a commit message to explain why this merge is necessary,
  especially if it merges an updated upstream into a topic branch.

  Lines starting with '#' will be ignored, and an empty message aborts
  the commit.
MSG

Constants included from WriteCommit

WriteCommit::CHERRY_PICK_NOTES, WriteCommit::CONFLICT_MESSAGE, WriteCommit::MERGE_NOTES

Instance Attribute Summary

Attributes inherited from Base

#status

Instance Method Summary collapse

Methods included from WriteCommit

#commit_message_path, #compose_merge_message, #current_author, #define_write_commit_options, #handle_conflicted_index, #pending_commit, #print_commit, #read_message, #resume_merge, #write_cherry_pick_commit, #write_commit, #write_merge_commit, #write_revert_commit, #write_tree

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from Command::Base

Instance Method Details

#define_optionsObject



20
21
22
23
24
25
26
27
# File 'lib/command/merge.rb', line 20

def define_options
  define_write_commit_options

  @options[:mode] = :run

  @parser.on("--abort")    { @options[:mode] = :abort    }
  @parser.on("--continue") { @options[:mode] = :continue }
end

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/command/merge.rb', line 29

def run
  handle_abort if @options[:mode] == :abort
  handle_continue if @options[:mode] == :continue
  handle_in_progress_merge if pending_commit.in_progress?

  @inputs = ::Merge::Inputs.new(repo, Revision::HEAD, @args[0])
  repo.refs.update_ref(Refs::ORIG_HEAD, @inputs.left_oid)

  handle_merged_ancestor if @inputs.already_merged?
  handle_fast_forward if @inputs.fast_forward?

  pending_commit.start(@inputs.right_oid)
  resolve_merge
  commit_merge

  exit 0
end