tracker-client 1.0 → 1.0.1
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 +7 -4
- data/lib/command.rb +32 -10
- metadata +2 -2
data/bin/tracker
CHANGED
@@ -16,6 +16,7 @@ opts = Trollop::options do
|
|
16
16
|
opt :message, "Add short message to actions", :short => 'm', :type => :string
|
17
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
|
+
opt :branch, 'Create specified branch when downloading patches', :short => 'b', :type => :string
|
19
20
|
end
|
20
21
|
|
21
22
|
Tracker::Cmd.config(:set, :file => opts[:config])
|
@@ -42,11 +43,13 @@ end
|
|
42
43
|
|
43
44
|
puts case ARGV[0]
|
44
45
|
when 'record' then Tracker::Cmd.record(opts[:dir], { :obsolete => opts[:obsolete], :upload => opts[:upload]})
|
45
|
-
|
46
|
-
when '
|
47
|
-
when '
|
46
|
+
|
47
|
+
when 'ack' then Tracker::Cmd.ack(opts[:dir], { :message => opts[:message], :set => opts[:id] })
|
48
|
+
when 'nack' then Tracker::Cmd.nack(opts[:dir], { :message => opts[:message], :set => opts[:id] })
|
49
|
+
when 'push' then Tracker::Cmd.push(opts[:dir], { :message => opts[:message], :set => opts[:id] })
|
50
|
+
|
48
51
|
when 'upload' then Tracker::Cmd.upload(opts[:dir])
|
49
|
-
when 'download' then Tracker::Cmd.download(opts[:dir], opts[:
|
52
|
+
when 'download' then Tracker::Cmd.download(opts[:dir], ARGV[1], opts[:branch])
|
50
53
|
when 'status' then Tracker::Cmd.status(opts[:dir])
|
51
54
|
when 'apply' then Tracker::Cmd.apply(opts[:dir], ARGV[1])
|
52
55
|
else print_usage
|
data/lib/command.rb
CHANGED
@@ -157,7 +157,7 @@ module Tracker
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
def self.download(directory, patchset_id)
|
160
|
+
def self.download(directory, patchset_id, branch=nil)
|
161
161
|
patches = []
|
162
162
|
begin
|
163
163
|
response = RestClient.get(
|
@@ -174,11 +174,15 @@ module Tracker
|
|
174
174
|
end
|
175
175
|
counter = 0
|
176
176
|
puts
|
177
|
+
puts git_cmd("git checkout -b #{branch}", directory) if !branch.nil?
|
177
178
|
patches.each do |commit|
|
178
|
-
File.
|
179
|
-
|
180
|
-
|
181
|
-
|
179
|
+
patch_filename = File.join(directory, "#{counter}-#{commit}.patch")
|
180
|
+
File.open(patch_filename, 'w') { |f| f.puts download_patch_body(commit) }
|
181
|
+
if !branch.nil?
|
182
|
+
puts git_cmd("git am #{patch_filename}", directory)
|
183
|
+
else
|
184
|
+
puts '[v] %s-%s.patch' % [counter, commit]
|
185
|
+
end
|
182
186
|
counter += 1
|
183
187
|
end
|
184
188
|
puts "\n -> #{counter} patches downloaded."
|
@@ -204,13 +208,11 @@ module Tracker
|
|
204
208
|
# * +directory+ - If given, cmd app will 'chdir' into that directory (default: nil)
|
205
209
|
#
|
206
210
|
def self.action(name, directory, options={})
|
207
|
-
patches = JSON::parse(patches_to_json(directory))
|
208
|
-
messages = patches.pop
|
209
211
|
puts
|
210
|
-
|
212
|
+
if options[:set]
|
211
213
|
begin
|
212
214
|
RestClient.post(
|
213
|
-
config[:url] + ('/
|
215
|
+
config[:url] + ('/set/%s/%s' % [options[:set], name]),
|
214
216
|
{
|
215
217
|
:message => options[:message]
|
216
218
|
},
|
@@ -219,10 +221,30 @@ module Tracker
|
|
219
221
|
'Authorization' => "Basic #{basic_auth}"
|
220
222
|
}
|
221
223
|
)
|
222
|
-
puts '[%s][%s]
|
224
|
+
puts '[%s][%s] Status of all patches in set updated.' % [name, options[:set]]
|
223
225
|
rescue => e
|
224
226
|
puts '[ERR] %s' % e.message
|
225
227
|
end
|
228
|
+
else
|
229
|
+
patches = JSON::parse(patches_to_json(directory))
|
230
|
+
messages = patches.pop
|
231
|
+
patches.each do |p|
|
232
|
+
begin
|
233
|
+
RestClient.post(
|
234
|
+
config[:url] + ('/patch/%s/%s' % [p['hashes']['commit'], name]),
|
235
|
+
{
|
236
|
+
:message => options[:message]
|
237
|
+
},
|
238
|
+
{
|
239
|
+
:content_type => 'application/json',
|
240
|
+
'Authorization' => "Basic #{basic_auth}"
|
241
|
+
}
|
242
|
+
)
|
243
|
+
puts '[%s][%s] %s' % [name.to_s.upcase, p['hashes']['commit'][-8, 8], messages[p['hashes']['commit']]]
|
244
|
+
rescue => e
|
245
|
+
puts '[ERR] %s' % e.message
|
246
|
+
end
|
247
|
+
end
|
226
248
|
end
|
227
249
|
" |\n |--------> [%s]\n\n" % config[:url]
|
228
250
|
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:
|
4
|
+
version: 1.0.1
|
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-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|