tracker-client 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/command.rb +12 -3
  2. metadata +1 -1
data/lib/command.rb CHANGED
@@ -53,7 +53,8 @@ module Tracker
53
53
  commit_messages_raw = git_cmd('git log --pretty=oneline origin/master..HEAD', directory)
54
54
  commit_messages = commit_messages_raw.each_line.map.inject({}) do |result, line|
55
55
  hash, message = line.split(' ', 2)
56
- result[hash] = message.strip
56
+ full_message = git_cmd("git rev-list --format=%B --max-count=1 #{hash}", directory)
57
+ result[hash] = { :msg => message.strip, :full_message => full_message }
57
58
  result
58
59
  end
59
60
  "[#{patches_in_json}#{JSON::dump(commit_messages)}]"
@@ -122,6 +123,8 @@ module Tracker
122
123
  end
123
124
 
124
125
  def self.upload_patch_body(commit_id, body)
126
+ # Inject TrackedAt header to the commit message
127
+ body.sub!(/^---/m, "TrackedAt: #{config[:url]}/patch/#{commit_id}\n\n---")
125
128
  patch_file = Tempfile.new(commit_id)
126
129
  begin
127
130
  patch_file.write(body)
@@ -229,9 +232,15 @@ module Tracker
229
232
  patches = JSON::parse(patches_to_json(directory))
230
233
  messages = patches.pop
231
234
  patches.each do |p|
235
+ messages[p['hashes']['commit']]['full_message'][/TrackedAt: (.*)./m]
236
+ tracker_commit_url = $1.chop
237
+ if tracker_commit_url.nil?
238
+ puts '[ERR] Patch has not be recorded by tracker (no TrackedAt header)'
239
+ next
240
+ end
232
241
  begin
233
242
  RestClient.post(
234
- config[:url] + ('/patch/%s/%s' % [p['hashes']['commit'], name]),
243
+ tracker_commit_url + '/' + name.to_s,
235
244
  {
236
245
  :message => options[:message]
237
246
  },
@@ -240,7 +249,7 @@ module Tracker
240
249
  'Authorization' => "Basic #{basic_auth}"
241
250
  }
242
251
  )
243
- puts '[%s][%s] %s' % [name.to_s.upcase, p['hashes']['commit'][-8, 8], messages[p['hashes']['commit']]]
252
+ puts '[%s][%s] %s' % [name.to_s.upcase, p['hashes']['commit'][-8, 8], messages[p['hashes']['commit']]['msg']]
244
253
  rescue => e
245
254
  puts '[ERR] %s' % e.message
246
255
  end
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.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: