Class: StoryCommit

Inherits:
Command show all
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

Methods inherited from Command

#initialize, #message, #message_ids, #parse, run!, #story_branch, #story_id, #story_ids

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#cmdObject

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.



30
31
32
33
34
35
36
37
# File 'lib/pivotal-github/story_commit.rb', line 30

def cmd
  c = ['git commit']
  c << '-a' if all?
  c << %(-m "#{options.message}") if message?
  c << %(-m "#{message}") unless story_ids.empty?
  c << argument_string(unknown_options) unless unknown_options.empty?
  c.join(' ')
end

#parserObject



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.banner = "Usage: git story-commit [options]"
    opts.on("-m", "--message MESSAGE",
            "add a commit message (including story #)") do |opt|
      self.options.message = opt
    end
    opts.on("-f", "--finish", "mark story as finished") do |opt|
      self.options.finish = opt
    end
    opts.on("-d", "--deliver", "mark story as delivered") do |opt|
      self.options.deliver = opt
    end
    opts.on("-a", "--all", "commit all changed files") do |opt|
      self.options.all = opt
    end
    opts.on_tail("-h", "--help", "this usage guide") do
      puts opts.to_s; exit 0
    end
  end
end

#run!Object



39
40
41
# File 'lib/pivotal-github/story_commit.rb', line 39

def run!
  system cmd
end