git-review 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/git-review.rb +19 -2
- metadata +3 -3
data/lib/git-review.rb
CHANGED
@@ -5,6 +5,11 @@ require 'launchy'
|
|
5
5
|
# Time is used to parse time strings from git back into Time objects.
|
6
6
|
require 'time'
|
7
7
|
|
8
|
+
# A custom error to raise, if we know we can't go on.
|
9
|
+
class UnprocessableState < StandardError
|
10
|
+
end
|
11
|
+
|
12
|
+
|
8
13
|
class GitReview
|
9
14
|
|
10
15
|
## COMMANDS ##
|
@@ -146,7 +151,7 @@ class GitReview
|
|
146
151
|
end
|
147
152
|
unless git_call("cherry #{target_branch}").empty?
|
148
153
|
# Push latest commits to the remote branch (and by that, create it if necessary).
|
149
|
-
git_call "push --set-upstream origin #{@local_branch}"
|
154
|
+
git_call "push --set-upstream origin #{@local_branch}", debug_mode, true
|
150
155
|
# Gather information.
|
151
156
|
last_request_id = @pending_requests.collect{|req| req['number'] }.sort.last.to_i
|
152
157
|
title = "[Review] Request from '#{git_config['github.login']}' @ '#{source}'"
|
@@ -195,6 +200,8 @@ class GitReview
|
|
195
200
|
end
|
196
201
|
help
|
197
202
|
end
|
203
|
+
rescue UnprocessableState
|
204
|
+
puts 'Execution of git-review command stopped.'
|
198
205
|
end
|
199
206
|
|
200
207
|
# Show a quick reference of available commands.
|
@@ -246,7 +253,7 @@ class GitReview
|
|
246
253
|
end
|
247
254
|
|
248
255
|
# System call to 'git'.
|
249
|
-
def git_call(command, verbose = debug_mode)
|
256
|
+
def git_call(command, verbose = debug_mode, enforce_success = false)
|
250
257
|
if verbose
|
251
258
|
puts
|
252
259
|
puts " git #{command}"
|
@@ -254,6 +261,11 @@ class GitReview
|
|
254
261
|
end
|
255
262
|
output = `git #{command}`
|
256
263
|
puts output if verbose and not output.empty?
|
264
|
+
# If we need sth. to succeed, but it doesn't stop right there.
|
265
|
+
if enforce_success and not last_command_successful?
|
266
|
+
puts output unless output.empty?
|
267
|
+
raise UnprocessableState
|
268
|
+
end
|
257
269
|
output
|
258
270
|
end
|
259
271
|
|
@@ -408,4 +420,9 @@ class GitReview
|
|
408
420
|
matches ? [matches[1], matches[2].sub(/\.git\z/, '')] : [nil, nil]
|
409
421
|
end
|
410
422
|
|
423
|
+
# Returns a boolean stating whether the last issued system call was successful.
|
424
|
+
def last_command_successful?
|
425
|
+
$?.exitstatus == 0
|
426
|
+
end
|
427
|
+
|
411
428
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-review
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 8
|
10
|
+
version: 0.8.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dominik Bamberger, Cristian Messel
|