Class: StoryPullRequest
- Inherits:
-
FinishedCommand
- Object
- Command
- FinishedCommand
- StoryPullRequest
- Includes:
- Story
- Defined in:
- lib/pivotal-github/story_pull_request.rb
Instance Attribute Summary
Attributes inherited from Command
#args, #known_options, #options, #unknown_options
Instance Method Summary collapse
- #base_branch ⇒ Object
-
#cmd ⇒ Object
Returns a command appropriate for executing at the command line.
-
#delivers_url(id) ⇒ Object
Returns the (Markdown) link for a delivered story id.
-
#long_message ⇒ Object
Returns a commit message with links to all the delivered stories.
- #parser ⇒ Object
-
#short_message ⇒ Object
Returns a commit message with the branch being used for the pull request.
Methods included from Story
Methods inherited from FinishedCommand
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
#base_branch ⇒ Object
29 30 31 |
# File 'lib/pivotal-github/story_pull_request.rb', line 29 def base_branch .base_branch || 'master' end |
#cmd ⇒ Object
Returns a command appropriate for executing at the command line
45 46 47 48 49 50 51 52 |
# File 'lib/pivotal-github/story_pull_request.rb', line 45 def cmd Dir.mkdir '.pull_requests' unless File.directory?('.pull_requests') c = ["touch .pull_requests/`date '+%s'`"] c << "git add ." c << %(git commit -m "#{}" -m "#{}") c << "git pull-request" c.join("\n") end |
#delivers_url(id) ⇒ Object
Returns the (Markdown) link for a delivered story id.
25 26 27 |
# File 'lib/pivotal-github/story_pull_request.rb', line 25 def delivers_url(id) "[Delivers ##{id}](#{story_url(id)})" end |
#long_message ⇒ Object
Returns a commit message with links to all the delivered stories.
39 40 41 42 |
# File 'lib/pivotal-github/story_pull_request.rb', line 39 def ids = delivered_ids(`git log #{base_branch}..HEAD`) ids.map { |id| delivers_url(id) }.join("\n") end |
#parser ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pivotal-github/story_pull_request.rb', line 8 def parser OptionParser.new do |opts| opts. = "Usage: git story-pull-request [options]" opts.on("-b", "--base-branch BRANCH", "base branch for delivered ids") do |opt| self..base_branch = opt end opts.on("-o", "--override", "override unfinished story warning") do |opt| self..override = opt end opts.on_tail("-h", "--help", "this usage guide") do puts opts.to_s; exit 0 end end end |
#short_message ⇒ Object
Returns a commit message with the branch being used for the pull request.
34 35 36 |
# File 'lib/pivotal-github/story_pull_request.rb', line 34 def "Issue pull request for branch #{story_branch}" end |