3 #this will shelve your current changes to a new branch
10 attr_accessor
:destination_branch
14 branch
= OptionParser
.new
do |opts
|
15 opts
.on("-v", "--[no-]verbose", "Verbose output (echo individual git commands)") do |v
|
19 self.options
= {:verbose => false}.merge options
20 self.destination_branch
= branch
.join('-')
24 previous_branch
= current_branch
25 git("git checkout #{"-b
" unless branch_exists?(destination_branch)} #{destination_branch}") &&
27 git("git ci -a -m 'SHELVE SHELVE SHELVE'") &&
28 git("git checkout #{previous_branch}")
34 output
= get('git branch')
35 output
.match(/^\* (.+)$/)[1]
38 def branch_exists
?(branch
)
39 output
= get('git branch')
40 !output
.match("^(\\*| ) #{branch}$").nil?
44 puts cmd
if options
[:verbose]
49 puts cmd
if options
[:verbose]