pivotal-github 1.0.2 → 1.0.3

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: ffb65422d4145e0558694e16e86efeee2ba8e6fe
4
- data.tar.gz: 0e30c9e9dfb790c7d60dbb13b2f27c85b8d9a318
3
+ metadata.gz: 76c6eb2dc161943529e3884e271773d40e013c30
4
+ data.tar.gz: 97250a952a1db4399123fc95d30944ffeeafd661
5
5
  SHA512:
6
- metadata.gz: b96f438c08b356a7732c32171e73e39688e39cdf9f543bab53cadf78873fc60d574f03c2ffc0cf23b334f037b0959c6b6366603bede72b282e55f1a5941a3a68
7
- data.tar.gz: 00340e88ce75f377f22b081f6f02b49af6ee7e284396fa56a89a4df488cf193dfe990dfb2081d29213d13271caee5c2bc6f89f40428836ee94419efc414d82d6
6
+ metadata.gz: 8ac8e989aeab986c04ee7248f5a58d48be96d9903be492d46d05410f9d6d281e20180318fad9b8de4b6c819c23b9503057aad6580e432d61236e3d271e546fea
7
+ data.tar.gz: 53310a883ab3444f317a1d59fd00aa4e389939be844f8a4b8dd451161675e7902ffa808f0ccd4caf081e471b741a4ee19d6e3cd1f1e332da9c5063d8f3416e90
data/README.md CHANGED
@@ -137,11 +137,11 @@ In order to avoid reading the entire Git log every time it's run, by default `gi
137
137
 
138
138
  #### Options
139
139
 
140
- Usage: git story-accept
140
+ Usage: git story-accept [options]
141
141
  -o, --override override master branch requirement
142
+ -q, --quiet suppress display of accepted story ids
142
143
  -a, --all process all stories (entire log)
143
144
  -h, --help this usage guide
144
-
145
145
  ### story-open
146
146
 
147
147
  The `story-open` command (no `git`) opens the current story in the default browser (OS X–only):
@@ -22,7 +22,7 @@ class Command
22
22
  end
23
23
 
24
24
  def story_branch
25
- `git rev-parse --abbrev-ref HEAD`.strip
25
+ @story_branch ||= `git rev-parse --abbrev-ref HEAD`.strip
26
26
  end
27
27
 
28
28
  # Returns the story id (or ids).
@@ -8,10 +8,13 @@ class StoryAccept < Command
8
8
 
9
9
  def parser
10
10
  OptionParser.new do |opts|
11
- opts.banner = "Usage: git story-accept"
11
+ opts.banner = "Usage: git story-accept [options]"
12
12
  opts.on("-o", "--override", "override master branch requirement") do |opt|
13
13
  self.options.override = opt
14
14
  end
15
+ opts.on("-q", "--quiet", "suppress display of accepted story ids") do |opt|
16
+ self.options.quiet = opt
17
+ end
15
18
  opts.on("-a", "--all", "process all stories (entire log)") do |opt|
16
19
  self.options.all = opt
17
20
  end
@@ -21,6 +24,12 @@ class StoryAccept < Command
21
24
  end
22
25
  end
23
26
 
27
+ # The story_id has a different meaning in this context, so raise an
28
+ # error if it's called accidentally.
29
+ def story_id
30
+ raise 'Invalid reference to Command#story_id'
31
+ end
32
+
24
33
  # Returns the ids to accept.
25
34
  # These ids are of the form [Delivers #<story id>] or
26
35
  # [Delivers #<story id> #<another story id>].
@@ -47,8 +56,9 @@ class StoryAccept < Command
47
56
  def already_accepted?(story_id)
48
57
  data = { 'X-TrackerToken' => api_token,
49
58
  'Content-type' => "application/xml" }
50
- response = Net::HTTP.start(story_uri.host, story_uri.port) do |http|
51
- http.get(story_uri.path, data)
59
+ uri = story_uri(story_id)
60
+ response = Net::HTTP.start(uri.host, uri.port) do |http|
61
+ http.get(uri.path, data)
52
62
  end
53
63
  Nokogiri::XML(response.body).at_css('current_state').content == "accepted"
54
64
  end
@@ -67,9 +77,9 @@ class StoryAccept < Command
67
77
  def project_id
68
78
  project_id_filename = '.project_id'
69
79
  if File.exist?(project_id_filename)
70
- @project_id_filename ||= File.read(project_id_filename)
80
+ @project_id ||= File.read(project_id_filename).strip
71
81
  else
72
- puts "Please create a file called '#{project_id}'"
82
+ puts "Please create a file called '.project_id'"
73
83
  puts "containing the Pivotal Tracker project number."
74
84
  exit 1
75
85
  end
@@ -79,10 +89,12 @@ class StoryAccept < Command
79
89
  def accept!(story_id)
80
90
  accepted = "<story><current_state>accepted</current_state></story>"
81
91
  data = { 'X-TrackerToken' => api_token,
82
- 'Content-type' => "application/xml" }
83
- Net::HTTP.start(story_uri.host, story_uri.port) do |http|
84
- http.put(story_uri.path, accepted, data)
92
+ 'Content-type' => "application/xml" }
93
+ uri = story_uri(story_id)
94
+ Net::HTTP.start(uri.host, uri.port) do |http|
95
+ http.put(uri.path, accepted, data)
85
96
  end
97
+ puts "Accepted story ##{story_id}" unless options.quiet
86
98
  end
87
99
 
88
100
  def run!
@@ -100,7 +112,8 @@ class StoryAccept < Command
100
112
  'http://www.pivotaltracker.com/services/v3'
101
113
  end
102
114
 
103
- def story_uri
104
- URI.parse("#{api_base}/projects/#{project_id}/stories/#{story_id}")
115
+ def story_uri(story_id)
116
+ uri = "#{api_base}/projects/#{project_id}/stories/#{story_id}"
117
+ URI.parse(uri)
105
118
  end
106
119
  end
@@ -1,5 +1,5 @@
1
1
  module Pivotal
2
2
  module Github
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  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.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl