tracker-client 1.0.7 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/tracker +2 -2
  2. data/lib/command.rb +24 -32
  3. metadata +2 -2
data/bin/tracker CHANGED
@@ -29,6 +29,7 @@ def print_usage
29
29
  puts 'tracker ack - ACK all patches in current branch'
30
30
  puts 'tracker nack - NACK all patches in current branch'
31
31
  puts 'tracker push - Mark all patches in current branch as PUSHED'
32
+ puts 'tracker note - Annotate all patches and keep current state'
32
33
  puts 'tracker status - Display review status for current branch'
33
34
  puts 'tracker upload - Upload current patches (diffs) to tracker'
34
35
  puts 'tracker download - Download whole patchset from tracker (-i PATCHSET_ID, -b CREATE_BRANCH)'
@@ -48,11 +49,10 @@ end
48
49
 
49
50
  puts case ARGV[0]
50
51
  when 'record' then Tracker::Cmd.record(opts[:dir], { :obsolete => opts[:obsolete], :upload => opts[:upload]})
51
-
52
52
  when 'ack' then Tracker::Cmd.ack(opts[:dir], { :message => opts[:message], :set => opts[:id] })
53
53
  when 'nack' then Tracker::Cmd.nack(opts[:dir], { :message => opts[:message], :set => opts[:id] })
54
54
  when 'push' then Tracker::Cmd.push(opts[:dir], { :message => opts[:message], :set => opts[:id] })
55
-
55
+ when 'note' then Tracker::Cmd.note(opts[:dir], { :message => opts[:message], :set => opts[:id] })
56
56
  when 'upload' then Tracker::Cmd.upload(opts[:dir])
57
57
  when 'download' then Tracker::Cmd.download(opts[:dir], ARGV[1], opts[:branch])
58
58
  when 'status' then Tracker::Cmd.status(opts[:dir])
data/lib/command.rb CHANGED
@@ -79,7 +79,7 @@ module Tracker
79
79
  )
80
80
  response = JSON::parse(response)
81
81
  output = "#{number_of_commits} patches were recorded to the tracker server"+
82
- " [#{config[:url]}][##{response['id']}][rev#{response['revision']}]"
82
+ " [\e[1m%s#{config[:url]}set/#{response['id']}\e[0m] [revision #{response['revision']}]"
83
83
  output += "\n" + upload(directory) if opts[:upload]
84
84
  output
85
85
  rescue => e
@@ -89,7 +89,7 @@ module Tracker
89
89
 
90
90
  def self.apply(directory, commit_id)
91
91
  patch_body = download_patch_body(commit_id)
92
- File.open(File.join(directory, "#{commit_id}.patch"), 'w') { |f| f.puts patch_body }
92
+ File.open(File.join(directory, "#{commit_id}.patch"), 'w') { |f| f.write patch_body }
93
93
  print '[%s] Are you sure you want to apply patch to current branch? [Y/n]' % commit_id
94
94
  exit if (STDIN.gets.chomp) == 'n'
95
95
  git_cmd("git am #{commit_id}.patch", directory)
@@ -107,15 +107,14 @@ module Tracker
107
107
  patches[current_patch_commit] += line
108
108
  end
109
109
  end
110
- begin
111
- patches.each do |commit, body|
112
- puts '[^] %s' % commit
110
+ upload_counter = 0
111
+ patches.each do |commit, body|
112
+ begin
113
113
  upload_patch_body(commit, body)
114
- end
115
- '%i patches were uploaded to tracker [%s]' % [patches.size, config[:url]]
116
- rescue => e
117
- e.message
114
+ upload_counter += 1
115
+ rescue;end
118
116
  end
117
+ '%i patches successfully uploaded' % [upload_counter]
119
118
  end
120
119
 
121
120
  def self.upload_patch_body(commit_id, body)
@@ -172,20 +171,14 @@ module Tracker
172
171
  exit
173
172
  end
174
173
  counter = 0
175
- puts
176
174
  puts git_cmd("git checkout -b #{branch}", directory) if !branch.nil?
177
175
  patches.each do |commit|
178
176
  patch_filename = File.join(directory, "#{counter}-#{commit}.patch")
179
177
  File.open(patch_filename, 'w') { |f| f.puts download_patch_body(commit) }
180
- if !branch.nil?
181
- puts git_cmd("git am #{patch_filename}", directory)
182
- else
183
- puts '[v] %s-%s.patch' % [counter, commit]
184
- end
178
+ puts git_cmd("git am #{patch_filename}", directory) if !branch.nil?
185
179
  counter += 1
