Sha256: d5d5d5c9331b62b665d45e38e3421e8d1a748eae53dd6cbdb7dcf4ed50dcfaba

Contents?: true

Size: 626 Bytes

Versions: 5

Compression:

Stored size: 626 Bytes

Contents

require 'git-utils/command'

class Switch < Command

  def parser
    OptionParser.new do |opts|
      opts.banner = "Usage: git switch <pattern>"
      opts.on_tail("-h", "--help", "this usage guide") do
        puts opts.to_s; exit 0
      end
    end
  end

  # Returns the branch to switch to.
  def other_branch
    @other_branch ||= `git branch | grep #{pattern}`.strip
  end

  # Returns a command appropriate for executing at the command line
  def cmd
    "git checkout #{other_branch}"
  end

  private

    # Returns the pattern of the branch to switch to.
    def pattern
      self.known_options.first
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-utils-0.5.9 lib/git-utils/switch.rb
git-utils-0.5.8 lib/git-utils/switch.rb
git-utils-0.5.7 lib/git-utils/switch.rb
git-utils-0.5.6 lib/git-utils/switch.rb
git-utils-0.5.5 lib/git-utils/switch.rb