pivotal-github 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 727659cf612b3572160046ca9f12608acf16698a
4
- data.tar.gz: cc892a9b14ca4d3538d64b345d69c65825945fe8
3
+ metadata.gz: 14cc1b18c4f212885bef01e59a3ec1afb2dee62b
4
+ data.tar.gz: 9db260b070a5e61863d5f1c6bf497291775ad79f
5
5
  SHA512:
6
- metadata.gz: 0af10b8c3ef1fa9348d4aa4b06aee3bb552100258859a49af400ba809f79d286edf8b18f1a4066bc1322ece1a8ff686f0987d8724354ae5b5c07186a338306f2
7
- data.tar.gz: 107f5d9c12867a47b3e548770cfe96fe1fc5ff5126859b70463101efc7599690a0d4ad46060491291b410fc0d2020895449acf0fdaa3c3069b462e0f7da4e3aa
6
+ metadata.gz: 121e1d1a29a105bf95adba4343c3c6456359549363f32e666f8d0e402e8d787d3d9d10b8313428c34a3e4fb01c04170d110a4188f667ad8fc337bde84548e0f8
7
+ data.tar.gz: da5c6538f8b44413c460de83da555c916a65301f1b5ad07c9ac865de5e4278c1182eb9fa1dbdfae2d14170d8313fc0e54c021bc0c5196b0d5deda44a93fb9434
data/README.md CHANGED
@@ -115,7 +115,7 @@ Additionally, `git story-merge` accepts any options valid for `git merge`.
115
115
 
116
116
  $ git story-pull-request
117
117
 
