tracker-client 0.9 → 1.0
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.
- data/bin/tracker +1 -1
- data/lib/command.rb +21 -9
- metadata +2 -2
data/bin/tracker
CHANGED
@@ -14,7 +14,7 @@ opts = Trollop::options do
|
|
14
14
|
opt :config, "Tracker config file location", :short => 'c', :default => "#{File.join(ENV['HOME'], '.trackerrc')}"
|
15
15
|
opt :obsolete, "Used when recording new revision of patchset", :short => 'o', :type => :int
|
16
16
|
opt :message, "Add short message to actions", :short => 'm', :type => :string
|
17
|
-
opt :id, "Patchset ID used by download action", :short => 'i', :type => :
|
17
|
+
opt :id, "Patchset ID used by download action", :short => 'i', :type => :string
|
18
18
|
opt :upload, 'Upload current branch patches after record', :short => 'u', :type => :flag
|
19
19
|
end
|
20
20
|
|
data/lib/command.rb
CHANGED
@@ -4,6 +4,7 @@ module Tracker
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'json'
|
6
6
|
require 'base64'
|
7
|
+
require 'tempfile'
|
7
8
|
|
8
9
|
GIT_JSON_FORMAT = '{ "hashes":'+
|
9
10
|
'{ "commit":"%H", "tree":"%T",'+' "parents":"%P" },'+
|
@@ -121,14 +122,25 @@ module Tracker
|
|
121
122
|
end
|
122
123
|
|
123
124
|
def self.upload_patch_body(commit_id, body)
|
124
|
-
|
125
|
-
|
126
|
-
body
|
127
|
-
|
128
|
-
|
129
|
-
'
|
130
|
-
|
131
|
-
|
125
|
+
patch_file = Tempfile.new(commit_id)
|
126
|
+
begin
|
127
|
+
patch_file.write(body)
|
128
|
+
patch_file.rewind
|
129
|
+
RestClient.post(
|
130
|
+
config[:url] + ('/patch/%s/body' % commit_id),
|
131
|
+
{
|
132
|
+
:diff => patch_file
|
133
|
+
},
|
134
|
+
{
|
135
|
+
'Authorization' => "Basic #{basic_auth}"
|
136
|
+
}
|
137
|
+
)
|
138
|
+
rescue => e
|
139
|
+
puts "[ERR] Upload of #{commit_id} failed. (#{e.message})"
|
140
|
+
ensure
|
141
|
+
patch_file.close
|
142
|
+
patch_file.unlink
|
143
|
+
end
|
132
144
|
end
|
133
145
|
|
134
146
|
def self.download_patch_body(commit_id)
|
@@ -155,7 +167,7 @@ module Tracker
|
|
155
167
|
'Authorization' => "Basic #{basic_auth}"
|
156
168
|
}
|
157
169
|
)
|
158
|
-
patches = JSON::parse(response)['patches']
|
170
|
+
patches = JSON::parse(response)['patches']
|
159
171
|
rescue => e
|
160
172
|
puts "ERR: #{e.message}"
|
161
173
|
exit
|
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: '0
|
4
|
+
version: '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-
|
12
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|