v2gpti 1.1.9 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/git-deliver +1 -1
- data/bin/git-finish +1 -1
- data/bin/git-newbug +1 -1
- data/bin/git-newfeature +1 -1
- data/bin/git-qa +1 -1
- data/bin/git-release +1 -1
- data/bin/git-report +1 -1
- data/bin/git-start +1 -1
- data/bin/git-uat +1 -1
- data/config_template +16 -0
- data/lib/git-pivotal-tracker-integration/command/base.rb +235 -322
- data/lib/git-pivotal-tracker-integration/command/configuration.rb +183 -109
- data/lib/git-pivotal-tracker-integration/command/deliver.rb +145 -200
- data/lib/git-pivotal-tracker-integration/command/finish.rb +70 -63
- data/lib/git-pivotal-tracker-integration/command/newbug.rb +36 -39
- data/lib/git-pivotal-tracker-integration/command/newfeature.rb +43 -42
- data/lib/git-pivotal-tracker-integration/command/release.rb +171 -203
- data/lib/git-pivotal-tracker-integration/command/report.rb +33 -36
- data/lib/git-pivotal-tracker-integration/command/start.rb +74 -78
- data/lib/git-pivotal-tracker-integration/util/git.rb +202 -204
- data/lib/git-pivotal-tracker-integration/util/shell.rb +19 -16
- data/lib/git-pivotal-tracker-integration/util/story.rb +155 -177
- data/lib/git-pivotal-tracker-integration/version-update/gradle.rb +44 -40
- data/lib/git-pivotal-tracker-integration.rb +44 -0
- data/spec/git-pivotal-tracker-integration/command/configuration_spec.rb +1 -2
- data/spec/git-pivotal-tracker-integration/command/finish_spec.rb +1 -1
- data/spec/git-pivotal-tracker-integration/command/release_spec.rb +1 -1
- data/spec/git-pivotal-tracker-integration/command/start_spec.rb +1 -1
- data/spec/git-pivotal-tracker-integration/util/story_spec.rb +21 -32
- data/tracker_api/lib/tracker_api/client.rb +241 -0
- data/tracker_api/lib/tracker_api/endpoints/activity.rb +38 -0
- data/tracker_api/lib/tracker_api/endpoints/comments.rb +27 -0
- data/tracker_api/lib/tracker_api/endpoints/epic.rb +17 -0
- data/tracker_api/lib/tracker_api/endpoints/epics.rb +20 -0
- data/tracker_api/lib/tracker_api/endpoints/file_attachment.rb +18 -0
- data/tracker_api/lib/tracker_api/endpoints/iterations.rb +20 -0
- data/tracker_api/lib/tracker_api/endpoints/me.rb +17 -0
- data/tracker_api/lib/tracker_api/endpoints/memberships.rb +20 -0
- data/tracker_api/lib/tracker_api/endpoints/notifications.rb +20 -0
- data/tracker_api/lib/tracker_api/endpoints/project.rb +17 -0
- data/tracker_api/lib/tracker_api/endpoints/projects.rb +18 -0
- data/tracker_api/lib/tracker_api/endpoints/stories.rb +20 -0
- data/tracker_api/lib/tracker_api/endpoints/story.rb +37 -0
- data/tracker_api/lib/tracker_api/endpoints/tasks.rb +20 -0
- data/tracker_api/lib/tracker_api/error.rb +18 -0
- data/tracker_api/lib/tracker_api/logger.rb +31 -0
- data/tracker_api/lib/tracker_api/resources/account.rb +18 -0
- data/tracker_api/lib/tracker_api/resources/activity.rb +24 -0
- data/tracker_api/lib/tracker_api/resources/base.rb +71 -0
- data/tracker_api/lib/tracker_api/resources/change.rb +15 -0
- data/tracker_api/lib/tracker_api/resources/comment.rb +20 -0
- data/tracker_api/lib/tracker_api/resources/epic.rb +17 -0
- data/tracker_api/lib/tracker_api/resources/file_attachment.rb +23 -0
- data/tracker_api/lib/tracker_api/resources/iteration.rb +24 -0
- data/tracker_api/lib/tracker_api/resources/label.rb +14 -0
- data/tracker_api/lib/tracker_api/resources/me.rb +21 -0
- data/tracker_api/lib/tracker_api/resources/membership_summary.rb +15 -0
- data/tracker_api/lib/tracker_api/resources/notification.rb +26 -0
- data/tracker_api/lib/tracker_api/resources/person.rb +14 -0
- data/tracker_api/lib/tracker_api/resources/primary_resource.rb +13 -0
- data/tracker_api/lib/tracker_api/resources/project.rb +131 -0
- data/tracker_api/lib/tracker_api/resources/project_membership.rb +16 -0
- data/tracker_api/lib/tracker_api/resources/story.rb +102 -0
- data/tracker_api/lib/tracker_api/resources/task.rb +16 -0
- data/tracker_api/lib/tracker_api/resources/time_zone.rb +13 -0
- data/tracker_api/lib/tracker_api/version.rb +3 -0
- data/tracker_api/lib/tracker_api.rb +60 -0
- metadata +202 -53
- data/lib/git-pivotal-tracker-integration/command/command.rb +0 -20
- data/lib/git-pivotal-tracker-integration/util/util.rb +0 -20
- data/lib/git-pivotal-tracker-integration/version-update/version_update.rb +0 -20
- data/lib/git_pivotal_tracker_integration.rb +0 -18
@@ -13,127 +13,201 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
api_token
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
16
|
+
module GitPivotalTrackerIntegration
|
17
|
+
module Command
|
18
|
+
|
19
|
+
# A class that exposes configuration that commands can use
|
20
|
+
class Configuration
|
21
|
+
|
22
|
+
SUPPORTED_PLATFORMS = ["ios", "android", "ruby-gem", "others"]
|
23
|
+
KEY_API_TOKEN = 'pivotal.api-token'.freeze
|
24
|
+
KEY_PROJECT_ID = 'pivotal.project-id'.freeze
|
25
|
+
KEY_PLATFORM_NAME = 'platform.platform-name'.freeze
|
26
|
+
KEY_STORY_ID = 'pivotal-story-id'.freeze
|
27
|
+
|
28
|
+
# Returns the user's Pivotal Tracker API token. If this token has not been
|
29
|
+
# configured, prompts the user for the value. The value is checked for in
|
30
|
+
# the _inherited_ Git configuration, but is stored in the _global_ Git
|
31
|
+
# configuration so that it can be used across multiple repositories.
|
32
|
+
#
|
33
|
+
# @return [String] The user's Pivotal Tracker API token
|
34
|
+
|
35
|
+
def api_token
|
36
|
+
api_token = Util::Git.get_config KEY_API_TOKEN, :inherited
|
37
|
+
if api_token.empty?
|
38
|
+
api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip
|
39
|
+
Util::Git.set_config KEY_API_TOKEN, api_token, :global
|
40
|
+
puts
|
41
|
+
end
|
42
|
+
self.check_config_project_id
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
if toggle_config.nil?
|
47
|
-
abort "toggle project id not set"
|
48
|
-
else
|
49
|
-
toggle_config["project-id"]
|
50
|
-
end
|
51
|
-
end
|
44
|
+
api_token
|
45
|
+
end
|
52
46
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
def toggl_project_id
|
48
|
+
toggle_config = self.pconfig["toggl"]
|
49
|
+
if toggle_config.nil?
|
50
|
+
abort "toggle project id not set"
|
51
|
+
else
|
52
|
+
toggle_config["project-id"]
|
53
|
+
end
|
54
|
+
end
|
57
55
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
# checked for in the _inherited_ Git configuration, but is stored in the
|
69
|
-
# _local_ Git configuration so that it is specific to this repository.
|
70
|
-
#
|
71
|
-
# @return [String] The repository's Pivotal Tracker project id
|
72
|
-
def project_id
|
73
|
-
project_id = GitPivotalTrackerIntegration::Util::Git.get_config KEY_PROJECT_ID, :inherited
|
74
|
-
|
75
|
-
if project_id.empty?
|
76
|
-
project_id = choose do |menu|
|
77
|
-
menu.prompt = 'Choose project associated with this repository: '
|
78
|
-
|
79
|
-
PivotalTracker::Project.all.sort_by { |project| project.name }.each do |project|
|
80
|
-
menu.choice(project.name) { project.id }
|
56
|
+
def check_config_project_id
|
57
|
+
Util::Git.set_config("pivotal.project-id", self.pconfig["pivotal-tracker"]["project-id"])
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def pconfig
|
62
|
+
pc = nil
|
63
|
+
config_filename = "#{Util::Git.repository_root}/.v2gpti/config"
|
64
|
+
if File.file?(config_filename)
|
65
|
+
pc = ParseConfig.new(config_filename)
|
81
66
|
end
|
67
|
+
pc
|
82
68
|
end
|
83
69
|
|
84
|
-
|
85
|
-
|
86
|
-
|
70
|
+
# Returns the Pivotal Tracker project id for this repository. If this id
|
71
|
+
# has not been configuration, prompts the user for the value. The value is
|
72
|
+
# checked for in the _inherited_ Git configuration, but is stored in the
|
73
|
+
# _local_ Git configuration so that it is specific to this repository.
|
74
|
+
#
|
75
|
+
# @return [String] The repository's Pivotal Tracker project id
|
76
|
+
def project_id
|
77
|
+
project_id = Util::Git.get_config KEY_PROJECT_ID, :inherited
|
87
78
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
def platform_name
|
92
|
-
platform_name = self.pconfig["platform"]["platform-name"].downcase
|
93
|
-
|
94
|
-
if platform_name.empty?
|
95
|
-
platforms = ["ios", "non-ios"]
|
96
|
-
platform_name = choose do |menu|
|
97
|
-
menu.prompt = 'Please choose your project platform:'
|
98
|
-
menu.choices(*platforms) do |chosen|
|
99
|
-
chosen
|
100
|
-
end
|
101
|
-
end
|
102
|
-
config_filename = "#{GitPivotalTrackerIntegration::Util::Git.repository_root}/.v2gpti/config"
|
103
|
-
pc_text = File.read(config_filename)
|
104
|
-
File.open(config_filename, "w") {|file| file.puts pc_text.gsub(/platform-name[\s+]?=/, "platform-name = #{platform_name}")}
|
105
|
-
end
|
106
|
-
puts "Your project platform is:#{platform_name}"
|
107
|
-
platform_name
|
108
|
-
end
|
79
|
+
if project_id.empty?
|
80
|
+
project_id = choose do |menu|
|
81
|
+
menu.prompt = 'Choose project associated with this repository: '
|
109
82
|
|
110
|
-
|
111
|
-
#
|
112
|
-
# @param [PivotalTracker::Project] project the project the story belongs to
|
113
|
-
# @return [PivotalTracker::Story] the story associated with the current development branch
|
114
|
-
def story(project)
|
115
|
-
$LOG.debug("#{self.class}:#{__method__}")
|
116
|
-
story_id = GitPivotalTrackerIntegration::Util::Git.get_config KEY_STORY_ID, :branch
|
117
|
-
$LOG.debug("story_id:#{story_id}")
|
118
|
-
project.stories.find story_id.to_i
|
119
|
-
end
|
83
|
+
client = TrackerApi::Client.new(:token => api_token)
|
120
84
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
85
|
+
client.projects.sort_by { |project| project.name }.each do |project|
|
86
|
+
menu.choice(project.name) { project.id }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
Util::Git.set_config KEY_PROJECT_ID, project_id, :local
|
91
|
+
puts
|
92
|
+
end
|
93
|
+
|
94
|
+
project_id
|
95
|
+
end
|
128
96
|
|
129
|
-
|
97
|
+
def platform_name
|
98
|
+
config = self.pconfig
|
99
|
+
platform_name = config["platform"]["platform-name"].downcase
|
100
|
+
|
101
|
+
if platform_name.empty? || !SUPPORTED_PLATFORMS.include?(platform_name)
|
102
|
+
platform_name = choose do |menu|
|
103
|
+
menu.header = 'Project Platforms'
|
104
|
+
menu.prompt = 'Please choose your project platform:'
|
105
|
+
menu.choices(*SUPPORTED_PLATFORMS) do |chosen|
|
106
|
+
chosen
|
107
|
+
end
|
108
|
+
end
|
109
|
+
config["platform"]["platform-name"] = platform_name
|
110
|
+
config_filename = "#{Util::Git.repository_root}/.v2gpti/config"
|
111
|
+
file = File.open(config_filename, 'w')
|
112
|
+
config.write(file)
|
113
|
+
file.close
|
114
|
+
end
|
115
|
+
puts "Your project platform is:#{platform_name}"
|
116
|
+
platform_name
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns the story associated with the current development branch
|
120
|
+
#
|
121
|
+
# @param [PivotalTracker::Project] project the project the story belongs to
|
122
|
+
# @return [PivotalTracker::Story] the story associated with the current development branch
|
123
|
+
def story(project)
|
124
|
+
$LOG.debug("#{self.class}:#{__method__}")
|
125
|
+
story_id = Util::Git.get_config KEY_STORY_ID, :branch
|
126
|
+
$LOG.debug("story_id:#{story_id}")
|
127
|
+
project.story story_id.to_i
|
128
|
+
end
|
129
|
+
|
130
|
+
# Stores the story associated with the current development branch
|
131
|
+
#
|
132
|
+
# @param [PivotalTracker::Story] story the story associated with the current development branch
|
133
|
+
# @return [void]
|
134
|
+
def story=(story)
|
135
|
+
Util::Git.set_config KEY_STORY_ID, story.id, :branch
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
def check_for_config_file
|
141
|
+
rep_path = Util::Git.repository_root
|
142
|
+
FileUtils.mkdir_p(rep_path + '/.v2gpti') unless Dir.exists?( rep_path + '/.v2gpti/')
|
143
|
+
unless File.exists?(rep_path + '/.v2gpti/config')
|
144
|
+
FileUtils.cp(File.expand_path(File.dirname(__FILE__) + '/../../..') + '/config_template', rep_path + '/.v2gpti/config')
|
145
|
+
@new_config = true
|
146
|
+
end
|
147
|
+
end
|
130
148
|
|
131
|
-
|
149
|
+
def check_for_config_contents
|
150
|
+
config_filename = "#{Util::Git.repository_root}/.v2gpti/config"
|
151
|
+
pc = ParseConfig.new(config_filename) if File.file?(config_filename)
|
152
|
+
|
153
|
+
config_content = {}
|
154
|
+
pc.params.each do |key,value|
|
155
|
+
if value.is_a?(Hash)
|
156
|
+
value.each do |child_key, child_value|
|
157
|
+
populate_and_save(child_key,child_value,config_content,key)
|
158
|
+
end
|
159
|
+
else
|
160
|
+
populate_and_save(key,value,config_content)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
pc.params = config_content
|
165
|
+
|
166
|
+
File.open(config_filename, 'w') do |file|
|
167
|
+
pc.write(file, false)
|
168
|
+
end
|
132
169
|
|
133
|
-
|
134
|
-
|
135
|
-
KEY_PLATFORM_NAME = 'platform.platform-name'.freeze
|
170
|
+
puts "For any modification, please update the details in #{config_filename}" if @new_config
|
171
|
+
end
|
136
172
|
|
137
|
-
|
173
|
+
private
|
174
|
+
|
175
|
+
def populate_and_save(key,value,hash, parent=nil)
|
176
|
+
mandatory_details = %w(pivotal-tracker-project-id platform-platform-name)
|
177
|
+
if value.empty?
|
178
|
+
mandatory_field = mandatory_details.include?([parent,key].compact.join('-'))
|
179
|
+
val =
|
180
|
+
if mandatory_field || @new_config
|
181
|
+
if key.include?('project-id')
|
182
|
+
ask("Please provide #{parent.nil? ? '' : parent.capitalize} #{key.capitalize} value: ", lambda{|ip| mandatory_field ? Integer(ip) : ip =~ /^$/ ? '' : Integer(ip) }) do |q|
|
183
|
+
q.responses[:invalid_type] = "Please provide valid project-id#{mandatory_field ? '' : '(or blank line to skip)'}"
|
184
|
+
end
|
185
|
+
elsif key.include?('platform-name')
|
186
|
+
say("Please provide #{parent.nil? ? '' :parent.capitalize} #{key.capitalize} value: \n")
|
187
|
+
choose do |menu|
|
188
|
+
menu.prompt = 'Enter any of the above choices: '
|
189
|
+
menu.choices(*SUPPORTED_PLATFORMS)
|
190
|
+
end
|
191
|
+
else
|
192
|
+
ask("Please provide #{parent.nil? ? '' :parent.capitalize} #{key.capitalize} value: ")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
value = val
|
196
|
+
end
|
138
197
|
|
198
|
+
if parent.nil?
|
199
|
+
hash[key.to_s] = value
|
200
|
+
else
|
201
|
+
if hash.has_key?(parent.to_s) && hash[parent.to_s].has_key?(key.to_s)
|
202
|
+
hash[parent.to_s][key.to_sym] = value.to_s
|
203
|
+
else
|
204
|
+
hash[parent.to_s] = Hash.new if !hash.has_key?(parent.to_s)
|
205
|
+
hash[parent.to_s].store(key.to_s,value.to_s)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
hash
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
139
213
|
end
|