186
180
  end
187
- puts "\n -> #{counter} patches downloaded."
188
- ''
181
+ "#{counter} patches successfully downloaded"
189
182
  end
190
183
 
191
184
  def self.obsolete_patchset(patchset_id)
@@ -196,7 +189,7 @@ module Tracker
196
189
  'Authorization' => "Basic #{basic_auth}"
197
190
  }
198
191
  )
199
- puts 'This record marked patchset [#%s] as obsoleted.'
192
+ puts 'Set %s obsoleted.' % patchset_id
200
193
  end
201
194
 
202
195
  # Method perform given action on GIT branch with recorded commits.
@@ -207,7 +200,6 @@ module Tracker
207
200
  # * +directory+ - If given, cmd app will 'chdir' into that directory (default: nil)
208
201
  #
209
202
  def self.action(name, directory, options={})
210
- puts
211
203
  if options[:set]
212
204
  begin
213
205
  RestClient.post(
@@ -220,19 +212,20 @@ module Tracker
220
212
  'Authorization' => "Basic #{basic_auth}"
221
213
  }
222
214
  )
223
- puts '[%s][%s] Status of all patches in set updated.' % [name, options[:set]]
215
+ 'All patches in set %s marked as %s' % [options[:set], name.to_s.upcase]
224
216
  rescue => e
225
- puts '[ERR] %s' % e.message
217
+ '[ERR] %s' % e.message
226
218
  end
227
219
  else
228
220
  patches = JSON::parse(patches_to_json(directory))
229
221
  messages = patches.pop
222
+ patches_counter = 0
230
223
  patches.each do |p|
231
- messages[p['hashes']['commit']]['full_message'][/TrackedAt: (.*)./m]
232
- tracker_commit_url = $1.chop
233
- if tracker_commit_url.nil?
234
- puts '[ERR] Patch has not be recorded by tracker (no TrackedAt header)'
235
- next
224
+ if messages[p['hashes']['commit']]['full_message'][/TrackedAt: (.*)./m]
225
+ tracker_commit_url = $1.chop
226
+ else
227
+ tracker_commit_url = config[:url] + '/patch/' + p['hashes']['commit']
228
+ warn "[warn] Patches not applied by tracker. Using current commit hash."
236
229
  end
237
230
  begin
238
231
  RestClient.post(
@@ -245,18 +238,20 @@ module Tracker
245
238
  'Authorization' => "Basic #{basic_auth}"
246
239
  }
247
240
  )
248
- puts '[%s][%s] %s' % [name.to_s.upcase, p['hashes']['commit'][-8, 8], messages[p['hashes']['commit']]['msg']]
241
+ puts "\e[1m%s\e[0m send for \e[1m%s\e[0m" % [name.to_s.upcase, tracker_commit_url]
242
+ patches_counter += 1
249
243
  rescue => e
250
244
  puts '[ERR] %s' % e.message
251
245
  end
252
246
  end
247
+ '%i patches status updated.' % patches_counter
253
248
  end
254
- " |\n |--------> [%s]\n\n" % config[:url]
255
249
  end
256
250
 
257
251
  def self.ack(directory, opts={}); action(:ack, directory, opts); end
258
252
  def self.nack(directory, opts={}); action(:nack, directory, opts); end
259
253
  def self.push(directory, opts={}); action(:push, directory, opts); end
254
+ def self.note(directory, opts={}); action(:note, directory, opts); end
260
255
 
261
256
  def self.status(directory)
262
257
  patches = JSON::parse(patches_to_json(directory))
@@ -274,10 +269,8 @@ module Tracker
274
269
  }
275
270
  )
276
271
  response = JSON::parse(response)
277
- puts '[%s][%s][rev%s] %s' % [
278
- response['commit'][-8, 8],
272
+ puts "[%s] \e[1m%s\e[0m" % [
279
273
  response['status'].upcase,
280
- response['revision'],
281
274
  response['message']
282
275
  ]
283
276
  counter+=1
@@ -289,7 +282,6 @@ module Tracker
289
282
  if counter == 0
290
283
  "ERR: This branch is not recorded yet. ($ tracker record)\n\n"
291
284
  else
292
- " |\n |--------> [%s]\n\n" % config[:url]
293
285
  end
294
286
  end
295
287
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-24 00:00:00.000000000 Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client