summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>2020-02-10 13:39:24 +0000
committerJonathan Druart <jonathan.druart@gmail.com>2021-05-12 14:50:34 +0200
commitb28b39af59b04627aeb8cdb82c36595acaab8907 (patch)
tree160b567ef760a873301a48f58e45e4279749cd35
parent64ac10ad800715d5551f0d56bbfe936ffc037e22 (diff)
downloadgit-bz-b28b39af59b04627aeb8cdb82c36595acaab8907.tar.gz
Issue #4 - Exit with error on apply error, but catch in cascade apply.
If a patch fails to apply we should exit with a proper exit status so that ansible can catch the issue in non-interactive operation for the sandboxes. Test plan You can use echo $? after executing any command in the shell to see the last commands exit code.. 0 for success, 1 for failure. To test this patch try doing a git bz apply using a bug you know will fail to apply, Call the echo statement above and note the exit code is 0.. after applying the patch do the same bz apply and echo and not the exit code now properly reflects the failure state with an exit code of 1. Bonus points is to test that the cascade apply still works as expected for both cases of a fully successful apply and for one where one of the dependancies fails to apply. More bonus points, check that passing multiple bug ids also still works
-rwxr-xr-xgit-bz10
1 files changed, 5 insertions, 5 deletions
diff --git a/git-bz b/git-bz
index 9f77f4a..2a1fbb3 100755
--- a/git-bz
+++ b/git-bz
@@ -1766,10 +1766,11 @@ def do_apply(*args):
if opt == "n":
continue
else:
- applied = do_apply(d_id, { 'do_not_add_url': 1} )
- if applied is None:
+ try:
+ applied = do_apply(d_id, { 'do_not_add_url': 1} )
+ bugs_applied.extend(applied)
+ except BaseException:
die("\nCannot apply cleanly patches from bug %s. Everything will be left dirty.\ngit bz apply --continue will not continue the process if patches from other bug reports need to be applied." % d_id)
- bugs_applied.extend(applied)
orig_head = git.rev_parse("HEAD")
@@ -1862,8 +1863,7 @@ FIXME: need commit message.
for i in range(patches.index(patch) + 1, len(patches)):
f.write("%s\n" % patches[i].attach_id)
f.close()
- print "Patch left in %s" % filename
- return None # Better would be to raise an exception
+ die("Patch left in %s" % filename);
os.remove(filename)