Chromium Code Reviews| Index: git_cl_hooks.py |
| diff --git a/git_cl_hooks.py b/git_cl_hooks.py |
| index e880a0b30d679775b05538d8dfeeb0bfe74896d6..99a18ee45dc6ac185d83b2380cc7bdd705b83455 100644 |
| --- a/git_cl_hooks.py |
| +++ b/git_cl_hooks.py |
| @@ -33,11 +33,13 @@ def ConvertToInteger(inputval): |
| class ChangeOptions: |
|
M-A Ruel
2011/03/11 00:48:41
While at it make it a new style class:
class Chang
|
| - def __init__(self, commit=None, upstream_branch=None): |
| + 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) |