summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-10-21 22:53:46 -0400
committerMike Frysinger <vapier@google.com>2019-10-22 14:10:34 +0000
commitb466854bed4348a210fec5870023c1a44cd830b5 (patch)
treeaf4a11722ff66e5b08eebcc8c187f5fbdfb9d3b5 /subcmds
parentd1e93dd58a6bc74b9a6f872bb3a7a0123e8a9933 (diff)
downloadgit-repo-b466854bed4348a210fec5870023c1a44cd830b5.tar.gz
forall: add an --ignore-missing optionv1.13.7.1
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 <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/forall.py7
1 files changed, 7 insertions, 0 deletions
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.
139 p.add_option('-e', '--abort-on-errors', 139 p.add_option('-e', '--abort-on-errors',
140 dest='abort_on_errors', action='store_true', 140 dest='abort_on_errors', action='store_true',
141 help='Abort if a command exits unsuccessfully') 141 help='Abort if a command exits unsuccessfully')
142 p.add_option('--ignore-missing', action='store_true',
143 help='Silently skip & do not exit non-zero due missing '
144 'checkouts')
142 145
143 g = p.add_option_group('Output') 146 g = p.add_option_group('Output')
144 g.add_option('-p', 147 g.add_option('-p',
@@ -323,6 +326,10 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config):
323 cwd = project['worktree'] 326 cwd = project['worktree']
324 327
325 if not os.path.exists(cwd): 328 if not os.path.exists(cwd):
329 # Allow the user to silently ignore missing checkouts so they can run on
330 # partial checkouts (good for infra recovery tools).
331 if opt.ignore_missing:
332 return 0
326 if ((opt.project_header and opt.verbose) 333 if ((opt.project_header and opt.verbose)
327 or not opt.project_header): 334 or not opt.project_header):
328 print('skipping %s/' % project['relpath'], file=sys.stderr) 335 print('skipping %s/' % project['relpath'], file=sys.stderr)