Sha256: d354a695fc0be06119f79ccbbc43c3ca633dc40d1a0b1883c3571afcb4cb5d7d

Contents?: true

Size: 963 Bytes

Versions: 4

Compression:

Stored size: 963 Bytes

Contents

require 'git-utils/command'

class MergeBranch < Command

  def parser
    OptionParser.new do |opts|
      opts.banner = "Usage: git merge-into-branch [branch] [options]"
      opts.on_tail("-h", "--help", "this usage guide") do
        puts opts.to_s; exit 0
      end
    end
  end

  # Returns a command appropriate for executing at the command line.
  # For example:
  #   git checkout master
  #   git merge --no-ff --log <branch>
  def cmd
    lines = ["git checkout #{target_branch}"]
    c = ["git merge --no-ff --log"]
    c << argument_string(unknown_options) unless unknown_options.empty?
    c << current_branch
    lines << c.join(' ')
    lines.join("\n")
  end

  private

    # Returns the name of the branch to be merged into.
    # If there is anything left in the known options after parsing,
    # that's the merge branch. Otherwise, it's the default branch.
    def target_branch
      self.known_options.first || default_branch
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-utils-2.4.0 lib/git-utils/merge_branch.rb
git-utils-2.3.0 lib/git-utils/merge_branch.rb
git-utils-2.2.1 lib/git-utils/merge_branch.rb
git-utils-2.2.0 lib/git-utils/merge_branch.rb