OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 import re | 6 import re |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 | 9 |
10 import presubmit_support | 10 import presubmit_support |
(...skipping 17 matching lines...) Expand all Loading... |
28 if not root: | 28 if not root: |
29 raise Exception("Could not get root directory.") | 29 raise Exception("Could not get root directory.") |
30 log = Backquote(['git', 'show', '--name-only', | 30 log = Backquote(['git', 'show', '--name-only', |
31 '--pretty=format:%H%n%s%n%n%b']) | 31 '--pretty=format:%H%n%s%n%n%b']) |
32 m = re.match(r'^(\w+)\n(.*)$', log, re.MULTILINE|re.DOTALL) | 32 m = re.match(r'^(\w+)\n(.*)$', log, re.MULTILINE|re.DOTALL) |
33 if not m: | 33 if not m: |
34 raise Exception("Could not parse log message: %s" % log) | 34 raise Exception("Could not parse log message: %s" % log) |
35 name = m.group(1) | 35 name = m.group(1) |
36 description = m.group(2) | 36 description = m.group(2) |
37 files = scm.GIT.CaptureStatus([root], upstream_branch) | 37 files = scm.GIT.CaptureStatus([root], upstream_branch) |
38 issue = Backquote(['cl', 'status', '--field=id']) | 38 issue = Backquote(['git', 'cl', 'status', '--field=id']) |
39 patchset = None | 39 patchset = None |
40 self.change = presubmit_support.GitChange(name, description, root, files, | 40 self.change = presubmit_support.GitChange(name, description, root, files, |
41 issue, patchset) | 41 issue, patchset) |
42 | 42 |
43 | 43 |
44 def RunHooks(hook_name, upstream_branch): | 44 def RunHooks(hook_name, upstream_branch): |
45 commit = (hook_name == 'pre-cl-dcommit') | 45 commit = (hook_name == 'pre-cl-dcommit') |
46 | 46 |
47 # Create our options based on the command-line args and the current checkout. | 47 # Create our options based on the command-line args and the current checkout. |
48 options = ChangeOptions(commit=commit, upstream_branch=upstream_branch) | 48 options = ChangeOptions(commit=commit, upstream_branch=upstream_branch) |
49 | 49 |
50 # Run the presubmit checks. | 50 # Run the presubmit checks. |
51 if presubmit_support.DoPresubmitChecks(options.change, | 51 if presubmit_support.DoPresubmitChecks(options.change, |
52 options.commit, | 52 options.commit, |
53 options.verbose, | 53 options.verbose, |
54 sys.stdout, | 54 sys.stdout, |
55 sys.stdin, | 55 sys.stdin, |
56 options.default_presubmit, | 56 options.default_presubmit, |
57 options.may_prompt): | 57 options.may_prompt): |
58 sys.exit(0) | 58 sys.exit(0) |
59 else: | 59 else: |
60 sys.exit(1) | 60 sys.exit(1) |
OLD | NEW |