toolshed 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -0
- data/Rakefile +11 -0
- data/bin/toolshed.rb +95 -16
- data/lib/toolshed/base.rb +7 -0
- data/lib/toolshed/cli.rb +13 -6
- data/lib/toolshed/client.rb +105 -83
- data/lib/toolshed/commands/checkout_branch.rb +26 -0
- data/lib/toolshed/commands/create_branch.rb +60 -0
- data/lib/toolshed/commands/create_pivotal_tracker_note.rb +9 -4
- data/lib/toolshed/commands/create_pull_request.rb +137 -0
- data/lib/toolshed/commands/delete_branch.rb +27 -0
- data/lib/toolshed/commands/get_daily_time_update.rb +21 -0
- data/lib/toolshed/commands/get_pivotal_tracker_story_information.rb +6 -3
- data/lib/toolshed/commands/list_branches.rb +13 -0
- data/lib/toolshed/commands/push_branch.rb +11 -0
- data/lib/toolshed/commands/update_pivotal_tracker_story_status.rb +8 -5
- data/lib/toolshed/git/git.rb +134 -0
- data/lib/toolshed/git/github.rb +88 -0
- data/lib/toolshed/ticket_tracking/pivotal_tracker.rb +111 -0
- data/lib/toolshed/ticket_tracking/ticket_tracking.rb +6 -0
- data/lib/toolshed/time_tracking/harvest.rb +68 -0
- data/lib/toolshed/time_tracking/time_tracking.rb +6 -0
- data/lib/toolshed/version.rb +1 -1
- data/lib/toolshed.rb +8 -2
- data/test/commands/checkout_branch_test.rb +28 -0
- data/test/commands/commands_helper.rb +2 -0
- data/test/commands/create_branch_test.rb +44 -0
- data/test/commands/create_pull_request_test.rb +125 -0
- data/test/commands/delete_branch_test.rb +75 -0
- data/test/commands/push_branch_test.rb +49 -0
- data/test/config.rb +1 -0
- data/test/git/git_helper.rb +31 -0
- data/test/git/git_test.rb +115 -0
- data/test/git/github_test.rb +91 -0
- data/test/helper.rb +98 -0
- data/toolshed.gemspec +8 -0
- metadata +151 -9
- data/lib/toolshed/commands/checkout_git_branch.rb +0 -23
- data/lib/toolshed/commands/create_git_branch.rb +0 -28
- data/lib/toolshed/commands/create_github_pull_request.rb +0 -77
- data/lib/toolshed/commands/push_git_branch.rb +0 -10
- data/lib/toolshed/github.rb +0 -89
- data/lib/toolshed/pivotal_tracker.rb +0 -87
data/toolshed.gemspec
CHANGED
@@ -22,7 +22,15 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "httparty"
|
23
23
|
spec.add_dependency "json"
|
24
24
|
spec.add_dependency "pivotal-tracker"
|
25
|
+
spec.add_dependency "harvested"
|
26
|
+
spec.add_dependency "veto"
|
25
27
|
|
26
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
29
|
spec.add_development_dependency "rake"
|
30
|
+
spec.add_development_dependency 'mocha'
|
31
|
+
spec.add_development_dependency 'faker'
|
32
|
+
spec.add_development_dependency 'test-unit', '~> 2.5.5'
|
33
|
+
spec.add_development_dependency 'debugger'
|
34
|
+
spec.add_development_dependency 'ci_reporter'
|
35
|
+
spec.add_development_dependency 'simplecov'
|
28
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toolshed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- test
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: harvested
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: veto
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: bundler
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +108,90 @@ dependencies:
|
|
80
108
|
- - '>='
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mocha
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: faker
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: test-unit
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.5.5
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ~>
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.5.5
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: debugger
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: ci_reporter
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: simplecov
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
83
195
|
description: Utility that will automate simple daily tasks developers perform like
|
84
196
|
creating a Github pull request
|
85
197
|
email:
|
@@ -90,6 +202,7 @@ extensions: []
|
|
90
202
|
extra_rdoc_files: []
|
91
203
|
files:
|
92
204
|
- .gitignore
|
205
|
+
- .travis.yml
|
93
206
|
- Gemfile
|
94
207
|
- LICENSE.txt
|
95
208
|
- README.md
|
@@ -100,17 +213,35 @@ files:
|
|
100
213
|
- lib/toolshed/base.rb
|
101
214
|
- lib/toolshed/cli.rb
|
102
215
|
- lib/toolshed/client.rb
|
103
|
-
- lib/toolshed/commands/
|
104
|
-
- lib/toolshed/commands/
|
105
|
-
- lib/toolshed/commands/create_github_pull_request.rb
|
216
|
+
- lib/toolshed/commands/checkout_branch.rb
|
217
|
+
- lib/toolshed/commands/create_branch.rb
|
106
218
|
- lib/toolshed/commands/create_pivotal_tracker_note.rb
|
219
|
+
- lib/toolshed/commands/create_pull_request.rb
|
220
|
+
- lib/toolshed/commands/delete_branch.rb
|
221
|
+
- lib/toolshed/commands/get_daily_time_update.rb
|
107
222
|
- lib/toolshed/commands/get_pivotal_tracker_story_information.rb
|
108
|
-
- lib/toolshed/commands/
|
223
|
+
- lib/toolshed/commands/list_branches.rb
|
224
|
+
- lib/toolshed/commands/push_branch.rb
|
109
225
|
- lib/toolshed/commands/update_pivotal_tracker_story_status.rb
|
110
226
|
- lib/toolshed/error.rb
|
111
|
-
- lib/toolshed/
|
112
|
-
- lib/toolshed/
|
227
|
+
- lib/toolshed/git/git.rb
|
228
|
+
- lib/toolshed/git/github.rb
|
229
|
+
- lib/toolshed/ticket_tracking/pivotal_tracker.rb
|
230
|
+
- lib/toolshed/ticket_tracking/ticket_tracking.rb
|
231
|
+
- lib/toolshed/time_tracking/harvest.rb
|
232
|
+
- lib/toolshed/time_tracking/time_tracking.rb
|
113
233
|
- lib/toolshed/version.rb
|
234
|
+
- test/commands/checkout_branch_test.rb
|
235
|
+
- test/commands/commands_helper.rb
|
236
|
+
- test/commands/create_branch_test.rb
|
237
|
+
- test/commands/create_pull_request_test.rb
|
238
|
+
- test/commands/delete_branch_test.rb
|
239
|
+
- test/commands/push_branch_test.rb
|
240
|
+
- test/config.rb
|
241
|
+
- test/git/git_helper.rb
|
242
|
+
- test/git/git_test.rb
|
243
|
+
- test/git/github_test.rb
|
244
|
+
- test/helper.rb
|
114
245
|
- toolshed.gemspec
|
115
246
|
homepage: ''
|
116
247
|
licenses:
|
@@ -137,4 +268,15 @@ signing_key:
|
|
137
268
|
specification_version: 4
|
138
269
|
summary: Create a Github pull request with minimal work. Will automatically read ticket
|
139
270
|
information from pivotal tracker if you use that.
|
140
|
-
test_files:
|
271
|
+
test_files:
|
272
|
+
- test/commands/checkout_branch_test.rb
|
273
|
+
- test/commands/commands_helper.rb
|
274
|
+
- test/commands/create_branch_test.rb
|
275
|
+
- test/commands/create_pull_request_test.rb
|
276
|
+
- test/commands/delete_branch_test.rb
|
277
|
+
- test/commands/push_branch_test.rb
|
278
|
+
- test/config.rb
|
279
|
+
- test/git/git_helper.rb
|
280
|
+
- test/git/git_test.rb
|
281
|
+
- test/git/github_test.rb
|
282
|
+
- test/helper.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Toolshed
|
2
|
-
module Commands
|
3
|
-
class CheckoutGitBranch
|
4
|
-
def execute(args, options = {})
|
5
|
-
print "Ticket ID or Branch Name? "
|
6
|
-
ticket_id = $stdin.gets.chomp
|
7
|
-
|
8
|
-
branch_name = `git branch | grep \"#{ticket_id}\"`.gsub("*", "").strip
|
9
|
-
|
10
|
-
git_submodule_command = ''
|
11
|
-
if (Toolshed::Client.use_git_submodules)
|
12
|
-
print "Update Submodules (y/n)? "
|
13
|
-
update_submodules = $stdin.gets.chomp
|
14
|
-
if (update_submodules == 'y')
|
15
|
-
git_submodule_command = "git submodule update --init;"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
system("git checkout #{branch_name}; #{git_submodule_command}")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Toolshed
|
2
|
-
module Commands
|
3
|
-
class CreateGitBranch
|
4
|
-
def execute(args, options = {})
|
5
|
-
print "Branch text? "
|
6
|
-
branch_name = $stdin.gets.chomp
|
7
|
-
|
8
|
-
print "Branch from? "
|
9
|
-
branch_from = $stdin.gets.chomp
|
10
|
-
|
11
|
-
git_submodule_command = ''
|
12
|
-
if (Toolshed::Client.use_git_submodules)
|
13
|
-
print "Update Submodules (y/n)? "
|
14
|
-
update_submodules = $stdin.gets.chomp
|
15
|
-
if (update_submodules == 'y')
|
16
|
-
git_submodule_command = "git submodule update --init;"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
branch_name = branch_name.strip.downcase.tr(" ", "_").gsub("-", "").gsub("&", "").gsub("/", "_").gsub(".", "_").gsub("'", "").gsub("__", "_").gsub(":", "")
|
21
|
-
output_text = "git remote update; git checkout -b #{branch_name} #{Toolshed::Client.branched_from_remote_name}/#{branch_from}; #{git_submodule_command} git push #{Toolshed::Client.push_to_myself} #{branch_name}"
|
22
|
-
|
23
|
-
puts "Creating branch.."
|
24
|
-
system(output_text)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module Toolshed
|
2
|
-
module Commands
|
3
|
-
class CreateGithubPullRequest
|
4
|
-
def execute(args, options = {})
|
5
|
-
pivotal_tracker = nil
|
6
|
-
if (Toolshed::Client.use_pivotal_tracker)
|
7
|
-
# load up the project information for pivotal tracker
|
8
|
-
print "Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id})? "
|
9
|
-
project_id = $stdin.gets.chomp.strip
|
10
|
-
if (project_id == '')
|
11
|
-
project_id = Toolshed::Client.default_pivotal_tracker_project_id
|
12
|
-
end
|
13
|
-
pivotal_tracker = Toolshed::PivotalTracker.new({ project_id: project_id, username: Toolshed::PivotalTracker.username, password: Toolshed::PivotalTracker.password })
|
14
|
-
end
|
15
|
-
|
16
|
-
github = Toolshed::Github.new({ username: Toolshed::Github.username, password: Toolshed::Github.password })
|
17
|
-
|
18
|
-
# see what branch is checked out and where we are branched from
|
19
|
-
puts "Current Branch: #{github.branch_name}"
|
20
|
-
puts "Branched From: #{github.branched_from}"
|
21
|
-
|
22
|
-
pt_ticket_title = ''
|
23
|
-
if (Toolshed::Client.use_pivotal_tracker)
|
24
|
-
# load up the story information from PivotalTracker
|
25
|
-
default_story_id = Toolshed::PivotalTracker::story_id_from_branch_name(github.branch_name)
|
26
|
-
print "Story ID (Default: #{default_story_id})? "
|
27
|
-
story_id = $stdin.gets.chomp.strip
|
28
|
-
if (story_id == '')
|
29
|
-
story_id = default_story_id
|
30
|
-
end
|
31
|
-
|
32
|
-
pivotal_tracker_result = pivotal_tracker.story_information(story_id)
|
33
|
-
|
34
|
-
pt_ticket_title = pivotal_tracker_result.name
|
35
|
-
pt_ticket_title = pt_ticket_title.gsub("'", "").gsub("\"", "")
|
36
|
-
end
|
37
|
-
|
38
|
-
# github pull request fields
|
39
|
-
print "Github Pull Request Title (Default: #{pt_ticket_title})? "
|
40
|
-
github_pull_request_title = $stdin.gets.chomp.strip
|
41
|
-
if (github_pull_request_title == '')
|
42
|
-
github_pull_request_title = pt_ticket_title
|
43
|
-
end
|
44
|
-
|
45
|
-
github_pull_request_default_body = ''
|
46
|
-
if (Toolshed::Client.use_pivotal_tracker)
|
47
|
-
github_pull_request_default_body = pivotal_tracker_result.url
|
48
|
-
end
|
49
|
-
print "Body (Default: #{github_pull_request_default_body})? "
|
50
|
-
github_pull_request_body = $stdin.gets.chomp.strip
|
51
|
-
if (github_pull_request_body == '')
|
52
|
-
github_pull_request_body = github_pull_request_default_body
|
53
|
-
end
|
54
|
-
|
55
|
-
# create the pull request
|
56
|
-
begin
|
57
|
-
puts "Running Github Pull Request"
|
58
|
-
github_pull_request_result = github.create_pull_request(github_pull_request_title, github_pull_request_body)
|
59
|
-
puts "Github Pull Request URL: #{github_pull_request_result["html_url"]}"
|
60
|
-
|
61
|
-
if (Toolshed::Client.use_pivotal_tracker)
|
62
|
-
print "Would you like to add a note to PivotalTracker with the pull request URL(y/n)? "
|
63
|
-
update_pt_info = $stdin.gets.chomp.strip
|
64
|
-
|
65
|
-
if (update_pt_info == 'y')
|
66
|
-
result = pivotal_tracker.add_note(story_id, github_pull_request_result["html_url"])
|
67
|
-
result = pivotal_tracker.update_story_state(story_id, Toolshed::PivotalTracker::STORY_STATUS_DEFAULT)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
rescue => e
|
71
|
-
puts e.message
|
72
|
-
exit
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/lib/toolshed/github.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
module Toolshed
|
2
|
-
class Github
|
3
|
-
include HTTParty
|
4
|
-
|
5
|
-
def initialize(options={})
|
6
|
-
username = Toolshed::Client::github_username
|
7
|
-
password = Toolshed::Client::github_password
|
8
|
-
|
9
|
-
unless (options[:username].nil?)
|
10
|
-
username = options[:username]
|
11
|
-
end
|
12
|
-
|
13
|
-
unless (options[:password].nil?)
|
14
|
-
password = options[:password]
|
15
|
-
end
|
16
|
-
|
17
|
-
@auth = { username: username, password: password }
|
18
|
-
@default_options = {
|
19
|
-
:headers => {
|
20
|
-
"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17"
|
21
|
-
},
|
22
|
-
basic_auth: @auth,
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_pull_request(title, body, options={})
|
27
|
-
options.merge!(@default_options)
|
28
|
-
options.merge!({
|
29
|
-
body: {
|
30
|
-
title: title,
|
31
|
-
body: body,
|
32
|
-
head: "#{Toolshed::Client.github_username}:#{self.branch_name}",
|
33
|
-
base: self.branched_from
|
34
|
-
}.to_json
|
35
|
-
})
|
36
|
-
|
37
|
-
response = HTTParty.post("#{Toolshed::Client::GITHUB_BASE_API_URL}repos/#{Toolshed::Client.branched_from_user}/#{Toolshed::Client.branched_from_repo_name}/pulls", options).response
|
38
|
-
response = JSON.parse(response.body)
|
39
|
-
|
40
|
-
if (response["errors"].nil?)
|
41
|
-
response
|
42
|
-
else
|
43
|
-
raise "validation errors #{response.inspect}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def list_branches(options={})
|
48
|
-
options.merge!(@default_options)
|
49
|
-
|
50
|
-
response = HTTParty.get("#{Toolshed::Client::GITHUB_BASE_API_URL}repos/#{Toolshed::Client.github_username}/toolshed/branches", options).response
|
51
|
-
JSON.parse(response.body).each do |branch|
|
52
|
-
puts branch.inspect
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def branch_name
|
57
|
-
# branch information
|
58
|
-
branch_name = `git rev-parse --abbrev-ref HEAD`.strip
|
59
|
-
end
|
60
|
-
|
61
|
-
def branched_from
|
62
|
-
branched_from = `git rev-parse --abbrev-ref --symbolic-full-name @{u}`.split('/')[-1].strip
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.username
|
66
|
-
username = Toolshed::Client::github_username
|
67
|
-
if (username.nil?)
|
68
|
-
# prompt to ask for username
|
69
|
-
puts "Github username? "
|
70
|
-
username = $stdin.gets.chomp.strip
|
71
|
-
end
|
72
|
-
|
73
|
-
return username
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.password
|
77
|
-
password = Toolshed::Client::github_password
|
78
|
-
if (password.nil?)
|
79
|
-
# prompt to ask for password
|
80
|
-
system "stty -echo"
|
81
|
-
puts "Github password? "
|
82
|
-
password = $stdin.gets.chomp.strip
|
83
|
-
system "stty echo"
|
84
|
-
end
|
85
|
-
|
86
|
-
return password
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module Toolshed
|
2
|
-
class PivotalTracker
|
3
|
-
include HTTParty
|
4
|
-
|
5
|
-
STORY_STATUS_DEFAULT = 'finished'
|
6
|
-
|
7
|
-
attr_accessor :project_id, :token
|
8
|
-
|
9
|
-
def initialize(options={})
|
10
|
-
username = Toolshed::Client::pivotal_tracker_username
|
11
|
-
password = Toolshed::Client::pivotal_tracker_password
|
12
|
-
|
13
|
-
unless (options[:username].nil?)
|
14
|
-
username = options[:username]
|
15
|
-
end
|
16
|
-
|
17
|
-
unless (options[:password].nil?)
|
18
|
-
password = options[:password]
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
self.token = ::PivotalTracker::Client.token(username, password)
|
23
|
-
|
24
|
-
self.project_id = (options[:project_id].nil?) ? Toolshed::Client.default_pivotal_tracker_project_id : options[:project_id]
|
25
|
-
@pt_project = ::PivotalTracker::Project.find(self.project_id)
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.story_id_from_branch_name(branch_name)
|
29
|
-
story_id = branch_name.split("_")[0]
|
30
|
-
end
|
31
|
-
|
32
|
-
def story_information(story_id)
|
33
|
-
return @pt_project.stories.find(story_id)
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_note(story_id, note_text)
|
37
|
-
story = @pt_project.stories.find(story_id)
|
38
|
-
results = story.notes.create(text: note_text)
|
39
|
-
end
|
40
|
-
|
41
|
-
def update_story_state(story_id, current_state, options={})
|
42
|
-
options.merge!({
|
43
|
-
:headers => {
|
44
|
-
"X-TrackerToken" => self.token,
|
45
|
-
"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17",
|
46
|
-
"Content-Type" => "application/json",
|
47
|
-
},
|
48
|
-
body: {
|
49
|
-
current_state: current_state
|
50
|
-
}.to_json
|
51
|
-
})
|
52
|
-
|
53
|
-
response = HTTParty.put("#{Toolshed::Client::PIVOTAL_TRACKER_BASE_API_URL}projects/#{self.project_id}/stories/#{story_id}", options).response
|
54
|
-
response = JSON.parse(response.body)
|
55
|
-
|
56
|
-
if (response["error"].nil?)
|
57
|
-
response
|
58
|
-
else
|
59
|
-
raise "validation errors #{response.inspect}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.username
|
64
|
-
username = Toolshed::Client::pivotal_tracker_username
|
65
|
-
if (username.nil?)
|
66
|
-
# prompt to ask for username
|
67
|
-
puts "PivotalTracker username? "
|
68
|
-
username = $stdin.gets.chomp.strip
|
69
|
-
end
|
70
|
-
|
71
|
-
return username
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.password
|
75
|
-
password = Toolshed::Client::pivotal_tracker_password
|
76
|
-
if (password.nil?)
|
77
|
-
# prompt to ask for password
|
78
|
-
system "stty -echo"
|
79
|
-
puts "PivotalTracker password? "
|
80
|
-
password = $stdin.gets.chomp.strip
|
81
|
-
system "stty echo"
|
82
|
-
end
|
83
|
-
|
84
|
-
return password
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|