Sha256: 638a945389a5c592ead52363b7a9ea5de2848110758bda4493b96a9f97a71d61

Contents?: true

Size: 939 Bytes

Versions: 6

Compression:

Stored size: 939 Bytes

Contents

require 'git-utils/command'

class MergeBranch < Command

  def parser
    OptionParser.new do |opts|
      opts.banner = "Usage: git merge-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 master.
    def target_branch
      self.known_options.first || 'master'
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git-utils-1.0.0 lib/git-utils/merge_branch.rb
git-utils-0.7.1 lib/git-utils/merge_branch.rb
git-utils-0.7.0 lib/git-utils/merge_branch.rb
git-utils-0.6.5 lib/git-utils/merge_branch.rb
git-utils-0.6.4 lib/git-utils/merge_branch.rb
git-utils-0.6.3 lib/git-utils/merge_branch.rb