From b466854bed4348a210fec5870023c1a44cd830b5 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 21 Oct 2019 22:53:46 -0400 Subject: forall: add an --ignore-missing option In CrOS, our infra has to deal with partial checkouts constantly (for a variety of reasons). To help reset back to a good state, we run git commands via `repo forall`, but don't care about the missing checkouts. Add a flag so we can disambiguate between missing repos and failing git subcommands. Bug: https://crbug.com/1013377 Bug: https://crbug.com/1013623 Change-Id: Ie3498c6d111276c60d2ecedbba21bfa778588d50 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/241935 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- subcmds/forall.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'subcmds/forall.py') diff --git a/subcmds/forall.py b/subcmds/forall.py index c9de26bc..96eac541 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -139,6 +139,9 @@ without iterating through the remaining projects. p.add_option('-e', '--abort-on-errors', dest='abort_on_errors', action='store_true', help='Abort if a command exits unsuccessfully') + p.add_option('--ignore-missing', action='store_true', + help='Silently skip & do not exit non-zero due missing ' + 'checkouts') g = p.add_option_group('Output') g.add_option('-p', @@ -323,6 +326,10 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): cwd = project['worktree'] if not os.path.exists(cwd): + # Allow the user to silently ignore missing checkouts so they can run on + # partial checkouts (good for infra recovery tools). + if opt.ignore_missing: + return 0 if ((opt.project_header and opt.verbose) or not opt.project_header): print('skipping %s/' % project['relpath'], file=sys.stderr) -- cgit v1.2.3-54-g00ecf