From 8076c2854d339c96a1b008e72aa3b832e61e0f45 Mon Sep 17 00:00:00 2001 From: Aaron Gable Date: Wed, 29 Nov 2017 14:39:41 -0800 Subject: [PATCH] Give git-cl-presubmit an --all option This will let developers run PRESUBMIT against all files in the repo, rather than just those their CL touches. This will be particularly helpful when modifying PRESUBMIT.py itself. R=maruel@chromium.org Bug: 519046 Change-Id: I5775eef8aecefe0cd358537c9218afc7480a7619 Reviewed-on: https://chromium-review.googlesource.com/798056 Commit-Queue: Aaron Gable Reviewed-by: Marc-Antoine Ruel Reviewed-by: Andrii Shyshkalov --- git_cl.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/git_cl.py b/git_cl.py index a137bfcc78..014dbdafa4 100755 --- a/git_cl.py +++ b/git_cl.py @@ -4781,6 +4781,8 @@ def CMDpresubmit(parser, args): help='Run upload hook instead of the push hook') parser.add_option('-f', '--force', action='store_true', help='Run checks even if tree is dirty') + parser.add_option('--all', action='store_true', + help='Run checks against all files, not just modified ones') auth.add_auth_options(parser) options, args = parser.parse_args(args) auth_config = auth.extract_auth_config_from_options(options) @@ -4796,11 +4798,26 @@ def CMDpresubmit(parser, args): # Default to diffing against the common ancestor of the upstream branch. base_branch = cl.GetCommonAncestorWithUpstream() + if options.all: + base_change = cl.GetChange(base_branch, None) + files = [('M', f) for f in base_change.AllFiles()] + change = presubmit_support.GitChange( + base_change.Name(), + base_change.FullDescriptionText(), + base_change.RepositoryRoot(), + files, + base_change.issue, + base_change.patchset, + base_change.author_email, + base_change._upstream) + else: + change = cl.GetChange(base_branch, None) + cl.RunHook( committing=not options.upload, may_prompt=False, verbose=options.verbose, - change=cl.GetChange(base_branch, None)) + change=change) return 0