fix shelve-and-goto
[git-knacks.git] / git-can-i-unshelve
blob4fd2a3ee365c74dd8d116d864fbc69570287fc78
1 #!/usr/bin/env ruby
3 #this will shelve your current changes to a new branch
4 require 'optparse'
6 class CanIUnshelve
7 attr_accessor :options
9 def initialize
10 options = {}
11 branch = OptionParser.new do |opts|
12 opts.on("-v", "--[no-]verbose", "Verbose output (echo individual git commands)") do |v|
13 options[:verbose] = v
14 end
15 end.parse!
16 self.options = {:verbose => false}.merge options
17 end
19 def run
20 if get('git-log --pretty=\'format:%s\' -n1').strip == 'SHELVE SHELVE SHELVE'
21 puts "You have commits shelved on this branch"
22 exit 0
23 else
24 puts "No commits nee to be unshelved"
25 exit 1
26 end
27 end
30 private
32 def git(cmd)
33 puts cmd if options[:verbose]
34 system cmd
35 end
37 def get(cmd)
38 puts cmd if options[:verbose]
39 `#{cmd}`
40 end
41 end
43 CanIUnshelve.new.run