pivotal-github 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aa1293580e2c9efd94ee5cc32fc7dc1a29eee87
4
- data.tar.gz: 909ff85f5d206d692cd73fbcccc4b5cf03b50fa3
3
+ metadata.gz: eb23c95f5fd7c9ccb44d99c7769d4d5eb8193edc
4
+ data.tar.gz: af5aefc3a45d42d5711bc818084f17f71c9aab35
5
5
  SHA512:
6
- metadata.gz: 609a6d4ca5393d0c492b7452129c8a8118e32aa421db5290ae50d9fdb159594a879a8148602e72875f206cca6e8c51f87efbc22d257d4c229e3fadfce8741688
7
- data.tar.gz: 5867e839faacb0c1f17e9444b51dda487fec444f4b74f77fed85d58455af4f6b3c14356b1316748899dac3b0c276e1263b3f98e826cae9e3189c383ed321984c
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
- pat = '\\[Deliver(s|ed) #'
44
- delivered_lines = `git log --grep='#{pat}' | egrep '#{pat}'`.split("\n")
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
- # Returns the ids of delivered stories according to Pivotal Tracker.
51
- def pivotal_tracker_delivered_story_ids
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.path, data)
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
@@ -1,5 +1,5 @@
1
1
  module Pivotal
2
2
  module Github
3
- VERSION = "1.1.5"
3
+ VERSION = "1.1.6"
4
4
  end
5
5
  end
@@ -19,5 +19,4 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
  gem.add_dependency('git-utils')
21
21
  gem.add_dependency('nokogiri')
22
- gem.add_dependency('httparty', '~> 0.10.0')
23
22
  end
@@ -2,47 +2,53 @@ require 'spec_helper'
2
2
 
3
3
  describe StoryAccept do
4
4
 
5
- let(:command) { StoryAccept.new(['-o']) }
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
- describe "ids_to_accept" do
18
- let(:ids) { command.ids_to_accept }
19
- subject { ids }
20
-
21
- it { should_not be_empty }
22
- it { should include("51204529") }
23
- it { should include("51106181") }
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
- it "should not have duplicate ids" do
30
- expect(ids).to eq ids.uniq
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
- its(:api_token) { should_not be_empty }
40
+ its(:api_token) { should_not be_empty }
36
41
 
37
- describe "accept!" do
38
- before do
39
- command.stub(:accept!)
40
- end
42
+ describe "accept!" do
43
+ before do
44
+ command.stub(:accept!)
45
+ end
41
46
 
42
- it "should accept each id" do
43
- number_accepted = command.ids_to_accept.length
44
- command.should_receive(:accept!).exactly(number_accepted).times
45
- command.run!
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.5
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