Class: StoryCommit
- Defined in:
- lib/pivotal-github/story_commit.rb
Instance Attribute Summary
Attributes inherited from Command
#args, #known_options, #options, #unknown_options
Instance Method Summary collapse
-
#cmd ⇒ Object
Returns a command appropriate for executing at the command line.
-
#message ⇒ Object
Returns the message for the story id(s) and action (if any).
-
#message_ids ⇒ Object
Returns the story ids formatted for story commits.
- #parser ⇒ Object
- #run! ⇒ Object
Methods inherited from Command
#initialize, #parse, run!, #story_branch, #story_id, #story_ids
Constructor Details
This class inherits a constructor from Command
Instance Method Details
#cmd ⇒ Object
Returns a command appropriate for executing at the command line. We take care to insert the story number and, if necessary, an indication that the commit finishes the story.
50 51 52 53 54 55 56 57 |
# File 'lib/pivotal-github/story_commit.rb', line 50 def cmd c = ['git commit'] c << '-a' if all? c << %(-m "#{options.message}") if c << %(-m "#{message}") unless story_ids.empty? c << argument_string() unless .empty? c.join(' ') end |
#message ⇒ Object
Returns the message for the story id(s) and action (if any).
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pivotal-github/story_commit.rb', line 28 def if finish? label = "Finishes #{message_ids}" elsif deliver? label = "Delivers #{message_ids}" else label = end "[#{label}]" end |
#message_ids ⇒ Object
Returns the story ids formatted for story commits. For single-id stories, this is just the number preceded by ‘#’, as in ‘#6283185’. For multiple-id stories, each story id is precede by ‘#’, as in ‘#6283185 #3141592’
43 44 45 |
# File 'lib/pivotal-github/story_commit.rb', line 43 def story_ids.map { |id| "##{id}" }.join(' ') end |
#parser ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pivotal-github/story_commit.rb', line 5 def parser OptionParser.new do |opts| opts. = "Usage: git story-commit [options]" opts.on("-m", "--message MESSAGE", "add a commit message (including story #)") do |opt| self.. = opt end opts.on("-f", "--finish", "mark story as finished") do |opt| self..finish = opt end opts.on("-d", "--deliver", "mark story as delivered") do |opt| self..deliver = opt end opts.on("-a", "--all", "commit all changed files") do |opt| self..all = opt end opts.on_tail("-h", "--help", "this usage guide") do puts opts.to_s; exit 0 end end end |
#run! ⇒ Object
59 60 61 |
# File 'lib/pivotal-github/story_commit.rb', line 59 def run! system cmd end |