| Index: git_cl_hooks.py
|
| diff --git a/git_cl_hooks.py b/git_cl_hooks.py
|
| index e880a0b30d679775b05538d8dfeeb0bfe74896d6..e881085d0911293403cf01abe5bea42ef77e575d 100644
|
| --- a/git_cl_hooks.py
|
| +++ b/git_cl_hooks.py
|
| @@ -32,12 +32,14 @@ def ConvertToInteger(inputval):
|
| return None
|
|
|
|
|
| -class ChangeOptions:
|
| - def __init__(self, commit=None, upstream_branch=None):
|
| +class ChangeOptions(object):
|
| + def __init__(self, commit, upstream_branch, cmd_line_options):
|
| self.commit = commit
|
| self.verbose = None
|
| self.default_presubmit = None
|
| self.may_prompt = None
|
| + self.host_url = cmd_line_options.host_url
|
| + self.tbr = cmd_line_options.tbr
|
|
|
| root = Backquote(['git', 'rev-parse', '--show-cdup'])
|
| if not root:
|
| @@ -62,12 +64,20 @@ class ChangeOptions:
|
| self.change = presubmit_support.GitChange(name, description, absroot, files,
|
| issue, patchset)
|
|
|
| +# TODO(dpranke): remove when we make cmd_line_options mandatory in RunHooks().
|
| +class DefaultOptions(object):
|
| + tbr = False
|
| + host_url = None
|
| +
|
| +
|
| +def RunHooks(hook_name, upstream_branch, cmd_line_options=None):
|
| + # TODO(dpranke): make cmd_line_options mandatory
|
| + cmd_line_options = cmd_line_options or DefaultOptions()
|
|
|
| -def RunHooks(hook_name, upstream_branch):
|
| commit = (hook_name == 'pre-cl-dcommit')
|
|
|
| # Create our options based on the command-line args and the current checkout.
|
| - options = ChangeOptions(commit=commit, upstream_branch=upstream_branch)
|
| + options = ChangeOptions(commit, upstream_branch, cmd_line_options)
|
|
|
| # Apply watchlists on upload.
|
| if not commit:
|
| @@ -78,13 +88,16 @@ def RunHooks(hook_name, upstream_branch):
|
| 'rietveld.extracc', ','.join(watchers)])
|
|
|
| # Run the presubmit checks.
|
| + # TODO(dpranke): just pass the whole options object?
|
| if presubmit_support.DoPresubmitChecks(options.change,
|
| options.commit,
|
| options.verbose,
|
| sys.stdout,
|
| sys.stdin,
|
| options.default_presubmit,
|
| - options.may_prompt):
|
| + options.may_prompt,
|
| + options.tbr,
|
| + options.host_url):
|
| sys.exit(0)
|
| else:
|
| sys.exit(1)
|
|
|