pivotal-github 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/pivotal-github/command.rb +1 -1
- data/lib/pivotal-github/story_accept.rb +23 -10
- data/lib/pivotal-github/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c6eb2dc161943529e3884e271773d40e013c30
|
4
|
+
data.tar.gz: 97250a952a1db4399123fc95d30944ffeeafd661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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):
|
@@ -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
|
-
|
51
|
-
|
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
|
-
@
|
80
|
+
@project_id ||= File.read(project_id_filename).strip
|
71
81
|
else
|
72
|
-
puts "Please create a file called '
|
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'
|
83
|
-
|
84
|
-
|
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
|
-
|
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
|