mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Add option to abort on error in forall
Add a new option (-e, --abort-on-errors) which will cause forall to abort without iterating through remaining projects if a command exits unsuccessfully. Bug: Issue 17 Change-Id: Ibea405e0d98b575ad3bda719d511f6982511c19c Signed-off-by: Victor Boivie <victor.boivie@sonyericsson.com>
This commit is contained in:
parent
e66291f6d0
commit
88b86728a4
@ -93,6 +93,9 @@ following <command>.
|
||||
|
||||
Unless -p is used, stdin, stdout, stderr are inherited from the
|
||||
terminal and are not redirected.
|
||||
|
||||
If -e is used, when a command exits unsuccessfully, '%prog' will abort
|
||||
without iterating through the remaining projects.
|
||||
"""
|
||||
|
||||
def _Options(self, p):
|
||||
@ -105,6 +108,9 @@ terminal and are not redirected.
|
||||
dest='command',
|
||||
action='callback',
|
||||
callback=cmd)
|
||||
p.add_option('-e', '--abort-on-errors',
|
||||
dest='abort_on_errors', action='store_true',
|
||||
help='Abort if a command exits unsuccessfully')
|
||||
|
||||
g = p.add_option_group('Output')
|
||||
g.add_option('-p',
|
||||
@ -255,7 +261,12 @@ terminal and are not redirected.
|
||||
s.dest.flush()
|
||||
|
||||
r = p.wait()
|
||||
if r != 0 and r != rc:
|
||||
if r != 0:
|
||||
if r != rc:
|
||||
rc = r
|
||||
if opt.abort_on_errors:
|
||||
print("error: %s: Aborting due to previous error" % project.relpath,
|
||||
file=sys.stderr)
|
||||
sys.exit(r)
|
||||
if rc != 0:
|
||||
sys.exit(rc)
|
||||
|
Loading…
Reference in New Issue
Block a user