Commit b0a6391f authored by maruel@chromium.org's avatar maruel@chromium.org

Fix --force implementation to not prompt but still run hooks

I found out that some devs thought that -f just skipped the prompt, but it did
in fact also skip the presubmit checks.
Make -f do what it should, no prompt and just return if the presubmit check
failed.

R=cmp@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/9240009

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@117918 0039d316-1c4b-4281-b951-d872f2087c98
parent 2e72bb1c
...@@ -550,7 +550,7 @@ or verify this branch is set up to track another (via the --track argument to ...@@ -550,7 +550,7 @@ or verify this branch is set up to track another (via the --track argument to
self.SetWatchers(watchlist.GetWatchersForPaths(files)) self.SetWatchers(watchlist.GetWatchersForPaths(files))
try: try:
output = presubmit_support.DoPresubmitChecks(change, committing, return presubmit_support.DoPresubmitChecks(change, committing,
verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin, verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin,
default_presubmit=None, may_prompt=may_prompt, default_presubmit=None, may_prompt=may_prompt,
rietveld_obj=self.RpcServer()) rietveld_obj=self.RpcServer())
...@@ -559,13 +559,6 @@ or verify this branch is set up to track another (via the --track argument to ...@@ -559,13 +559,6 @@ or verify this branch is set up to track another (via the --track argument to
('%s\nMaybe your depot_tools is out of date?\n' ('%s\nMaybe your depot_tools is out of date?\n'
'If all fails, contact maruel@') % e) 'If all fails, contact maruel@') % e)
# TODO(dpranke): We should propagate the error out instead of calling
# exit().
if not output.should_continue():
sys.exit(1)
return output
def CloseIssue(self): def CloseIssue(self):
"""Updates the description and closes the issue.""" """Updates the description and closes the issue."""
issue = int(self.GetIssue()) issue = int(self.GetIssue())
...@@ -909,15 +902,16 @@ def CMDupload(parser, args): ...@@ -909,15 +902,16 @@ def CMDupload(parser, args):
base_branch = cl.GetUpstreamBranch() base_branch = cl.GetUpstreamBranch()
args = [base_branch + "..."] args = [base_branch + "..."]
if not options.bypass_hooks and not options.force: if not options.bypass_hooks:
hook_results = cl.RunHook(committing=False, upstream_branch=base_branch, hook_results = cl.RunHook(committing=False, upstream_branch=base_branch,
may_prompt=True, may_prompt=not options.force,
verbose=options.verbose, verbose=options.verbose,
author=None) author=None)
if not hook_results.should_continue():
return 1
if not options.reviewers and hook_results.reviewers: if not options.reviewers and hook_results.reviewers:
options.reviewers = hook_results.reviewers options.reviewers = hook_results.reviewers
# --no-ext-diff is broken in some versions of Git, so try to work around # --no-ext-diff is broken in some versions of Git, so try to work around
# this by overriding the environment (but there is still a problem if the # this by overriding the environment (but there is still a problem if the
# git config key "diff.external" is used). # git config key "diff.external" is used).
...@@ -1068,24 +1062,29 @@ def SendUpstream(parser, args, cmd): ...@@ -1068,24 +1062,29 @@ def SendUpstream(parser, args, cmd):
'before attempting to %s.' % (base_branch, cmd)) 'before attempting to %s.' % (base_branch, cmd))
return 1 return 1
if not options.bypass_hooks and not options.force: if not options.bypass_hooks:
author = None author = None
if options.contributor: if options.contributor:
author = re.search(r'\<(.*)\>', options.contributor).group(1) author = re.search(r'\<(.*)\>', options.contributor).group(1)
cl.RunHook(committing=True, upstream_branch=base_branch, hook_results = cl.RunHook(
may_prompt=True, verbose=options.verbose, committing=True,
author=author) upstream_branch=base_branch,
may_prompt=not options.force,
verbose=options.verbose,
author=author)
if not hook_results.should_continue():
return 1
if cmd == 'dcommit': if cmd == 'dcommit':
# Check the tree status if the tree status URL is set. # Check the tree status if the tree status URL is set.
status = GetTreeStatus() status = GetTreeStatus()
if 'closed' == status: if 'closed' == status:
print ('The tree is closed. Please wait for it to reopen. Use ' print('The tree is closed. Please wait for it to reopen. Use '
'"git cl dcommit -f" to commit on a closed tree.') '"git cl dcommit --bypass-hooks" to commit on a closed tree.')
return 1 return 1
elif 'unknown' == status: elif 'unknown' == status:
print ('Unable to determine tree status. Please verify manually and ' print('Unable to determine tree status. Please verify manually and '
'use "git cl dcommit -f" to commit on a closed tree.') 'use "git cl dcommit --bypass-hooks" to commit on a closed tree.')
else: else:
breakpad.SendStack( breakpad.SendStack(
'GitClHooksBypassedCommit', 'GitClHooksBypassedCommit',
......
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