pivotal-github 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pivotal-github/story_accept.rb +23 -18
- data/lib/pivotal-github/version.rb +1 -1
- data/pivotal-github.gemspec +0 -1
- data/spec/commands/story_accept_spec.rb +35 -29
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb23c95f5fd7c9ccb44d99c7769d4d5eb8193edc
|
4
|
+
data.tar.gz: af5aefc3a45d42d5711bc818084f17f71c9aab35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 171552555c6e801c0ce9e614361ea0e5d47cee06714583998321f26f5a74e2e87e4656e26b50dcce3f8ce426a40c12f804d7cbe597c106cd09eb2f581ce6c41b
|
7
|
+
data.tar.gz: 1e6e7f994761a6b2b01a55dc537a504053be60b2f9c338ce5f7ef4fd9d67e21c73b25295e35cab39e23d89382cfd433a9356561949177fde214a6c82a1c4dc6d
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'pivotal-github/command'
|
2
|
-
require 'net/http'
|
3
|
-
require 'uri'
|
4
|
-
require 'nokogiri'
|
5
2
|
require 'pivotal-github/story'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'net/http'
|
5
|
+
require 'cgi'
|
6
6
|
|
7
7
|
class StoryAccept < Command
|
8
8
|
include Story
|
@@ -40,29 +40,28 @@ class StoryAccept < Command
|
|
40
40
|
# [Delivers #<story id> #<another story id>]. The difference is handled
|
41
41
|
# by the delivered_ids method.
|
42
42
|
def git_log_delivered_story_ids
|
43
|
-
|
44
|
-
|
45
|
-
delivered_lines.inject([]) do |accept, line|
|
46
|
-
accept << delivered_ids(line)
|
47
|
-
end.uniq
|
43
|
+
delivered_text = `git log -E --grep '\\[Deliver(s|ed) #'`
|
44
|
+
delivered_ids(delivered_text).uniq
|
48
45
|
end
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
data = { 'X-TrackerToken' => api_token,
|
53
|
-
'Content-type' => "application/xml" }
|
54
|
-
uri = URI.parse("#{project_uri}/stories?filter=state%3Adelivered")
|
47
|
+
def pivotal_tracker_ids(filter)
|
48
|
+
uri = URI.parse("#{project_uri}/stories?filter=#{CGI::escape(filter)}")
|
55
49
|
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
56
|
-
http.get(uri
|
50
|
+
http.get(uri, data)
|
57
51
|
end
|
58
|
-
Nokogiri::XML(response.body).css('id').map(&:content)
|
52
|
+
Nokogiri::XML(response.body).css('story > id').map(&:content)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns the ids of delivered stories according to Pivotal Tracker.
|
56
|
+
def pivotal_tracker_delivered_story_ids
|
57
|
+
# The Pivotal Tracker API doesn't seem to want to return stories
|
58
|
+
# with a particular state unless the type is also specified.
|
59
|
+
pivotal_tracker_ids('state:delivered type:feature') +
|
60
|
+
pivotal_tracker_ids('state:delivered type:bug')
|
59
61
|
end
|
60
62
|
|
61
63
|
# Returns true if a story has already been accepted.
|
62
64
|
def already_accepted?(story_id)
|
63
|
-
data = { 'X-TrackerToken' => api_token,
|
64
|
-
'Content-type' => "application/xml" }
|
65
|
-
uri = story_uri(story_id)
|
66
65
|
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
67
66
|
http.get(uri.path, data)
|
68
67
|
end
|
@@ -141,4 +140,10 @@ class StoryAccept < Command
|
|
141
140
|
def story_uri(story_id)
|
142
141
|
URI.parse("#{project_uri}/stories/#{story_id}")
|
143
142
|
end
|
143
|
+
|
144
|
+
# Returns data for Pivotal Tracker API calls
|
145
|
+
def data
|
146
|
+
{ 'X-TrackerToken' => api_token,
|
147
|
+
'Content-type' => "application/xml" }
|
148
|
+
end
|
144
149
|
end
|
data/pivotal-github.gemspec
CHANGED
@@ -2,47 +2,53 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe StoryAccept do
|
4
4
|
|
5
|
-
|
5
|
+
subject(:command) { StoryAccept.new(['-o']) }
|
6
6
|
before do
|
7
7
|
command.stub(:story_branch).and_return('62831853-tau-manifesto')
|
8
|
-
command.stub(:git_log_delivered_story_ids).
|
9
|
-
and_return(%w[51204529 51106181 50566167 50566179 60566178])
|
10
|
-
command.stub(:pivotal_tracker_delivered_story_ids).
|
11
|
-
and_return(%w[51204529 51106181 50566167 50566178])
|
12
8
|
end
|
13
|
-
subject { command }
|
14
9
|
|
15
10
|
it { should respond_to(:ids_to_accept) }
|
11
|
+
its(:git_log_delivered_story_ids) { should include "51204529" }
|
12
|
+
its(:pivotal_tracker_delivered_story_ids) { should_not include "51204529" }
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
it { should include("50566167") }
|
25
|
-
it { should_not include("50566178") }
|
26
|
-
it { should_not include("50566178") }
|
27
|
-
it { should_not include("60566178") }
|
14
|
+
context "with stubbed out story ids" do
|
15
|
+
before do
|
16
|
+
command.stub(:git_log_delivered_story_ids).
|
17
|
+
and_return(%w[51204529 51106181 50566167 50566179 60566178])
|
18
|
+
command.stub(:pivotal_tracker_delivered_story_ids).
|
19
|
+
and_return(%w[51204529 51106181 50566167 50566178])
|
20
|
+
end
|
28
21
|
|
29
|
-
|
30
|
-
|
22
|
+
describe "ids_to_accept" do
|
23
|
+
let(:ids) { command.ids_to_accept }
|
24
|
+
subject { ids }
|
25
|
+
|
26
|
+
it { should_not be_empty }
|
27
|
+
it { should include "51204529" }
|
28
|
+
it { should include "51106181" }
|
29
|
+
it { should include "50566167" }
|
30
|
+
it { should_not include "50566178" }
|
31
|
+
it { should_not include "50566178" }
|
32
|
+
it { should_not include "60566178" }
|
33
|
+
|
34
|
+
it "should not have duplicate ids" do
|
35
|
+
expect(ids).to eq ids.uniq
|
36
|
+
end
|
31
37
|
end
|
32
|
-
end
|
33
38
|
|
34
39
|
|
35
|
-
|
40
|
+
its(:api_token) { should_not be_empty }
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
42
|
+
describe "accept!" do
|
43
|
+
before do
|
44
|
+
command.stub(:accept!)
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
it "should accept each id" do
|
48
|
+
number_accepted = command.ids_to_accept.length
|
49
|
+
command.should_receive(:accept!).exactly(number_accepted).times
|
50
|
+
command.run!
|
51
|
+
end
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pivotal-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: httparty
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.10.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.10.0
|
55
41
|
description: Add commands for Pivotal Tracker-GitHub integration
|
56
42
|
email:
|
57
43
|
- michael@michaelhartl.com
|