3 #this will shelve your current changes to a new branch
8 attr_accessor
:destination_branch
12 branch
= OptionParser
.new
do |opts
|
13 opts
.on("-v", "--[no-]verbose", "Verbose output (echo individual git commands)") do |v
|
17 self.options
= {:verbose => false}.merge options
18 self.destination_branch
= branch
.join('-')
23 git("git ci -a -m 'SHELVE SHELVE SHELVE'") &&
24 if branch_exists
?(destination_branch
)
25 git("git checkout #{destination_branch}")
27 git("git checkout HEAD^")
28 git("git checkout -b #{destination_branch}")
35 output
= get('git branch')
36 output
.match(/^\* (.+)$/)[1]
39 def branch_exists
?(branch
)
40 output
= get('git branch')
41 !output
.match("^(\\*| ) #{branch}$").nil?
45 puts cmd
if options
[:verbose]
50 puts cmd
if options
[:verbose]