mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +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
|
Unless -p is used, stdin, stdout, stderr are inherited from the
|
||||||
terminal and are not redirected.
|
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):
|
def _Options(self, p):
|
||||||
@ -105,6 +108,9 @@ terminal and are not redirected.
|
|||||||
dest='command',
|
dest='command',
|
||||||
action='callback',
|
action='callback',
|
||||||
callback=cmd)
|
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 = p.add_option_group('Output')
|
||||||
g.add_option('-p',
|
g.add_option('-p',
|
||||||
@ -255,7 +261,12 @@ terminal and are not redirected.
|
|||||||
s.dest.flush()
|
s.dest.flush()
|
||||||
|
|
||||||
r = p.wait()
|
r = p.wait()
|
||||||
if r != 0 and r != rc:
|
if r != 0:
|
||||||
rc = r
|
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:
|
if rc != 0:
|
||||||
sys.exit(rc)
|
sys.exit(rc)
|
||||||
|
Loading…
Reference in New Issue
Block a user