Commit 8076c285 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

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 <agable@chromium.org>
Reviewed-by: 's avatarMarc-Antoine Ruel <maruel@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent bd95f41a
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment