Sha256: ab335c80e37e6107c7300c874cbff384430b359ea023e4ef6c5cca9f848c2f46
Contents?: true
Size: 691 Bytes
Versions: 4
Compression:
Stored size: 691 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. # When multiple branches match, switch to the first one. def other_branch @other_branch ||= `git branch | grep #{pattern}`.split.first 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
git-utils-0.6.2 | lib/git-utils/switch.rb |
git-utils-0.6.1 | lib/git-utils/switch.rb |
git-utils-0.6.0 | lib/git-utils/switch.rb |
git-utils-0.5.10 | lib/git-utils/switch.rb |