toolshed 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +3 -0
- data/bin/toolshed.rb +26 -3
- data/lib/toolshed/cli.rb +4 -0
- data/lib/toolshed/client.rb +54 -2
- data/lib/toolshed/commands/create_branch.rb +5 -0
- data/lib/toolshed/commands/create_pull_request.rb +62 -17
- data/lib/toolshed/commands/create_ticket_comment.rb +85 -0
- data/lib/toolshed/commands/get_daily_time_update.rb +22 -19
- data/lib/toolshed/commands/ticket_information.rb +15 -7
- data/lib/toolshed/commands/update_ticket_status.rb +74 -0
- data/lib/toolshed/git/git.rb +3 -2
- data/lib/toolshed/git/github.rb +14 -3
- data/lib/toolshed/ticket_tracking/jira.rb +106 -0
- data/lib/toolshed/ticket_tracking/pivotal_tracker.rb +49 -47
- data/lib/toolshed/ticket_tracking/ticket_tracking.rb +10 -0
- data/lib/toolshed/time_tracking/harvest.rb +47 -26
- data/lib/toolshed/version.rb +1 -1
- data/lib/toolshed.rb +2 -0
- data/test/commands/create_branch_test.rb +20 -0
- data/test/commands/create_pull_request_test.rb +10 -2
- data/test/commands/get_daily_time_update_test.rb +60 -0
- data/test/git/git_helper.rb +1 -1
- data/test/helper.rb +4 -0
- data/test/ticket_tracking/jira_test.rb +260 -0
- data/test/time_tracking/harvest_test.rb +49 -0
- data/toolshed.gemspec +2 -0
- metadata +40 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54a3e26a9cf4670879ed25c97435e8561787c511
|
4
|
+
data.tar.gz: b8f2a24202d44ad03349477e54d2ce1216ebfe61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf484481408ec9dbac5b35d93e19e3dc39f907aec6c5e6fe5f908135b794a401498cd5e9353b6556aeab016a02bf6b32bf1e515de1e9f2e58f8d5a4aff16ca04
|
7
|
+
data.tar.gz: 1b4833ba97542589fb44a81a358f250eaafe730d80e49b9c3339cee24b7df171dadb3f5bad726723df62984a6a176e4ee86565b053384aa87bc875c802ba0252
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/wallerjake/toolshed.svg?branch=master)](https://travis-ci.org/wallerjake/toolshed)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/wallerjake/toolshed.png)](https://codeclimate.com/github/wallerjake/toolshed)
|
3
|
+
|
1
4
|
# Toolshed
|
2
5
|
|
3
6
|
Toolshed is a utility gem meant to make small tasks faster. This includes things like making a pull request up to Github all the way to creating a branch. This gem can be extended to used else where also.
|
data/bin/toolshed.rb
CHANGED
@@ -20,9 +20,11 @@ Note that it will only read one file which ever file is closest to the directory
|
|
20
20
|
pivotal_tracker_username: [pivotal_tracker_username] (optional)
|
21
21
|
pivotal_tracker_password: [pivotal_tracker_password] (optional)
|
22
22
|
default_pivotal_tracker_project_id: [project_id] (optional)
|
23
|
+
ticket_status_for_complete: [status] (required (only if using pull requests)) example: "Code Review"
|
23
24
|
|
24
|
-
github_username:
|
25
|
-
github_password:
|
25
|
+
github_username: [github_username] (optional)
|
26
|
+
github_password: [github_password] (optional)
|
27
|
+
github_token: [github_token] (optional) - create the token if your account require two factor you can disable token or enable through Github. See https://github.com/settings/tokens/new for details.
|
26
28
|
git_tool: github (optional default `github`)
|
27
29
|
use_git_submodules: false (optional default `false`)
|
28
30
|
pull_from_remote_name: [pull_from_remote_name] (required)
|
@@ -36,7 +38,7 @@ Note that it will only read one file which ever file is closest to the directory
|
|
36
38
|
time_tracking_password: [password] (optional)
|
37
39
|
time_tracking_owner: [owner] (optional)
|
38
40
|
time_tracking_default_project_id: [project_id] (optional)
|
39
|
-
time_tracking_tool: [tool] (
|
41
|
+
time_tracking_tool: [tool] (required unless you are not going to be doing time tracking)
|
40
42
|
|
41
43
|
== Commands
|
42
44
|
|
@@ -73,6 +75,8 @@ push_branch [ # Push your current working branch to yo
|
|
73
75
|
]
|
74
76
|
get_daily_time_update [ # Get a daily update from your time tracking toolset currently harvest is supported
|
75
77
|
--format="html|text" # Format you want if you want html it will open html page in broswer otherwise puts out plain text
|
78
|
+
--use-defaults="true|false" # If you want to use your default project_id instead of entering it
|
79
|
+
--project-id="1234" # If you want to use a project id other than your defaults
|
76
80
|
]
|
77
81
|
list_branches [ # List branches for your remote repository
|
78
82
|
--repository-name "depot" # The repository name you want to list branches for if not passed pull_from_repository_name is used
|
@@ -80,6 +84,11 @@ list_branches [ # List branches for your remote reposito
|
|
80
84
|
delete_branch [ # Delete a branch both locally and to your push to remote
|
81
85
|
--branch-name "134_mybranch" | "134" # Either the full branch name or some unique string in the branch i.e. ticket id
|
82
86
|
]
|
87
|
+
create_ticket_comment [ # Add a comment to a specific ticket
|
88
|
+
--use-defaults "true" # use defaults instead of getting prompts if you don't want to supply project name
|
89
|
+
]
|
90
|
+
update_ticket_status [ # Update a specific tickets status
|
91
|
+
]
|
83
92
|
EOF
|
84
93
|
end
|
85
94
|
|
@@ -93,6 +102,9 @@ if $0.split("/").last == 'toolshed'
|
|
93
102
|
opts.on("-p", "--github-password [ARG]") do |password|
|
94
103
|
Toolshed::Client.github_password = password
|
95
104
|
end
|
105
|
+
opts.on("-t", "--github-token [ARG]") do |token|
|
106
|
+
Toolshed::Client.github_token = token
|
107
|
+
end
|
96
108
|
opts.on("-u", "--pivotal-tracker-username [ARG]") do |username|
|
97
109
|
Toolshed::Client.pivotal_tracker_username = username
|
98
110
|
end
|
@@ -160,6 +172,12 @@ if $0.split("/").last == 'toolshed'
|
|
160
172
|
opts.on("--format [ARG]") do |opt|
|
161
173
|
options[:format] = opt
|
162
174
|
end
|
175
|
+
opts.on("--use-defaults [ARG]") do |opt|
|
176
|
+
Toolshed::Client.use_defaults = opt
|
177
|
+
end
|
178
|
+
opts.on("--project-id [ARG]") do |opt|
|
179
|
+
options[:project_id] = opt
|
180
|
+
end
|
163
181
|
end,
|
164
182
|
'ticket_information' => OptionParser.new do |opts|
|
165
183
|
opts.on("--use-defaults [ARG]") do |opt|
|
@@ -175,6 +193,11 @@ if $0.split("/").last == 'toolshed'
|
|
175
193
|
options[:formatted_string] = opt
|
176
194
|
end
|
177
195
|
end,
|
196
|
+
'create_ticket_comment' => OptionParser.new do |opts|
|
197
|
+
opts.on("--use-defaults [ARG]") do |opt|
|
198
|
+
Toolshed::Client.use_defaults = opt
|
199
|
+
end
|
200
|
+
end,
|
178
201
|
}
|
179
202
|
|
180
203
|
global.order!
|
data/lib/toolshed/cli.rb
CHANGED
@@ -31,6 +31,8 @@ module Toolshed
|
|
31
31
|
'get_daily_time_update' => Toolshed::Commands::GetDailyTimeUpdate,
|
32
32
|
'list_branches' => Toolshed::Commands::ListBranches,
|
33
33
|
'delete_branch' => Toolshed::Commands::DeleteBranch,
|
34
|
+
'create_ticket_comment' => Toolshed::Commands::CreateTicketComment,
|
35
|
+
'update_ticket_status' => Toolshed::Commands::UpdateTicketStatus,
|
34
36
|
}
|
35
37
|
end
|
36
38
|
end
|
@@ -47,3 +49,5 @@ require 'toolshed/commands/get_daily_time_update'
|
|
47
49
|
require 'toolshed/commands/get_daily_time_update'
|
48
50
|
require 'toolshed/commands/list_branches'
|
49
51
|
require 'toolshed/commands/delete_branch'
|
52
|
+
require 'toolshed/commands/create_ticket_comment'
|
53
|
+
require 'toolshed/commands/update_ticket_status'
|
data/lib/toolshed/client.rb
CHANGED
@@ -49,6 +49,14 @@ module Toolshed
|
|
49
49
|
@github_password = password
|
50
50
|
end
|
51
51
|
|
52
|
+
def self.github_token
|
53
|
+
@github_token
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.github_token=(token)
|
57
|
+
@github_token = token
|
58
|
+
end
|
59
|
+
|
52
60
|
def self.pull_from_remote_name
|
53
61
|
@pull_from_remote_name
|
54
62
|
end
|
@@ -106,7 +114,8 @@ module Toolshed
|
|
106
114
|
end
|
107
115
|
|
108
116
|
|
109
|
-
#
|
117
|
+
# ticket tracking information
|
118
|
+
|
110
119
|
def self.pivotal_tracker_username
|
111
120
|
@pivotal_tracker_username
|
112
121
|
end
|
@@ -131,8 +140,29 @@ module Toolshed
|
|
131
140
|
@default_pivotal_tracker_project_id = default_pivotal_tracker_project_id
|
132
141
|
end
|
133
142
|
|
143
|
+
def self.ticket_tracker_username
|
144
|
+
@ticket_tracker_username
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.ticket_tracker_username=(username)
|
148
|
+
@ticket_tracker_username = username
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.ticket_tracker_password
|
152
|
+
@ticket_tracker_password
|
153
|
+
end
|
134
154
|
|
135
|
-
|
155
|
+
def self.ticket_tracker_password=(password)
|
156
|
+
@ticket_tracker_password = password
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.default_ticket_tracker_project
|
160
|
+
@default_ticket_tracker_project
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.default_ticket_tracker_project=(default_ticket_tracker_project)
|
164
|
+
@default_ticket_tracker_project = default_ticket_tracker_project
|
165
|
+
end
|
136
166
|
|
137
167
|
def self.ticket_tracking_tool
|
138
168
|
@ticket_tracking_tool
|
@@ -142,6 +172,22 @@ module Toolshed
|
|
142
172
|
@ticket_tracking_tool = ticket_tracking_tool
|
143
173
|
end
|
144
174
|
|
175
|
+
def self.ticket_tracker_owner
|
176
|
+
@ticket_tracker_owner
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.ticket_tracker_owner=(owner)
|
180
|
+
@ticket_tracker_owner = owner
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.ticket_status_for_complete
|
184
|
+
@ticket_status_for_complete
|
185
|
+
end
|
186
|
+
|
187
|
+
def self.ticket_status_for_complete=(status)
|
188
|
+
@ticket_status_for_complete = status
|
189
|
+
end
|
190
|
+
|
145
191
|
# time tracking configuration
|
146
192
|
|
147
193
|
def self.time_tracking_tool
|
@@ -213,9 +259,15 @@ module Toolshed
|
|
213
259
|
credentials = YAML.load_file(File.expand_path(loaded_from_path))
|
214
260
|
self.github_username ||= credentials['github_username']
|
215
261
|
self.github_password ||= credentials['github_password']
|
262
|
+
self.github_token ||= credentials['github_token']
|
216
263
|
self.pivotal_tracker_username ||= credentials['pivotal_tracker_username']
|
217
264
|
self.pivotal_tracker_password ||= credentials['pivotal_tracker_password']
|
218
265
|
self.default_pivotal_tracker_project_id ||= credentials['default_pivotal_tracker_project_id']
|
266
|
+
self.ticket_tracker_username ||= credentials['ticket_tracker_username']
|
267
|
+
self.ticket_tracker_password ||= credentials['ticket_tracker_password']
|
268
|
+
self.ticket_tracker_owner ||= credentials['ticket_tracker_owner']
|
269
|
+
self.ticket_status_for_complete ||= credentials['ticket_status_for_complete']
|
270
|
+
self.default_ticket_tracker_project ||= credentials['default_ticket_tracker_project']
|
219
271
|
self.pull_from_remote_name ||= credentials['pull_from_remote_name']
|
220
272
|
self.pull_from_repository_user ||= credentials['pull_from_repository_user']
|
221
273
|
self.pull_from_repository_name ||= credentials['pull_from_repository_name']
|
@@ -44,6 +44,11 @@ module Toolshed
|
|
44
44
|
def read_user_input_branch_from(message, options)
|
45
45
|
return options[:branch_from] if (options.has_key?(:branch_from))
|
46
46
|
|
47
|
+
# if branch-name was supplied then default to master if not supplied
|
48
|
+
if (options.has_key?(:branch_name))
|
49
|
+
return Toolshed::Git::DEFAULT_BRANCH_FROM
|
50
|
+
end
|
51
|
+
|
47
52
|
puts message
|
48
53
|
value = $stdin.gets.chomp
|
49
54
|
|
@@ -7,7 +7,7 @@ module Toolshed
|
|
7
7
|
puts "Branched From: #{Toolshed::Git::Base.branched_from}"
|
8
8
|
puts "Using Defaults: #{(Toolshed::Client.use_defaults.nil?) ? 'No' : 'Yes'}"
|
9
9
|
|
10
|
-
unless (Toolshed::Client.ticket_tracking_tool.empty?)
|
10
|
+
unless (Toolshed::Client.ticket_tracking_tool.nil? || Toolshed::Client.ticket_tracking_tool.empty?)
|
11
11
|
ticket_tracking_url = ''
|
12
12
|
ticket_tracking_title = ''
|
13
13
|
ticket_id = ''
|
@@ -15,25 +15,52 @@ module Toolshed
|
|
15
15
|
begin
|
16
16
|
ticket_tracker_class = Object.const_get("Toolshed::TicketTracking::#{Toolshed::Client.ticket_tracking_tool.camel_case}")
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
use_project_id = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") rescue false
|
19
|
+
if use_project_id
|
20
|
+
ticket_tracker_project_id = read_user_input_project(
|
21
|
+
"Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id}):",
|
22
|
+
options.merge!({
|
23
|
+
default: Toolshed::Client.default_pivotal_tracker_project_id,
|
24
|
+
})
|
25
|
+
)
|
26
|
+
options.merge!({
|
27
|
+
project_id: ticket_tracker_project_id,
|
28
|
+
})
|
21
29
|
end
|
22
30
|
|
23
|
-
|
31
|
+
use_project_name = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_NAME") rescue false
|
32
|
+
if use_project_name
|
33
|
+
ticket_tracker_project_name = read_user_input_project(
|
34
|
+
"Project Name (Default: #{Toolshed::Client.default_ticket_tracker_project}):", options.merge!({
|
35
|
+
default: Toolshed::Client.default_ticket_tracker_project,
|
36
|
+
})
|
37
|
+
)
|
38
|
+
options.merge!({
|
39
|
+
project: ticket_tracker_project_name,
|
40
|
+
})
|
41
|
+
end
|
24
42
|
|
25
43
|
# @TODO - refactor this code into the git module seems more appropriate since it's performing git functions
|
26
|
-
ticket_id = read_user_input_ticket_tracker_ticket_id(
|
27
|
-
|
44
|
+
ticket_id = read_user_input_ticket_tracker_ticket_id(
|
45
|
+
"Ticket ID (Default: #{Toolshed::TicketTracking::story_id_from_branch_name(Toolshed::Git::Base.branch_name)}):", {
|
46
|
+
default: Toolshed::TicketTracking::story_id_from_branch_name(Toolshed::Git::Base.branch_name),
|
47
|
+
}
|
48
|
+
)
|
49
|
+
options.merge!({
|
50
|
+
ticket_id: ticket_id,
|
51
|
+
})
|
52
|
+
|
53
|
+
ticket_tracker = ticket_tracker_class.create_instance(options)
|
28
54
|
|
29
|
-
ticket_tracking_url =
|
30
|
-
ticket_tracking_title =
|
31
|
-
ticket_id =
|
55
|
+
ticket_tracking_url = ticket_tracker.url
|
56
|
+
ticket_tracking_title = ticket_tracker.title
|
57
|
+
ticket_id = ticket_id
|
32
58
|
|
33
59
|
puts "Ticket Tracking URL: #{ticket_tracking_url}"
|
34
60
|
puts "Ticket Tracking title: #{ticket_tracking_title}"
|
35
61
|
puts "Ticket ID: #{ticket_id}"
|
36
62
|
rescue Exception => e
|
63
|
+
puts e.inspect
|
37
64
|
puts "Ticket tracking tool is not supported at this time"
|
38
65
|
return
|
39
66
|
end
|
@@ -45,17 +72,35 @@ module Toolshed
|
|
45
72
|
git_tool = git_tool_class.create_instance
|
46
73
|
|
47
74
|
# create the pull request prompt when needed
|
48
|
-
title = read_user_input_pull_request_title(
|
49
|
-
|
75
|
+
title = read_user_input_pull_request_title(
|
76
|
+
"Pull request title (Default: #{ticket_tracking_title}):",
|
77
|
+
options.merge!({
|
78
|
+
default: ticket_tracking_title,
|
79
|
+
})
|
80
|
+
)
|
81
|
+
body = read_user_input_pull_request_body(
|
82
|
+
"Pull request body (Default: #{ticket_tracking_url}):",
|
83
|
+
options.merge!({
|
84
|
+
default: ticket_tracking_url
|
85
|
+
})
|
86
|
+
)
|
50
87
|
|
51
88
|
puts "Pull request being created"
|
52
89
|
git_pull_request_result = git_tool.create_pull_request(title, body)
|
53
90
|
pull_request_url = git_pull_request_result["html_url"]
|
54
91
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
92
|
+
unless (Toolshed::Client.ticket_tracking_tool.nil? || Toolshed::Client.ticket_tracking_tool.empty?)
|
93
|
+
add_note_to_ticket = read_user_input_add_note_to_ticket("Would you like to add a note with the pull request url?")
|
94
|
+
if (add_note_to_ticket)
|
95
|
+
result = ticket_tracker.add_note(pull_request_url)
|
96
|
+
|
97
|
+
default_completed_status = Object.const_get("#{ticket_tracker_class}::DEFAULT_COMPLETED_STATUS") rescue false
|
98
|
+
unless (default_completed_status)
|
99
|
+
default_completed_status = Toolshed::Client.ticket_status_for_complete
|
100
|
+
end
|
101
|
+
|
102
|
+
result = ticket_tracker.update_ticket_status(default_completed_status)
|
103
|
+
end
|
59
104
|
end
|
60
105
|
|
61
106
|
puts "Created Pull Request: #{pull_request_url}"
|
@@ -107,7 +152,7 @@ module Toolshed
|
|
107
152
|
value
|
108
153
|
end
|
109
154
|
|
110
|
-
def
|
155
|
+
def read_user_input_project(message, options)
|
111
156
|
return options[:default] if (Toolshed::Client.use_defaults)
|
112
157
|
|
113
158
|
puts message
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Toolshed
|
2
|
+
module Commands
|
3
|
+
class CreateTicketComment
|
4
|
+
def execute(args, options = {})
|
5
|
+
ticket_tracker_class = Object.const_get("Toolshed::TicketTracking::#{Toolshed::Client.ticket_tracking_tool.camel_case}")
|
6
|
+
|
7
|
+
use_project_id = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") rescue false
|
8
|
+
if use_project_id
|
9
|
+
ticket_tracker_project_id = read_user_input_project(
|
10
|
+
"Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id}):",
|
11
|
+
options.merge!({
|
12
|
+
default: Toolshed::Client.default_pivotal_tracker_project_id,
|
13
|
+
})
|
14
|
+
)
|
15
|
+
options.merge!({
|
16
|
+
project_id: ticket_tracker_project_id
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
use_project_name = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_NAME") rescue false
|
21
|
+
if use_project_name
|
22
|
+
ticket_tracker_project_name = read_user_input_project(
|
23
|
+
"Project Name (Default: #{Toolshed::Client.default_ticket_tracker_project}):",
|
24
|
+
options.merge!({ default: Toolshed::Client.default_ticket_tracker_project })
|
25
|
+
)
|
26
|
+
options.merge!({
|
27
|
+
project: ticket_tracker_project_name
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
default_ticket_id = Toolshed::TicketTracking::story_id_from_branch_name(Toolshed::Git::Base.branch_name)
|
32
|
+
ticket_id = read_user_input_ticket_id("Ticket ID (Default: #{default_ticket_id}):", options.merge!({ default: default_ticket_id }))
|
33
|
+
options.merge!({ ticket_id: ticket_id })
|
34
|
+
|
35
|
+
ticket_tracker = ticket_tracker_class.create_instance(options)
|
36
|
+
|
37
|
+
if use_project_id
|
38
|
+
puts "Using Project: #{ticket_tracker_project_id}"
|
39
|
+
end
|
40
|
+
puts "Using Ticket: #{ticket_id}"
|
41
|
+
|
42
|
+
puts "Note? "
|
43
|
+
note_text = $stdin.gets.chomp.strip
|
44
|
+
|
45
|
+
begin
|
46
|
+
result = ticket_tracker.add_note(note_text)
|
47
|
+
if (result)
|
48
|
+
puts "Comment has been added to ticket"
|
49
|
+
else
|
50
|
+
puts "Unable to add comment #{result.inspect}"
|
51
|
+
end
|
52
|
+
rescue => e
|
53
|
+
puts e.message
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def read_user_input_project(message, options)
|
59
|
+
return options[:default] if (options.has_key?(:use_defaults))
|
60
|
+
|
61
|
+
puts message
|
62
|
+
value = $stdin.gets.chomp
|
63
|
+
|
64
|
+
if (value.empty?)
|
65
|
+
value = options[:default]
|
66
|
+
end
|
67
|
+
|
68
|
+
value
|
69
|
+
end
|
70
|
+
|
71
|
+
def read_user_input_ticket_id(message, options)
|
72
|
+
return options[:default] if (options.has_key?(:use_defaults))
|
73
|
+
|
74
|
+
puts message
|
75
|
+
value = $stdin.gets.chomp
|
76
|
+
|
77
|
+
if (value.empty?)
|
78
|
+
value = options[:default]
|
79
|
+
end
|
80
|
+
|
81
|
+
value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -2,29 +2,32 @@ module Toolshed
|
|
2
2
|
module Commands
|
3
3
|
class GetDailyTimeUpdate
|
4
4
|
def execute(args, options = {})
|
5
|
-
|
6
|
-
|
5
|
+
begin
|
6
|
+
time_tracking_class = Object.const_get("Toolshed::TimeTracking::#{Toolshed::Client.time_tracking_tool.camel_case}")
|
7
|
+
|
8
|
+
time_tracking_project_id = read_user_input_project_id("Project ID (Default: #{Toolshed::Client.time_tracking_default_project_id}):", options.merge!({ default: Toolshed::Client.time_tracking_default_project_id }))
|
9
|
+
options.merge!({ project_id: time_tracking_project_id })
|
10
|
+
time_tracker = time_tracking_class.create_instance(options)
|
7
11
|
|
8
12
|
puts "Getting time entries:"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
time_tracker.display
|
14
|
+
rescue Exception => e
|
15
|
+
puts "Time tracking tool is undefined implementation needed or an error occured #{e.inspect}"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
end
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
puts notes
|
23
|
-
end
|
24
|
-
else
|
25
|
-
puts "Time tracking tool is undefined implementation needed"
|
26
|
-
exit
|
20
|
+
def read_user_input_project_id(message, options)
|
21
|
+
return options[:project_id] if (options.has_key?(:project_id))
|
22
|
+
return options[:default] if (Toolshed::Client.use_defaults)
|
23
|
+
|
24
|
+
puts message
|
25
|
+
value = $stdin.gets.chomp
|
26
|
+
if (value.empty?)
|
27
|
+
value = options[:default]
|
27
28
|
end
|
29
|
+
|
30
|
+
value
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
@@ -5,22 +5,30 @@ module Toolshed
|
|
5
5
|
begin
|
6
6
|
ticket_tracker_class = Object.const_get("Toolshed::TicketTracking::#{Toolshed::Client.ticket_tracking_tool.camel_case}")
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
use_project_id = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") rescue false
|
9
|
+
if use_project_id
|
10
|
+
ticket_tracker_project_id = read_user_input_project("Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id}):", options.merge!({ default: Toolshed::Client.default_pivotal_tracker_project_id }))
|
10
11
|
options.merge!({ project_id: ticket_tracker_project_id })
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
use_project_name = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_NAME") rescue false
|
15
|
+
if use_project_name
|
16
|
+
ticket_tracker_project_name = read_user_input_project("Project Name (Default: #{Toolshed::Client.default_ticket_tracker_project}):", options.merge!({ default: Toolshed::Client.default_ticket_tracker_project }))
|
17
|
+
options.merge!({ project: ticket_tracker_project_name })
|
18
|
+
end
|
14
19
|
|
15
|
-
default_ticket_id = Toolshed::TicketTracking::
|
20
|
+
default_ticket_id = Toolshed::TicketTracking::story_id_from_branch_name(Toolshed::Git::Base.branch_name)
|
16
21
|
ticket_id = read_user_input_ticket_id("Story ID (Default: #{default_ticket_id}):", options.merge!({ default: default_ticket_id }))
|
22
|
+
options.merge!({ ticket_id: ticket_id })
|
23
|
+
|
24
|
+
ticket_tracker = ticket_tracker_class.create_instance(options)
|
17
25
|
|
18
|
-
if
|
26
|
+
if use_project_id
|
19
27
|
puts "Using Project: #{ticket_tracker_project_id}"
|
20
28
|
end
|
21
29
|
puts "Using Ticket: #{ticket_id}"
|
22
30
|
|
23
|
-
result = ticket_tracker.
|
31
|
+
result = ticket_tracker.ticket
|
24
32
|
|
25
33
|
if (options[:field])
|
26
34
|
field_value = result.send(options[:field])
|
@@ -49,7 +57,7 @@ module Toolshed
|
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
def
|
60
|
+
def read_user_input_project(message, options)
|
53
61
|
return options[:default] if (options.has_key?(:use_defaults))
|
54
62
|
|
55
63
|
puts message
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Toolshed
|
2
|
+
module Commands
|
3
|
+
class UpdateTicketStatus
|
4
|
+
def execute(args, options = {})
|
5
|
+
ticket_tracker_class = Object.const_get("Toolshed::TicketTracking::#{Toolshed::Client.ticket_tracking_tool.camel_case}")
|
6
|
+
|
7
|
+
use_project_id = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") rescue false
|
8
|
+
if use_project_id
|
9
|
+
ticket_tracker_project_id = read_user_input_project("Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id}):", options.merge!({ default: Toolshed::Client.default_pivotal_tracker_project_id }))
|
10
|
+
options.merge!({ project_id: ticket_tracker_project_id })
|
11
|
+
end
|
12
|
+
|
13
|
+
use_project_name = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_NAME") rescue false
|
14
|
+
if use_project_name
|
15
|
+
ticket_tracker_project_name = read_user_input_project("Project Name (Default: #{Toolshed::Client.default_ticket_tracker_project}):", options.merge!({ default: Toolshed::Client.default_ticket_tracker_project }))
|
16
|
+
options.merge!({ project: ticket_tracker_project_name })
|
17
|
+
end
|
18
|
+
|
19
|
+
default_ticket_id = Toolshed::TicketTracking::story_id_from_branch_name(Toolshed::Git::Base.branch_name)
|
20
|
+
ticket_id = read_user_input_ticket_id("Ticket ID (Default: #{default_ticket_id}):", options.merge!({ default: default_ticket_id }))
|
21
|
+
options.merge!({ ticket_id: ticket_id })
|
22
|
+
|
23
|
+
ticket_tracker = ticket_tracker_class.create_instance(options)
|
24
|
+
|
25
|
+
status = read_user_input_status("Status:")
|
26
|
+
|
27
|
+
begin
|
28
|
+
result = ticket_tracker.update_ticket_status(status)
|
29
|
+
puts result
|
30
|
+
rescue => e
|
31
|
+
puts e.message
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def read_user_input_project(message, options)
|
37
|
+
return options[:default] if (options.has_key?(:use_defaults))
|
38
|
+
|
39
|
+
puts message
|
40
|
+
value = $stdin.gets.chomp
|
41
|
+
|
42
|
+
if (value.empty?)
|
43
|
+
value = options[:default]
|
44
|
+
end
|
45
|
+
|
46
|
+
value
|
47
|
+
end
|
48
|
+
|
49
|
+
def read_user_input_ticket_id(message, options)
|
50
|
+
return options[:default] if (options.has_key?(:use_defaults))
|
51
|
+
|
52
|
+
puts message
|
53
|
+
value = $stdin.gets.chomp
|
54
|
+
|
55
|
+
if (value.empty?)
|
56
|
+
value = options[:default]
|
57
|
+
end
|
58
|
+
|
59
|
+
value
|
60
|
+
end
|
61
|
+
|
62
|
+
def read_user_input_status(message)
|
63
|
+
puts message
|
64
|
+
value = $stdin.gets.chomp
|
65
|
+
|
66
|
+
until (!value.blank?)
|
67
|
+
puts "Status must be passed in"
|
68
|
+
puts message
|
69
|
+
value = $stdin.gets.chomp
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/toolshed/git/git.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Toolshed
|
2
2
|
module Git
|
3
|
-
DEFAULT_GIT_TOOL
|
3
|
+
DEFAULT_GIT_TOOL = 'github'
|
4
|
+
DEFAULT_BRANCH_FROM = 'master'
|
4
5
|
|
5
6
|
def branch_name
|
6
7
|
# branch information
|
@@ -49,7 +50,7 @@ module Toolshed
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def clean_branch_name(branch_name)
|
52
|
-
branch_name.strip.downcase.tr(" ", "_").gsub("
|
53
|
+
branch_name.strip.downcase.tr(" ", "_").gsub("&", "").gsub("/", "_").gsub(".", "_").gsub("'", "").gsub("__", "_").gsub(":", "").gsub(",", "")
|
53
54
|
end
|
54
55
|
|
55
56
|
def push(options = {})
|
data/lib/toolshed/git/github.rb
CHANGED
@@ -9,8 +9,9 @@ module Toolshed
|
|
9
9
|
def initialize(options={})
|
10
10
|
super(options)
|
11
11
|
|
12
|
-
username
|
13
|
-
password
|
12
|
+
username = Toolshed::Client::github_username
|
13
|
+
password = Toolshed::Client::github_password
|
14
|
+
token = Toolshed::Client::github_token
|
14
15
|
|
15
16
|
unless (options[:username].nil?)
|
16
17
|
username = options[:username]
|
@@ -20,10 +21,20 @@ module Toolshed
|
|
20
21
|
password = options[:password]
|
21
22
|
end
|
22
23
|
|
24
|
+
unless (token.nil?)
|
25
|
+
username = token
|
26
|
+
password = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
unless (options[:token].nil?)
|
30
|
+
username = options[:token]
|
31
|
+
password = nil
|
32
|
+
end
|
33
|
+
|
23
34
|
@auth = { username: username, password: password }
|
24
35
|
self.default_options = {
|
25
36
|
:headers => {
|
26
|
-
"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"
|
37
|
+
"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",
|
27
38
|
},
|
28
39
|
basic_auth: @auth,
|
29
40
|
}
|