118
- `git story-pull-request` issues a `git push-branch` as well (from [git-utils](https://github.com/mhartl/git-utils)), just in case the local branch hasn't yet been pushed up to the remote repository. For reference, it then makes a commit containing a message with links to all the delivered story ids. These ids are determined relative to a base branch; this is `master` by default, but if there have been a series of topic branches then the base branch should be set (using the `-b` option) to the branch of the previous pull request. The pull request message includes the branch used for the request, so this previous branch can be determined using `git log`.
118
+ `git story-pull-request` issues a `git push-branch` as well (from [git-utils](https://github.com/mhartl/git-utils)), just in case the local branch hasn't yet been pushed up to the remote repository. For reference, it then makes a commit containing a message with links to all the delivered story ids. These ids consist of all the delivered stories that haven't already been delivered by a pull request.
119
119
 
120
120
  As with `git story-merge`, by default `git story-pull-request` exits with a warning if the most recent commit doesn't finish the story.
121
121
 
@@ -7,11 +7,36 @@ module Story
7
7
 
8
8
  # Returns the ids of delivered stories found in the given text.
9
9
  def delivered_ids(text)
10
- delivered = text.scan(/\[Deliver(?:s|ed) (.*?)\]/).flatten
10
+ delivered = text.scan(/\[Deliver(?:s|ed) (.*?)\]/).flatten
11
11
  # Handle multiple ids, i.e., '[Delivers #<id 1> #<id 2>]'
12
12
  delivered.inject([]) do |ids, element|
13
13
  ids.concat(element.scan(/[0-9]{8,}/).flatten)
14
14
  ids
15
15
  end.uniq
16
16
  end
17
+
18
+ # Returns the ids of delivered stories according to the Git log.
19
+ # These ids are of the form [Delivers #<story id>] or
20
+ # [Delivers #<story id> #<another story id>]. The difference is handled
21
+ # by the delivered_ids method.
22
+ def git_log_delivered_story_ids
23
+ delivered_ids(fast_log_delivered_text).uniq
24
+ end
25
+
26
+ def fast_log_delivered_text
27
+ @delivered_text ||= `git log -E --grep '\\[Deliver(s|ed) #'`
28
+ end
29
+
30
+ # Returns the ids delivered since the last pull request.
31
+ # We omit the ids of stories that have already been delivered by a
32
+ # particular pull request, so that each new PR is only tagged with stories
33
+ # delivered since the *last* PR.
34
+ def delivered_ids_since_last_pr(text)
35
+ delivered_ids(text) - pr_ids(text)
36
+ end
37
+
38
+ # Returns the ids included in previous pull requests.
39
+ def pr_ids(text)
40
+ text.scan(/\[Deliver(?:s|ed) #(.*?)\]\(https:\/\//).flatten.uniq
41
+ end
17
42
  end
@@ -37,15 +37,6 @@ class StoryAccept < Command
37
37
  git_log_delivered_story_ids & pivotal_tracker_delivered_story_ids
38
38
  end
39
39
 
40
- # Returns the ids of delivered stories according to the Git log.
41
- # These ids are of the form [Delivers #<story id>] or
42
- # [Delivers #<story id> #<another story id>]. The difference is handled
43
- # by the delivered_ids method.
44
- def git_log_delivered_story_ids
45
- delivered_text = `git log -E --grep '\\[Deliver(s|ed) #'`
46
- delivered_ids(delivered_text).uniq
47
- end
48
-
49
40
  def pivotal_tracker_ids(filter)
50
41
  uri = URI.parse("#{project_uri}/stories?filter=#{CGI::escape(filter)}")
51
42
  response = Net::HTTP.start(uri.host, uri.port) do |http|
@@ -8,10 +8,6 @@ class StoryPullRequest < FinishedCommand
8
8
  def parser
9
9
  OptionParser.new do |opts|
10
10
  opts.banner = "Usage: git story-pull-request [options]"
11
- opts.on("-b", "--base-branch BRANCH",
12
- "base branch for delivered ids") do |opt|
13
- self.options.base_branch = opt
14
- end
15
11
  opts.on("-o", "--override", "override unfinished story warning") do |opt|
16
12
  self.options.override = opt
17
13
  end
@@ -26,10 +22,6 @@ class StoryPullRequest < FinishedCommand
26
22
  "[Delivers ##{id}](#{story_url(id)})"
27
23
  end
28
24
 
29
- def base_branch
30
- options.base_branch || 'master'
31
- end
32
-
33
25
  # Returns a commit message with the branch being used for the pull request.
34
26
  def short_message
35
27
  "Issue pull request for branch #{story_branch}"
@@ -37,7 +29,7 @@ class StoryPullRequest < FinishedCommand
37
29
 
38
30
  # Returns a commit message with links to all the delivered stories.
39
31
  def long_message
40
- ids = delivered_ids(`git log #{base_branch}..HEAD`)
32
+ ids = delivered_ids_since_last_pr(fast_log_delivered_text)
41
33
  ids.map { |id| delivers_url(id) }.join("\n")
42
34
  end
43
35
 
@@ -1,5 +1,5 @@
1
1
  module Pivotal
2
2
  module Github
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
@@ -80,7 +80,8 @@ describe StoryCommit do
80
80
 
81
81
  describe "when used with branches containing multiple stories" do
82
82
  before do
83
- command.stub(:story_branch).and_return('62831853-tau-manifesto-31415926')
83
+ command.stub(:story_branch).
84
+ and_return('62831853-tau-manifesto-31415926')
84
85
  end
85
86
  its(:cmd) do
86
87
  delivered_ids = '#62831853 #31415926'
@@ -97,7 +98,8 @@ describe StoryCommit do
97
98
 
98
99
  describe "when used with branches containing multiple stories" do
99
100
  before do
100
- command.stub(:story_branch).and_return('62831853-tau-manifesto-31415926')
101
+ command.stub(:story_branch).
102
+ and_return('62831853-tau-manifesto-31415926')
101
103
  end
102
104
  its(:cmd) do
103
105
  delivered_ids = '#62831853 #31415926'
@@ -7,7 +7,8 @@ describe StoryPullRequest do
7
7
  before do
8
8
  command.stub(:remote_location).
9
9
  and_return('https://github.com/mhartl/foo')
10
- command.stub(:delivered_ids).and_return(['62831853', '31415926'])
10
+ command.stub(:delivered_ids_since_last_pr).
11
+ and_return(['62831853', '31415926'])
11
12
  command.stub(:write_pr_file).and_return('')
12
13
  end
13
14
  subject { command }
@@ -19,11 +20,6 @@ describe StoryPullRequest do
19
20
  should include '[Delivers #31415926]'
20
21
  end
21
22
 
22
- describe "base branch override" do
23
- let(:command) { StoryPullRequest.new(['-b', 'development']) }
24
- its(:base_branch) { should eq 'development' }
25
- end
26
-
27
23
  describe "command-line command" do
28
24
  subject { `bin/git-story-pull-request --debug` }
29
25
  it { should_not match /\.git/ }
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Story do
4
+ include Story
5
+
6
+ describe '#story_url' do
7
+ let(:id) { '62831853' }
8
+ subject { story_url(id) }
9
+ it { should include id }
10
+ end
11
+
12
+ describe '#delivered_ids_since_last_pr' do
13
+ let(:text) do <<-EOS
14
+ [Delivers #62831853 #31415926]
15
+ [Delivered #27182818]
16
+
17
+ [Delivers #55203510](https://www.pivotaltracker.com/story/show/55203510)
18
+ [Delivers #55202656](https://www.pivotaltracker.com/story/show/55202656)
19
+
20
+ [Delivers #55202656]
21
+ EOS
22
+ end
23
+ subject { delivered_ids_since_last_pr(text) }
24
+
25
+ it { should include '62831853' }
26
+ it { should include '31415926' }
27
+ it { should include '27182818' }
28
+ it { should_not include '55203510' }
29
+ it { should_not include '55202656' }
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-19 00:00:00.000000000 Z
11
+ date: 2013-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git-utils
@@ -89,6 +89,7 @@ files:
89
89
  - spec/commands/story_pull_request_spec.rb
90
90
  - spec/options/options_spec.rb
91
91
  - spec/spec_helper.rb
92
+ - spec/story_spec.rb
92
93
  homepage: https://github.com/mhartl/pivotal-github
93
94
  licenses:
94
95
  - MIT
@@ -123,3 +124,4 @@ test_files:
123
124
  - spec/commands/story_pull_request_spec.rb
124
125
  - spec/options/options_spec.rb
125
126
  - spec/spec_helper.rb
127
+ - spec/story_spec.rb