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
-
#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.
54 55 56 57 58 59 60 |
# File 'lib/pivotal-github/story_commit.rb', line 54 def cmd c = ['git commit'] c << '-a' if all? c << %(-m "#{}") if c << argument_string() unless .empty? c.join(' ') end |
#message ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pivotal-github/story_commit.rb', line 27 def if story_ids.empty? # Arranges to fall through to regular 'git commit' . else if finish? label = "Finishes #{}" elsif deliver? label = "Delivers #{}" else label = end "[#{label}] #{.}" end 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’
47 48 49 |
# File 'lib/pivotal-github/story_commit.rb', line 47 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
62 63 64 |
# File 'lib/pivotal-github/story_commit.rb', line 62 def run! system cmd end |