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 breakpad | 10 import breakpad |
11 | 11 |
| 12 import gcl |
12 import presubmit_support | 13 import presubmit_support |
13 import scm | 14 import scm |
14 import watchlists | 15 import watchlists |
15 | 16 |
16 def Backquote(cmd, cwd=None): | 17 def Backquote(cmd, cwd=None): |
17 """Like running `cmd` in a shell script.""" | 18 """Like running `cmd` in a shell script.""" |
18 return subprocess.Popen(cmd, | 19 return subprocess.Popen(cmd, |
19 cwd=cwd, | 20 cwd=cwd, |
20 stdout=subprocess.PIPE).communicate()[0].strip() | 21 stdout=subprocess.PIPE).communicate()[0].strip() |
21 | 22 |
(...skipping 10 matching lines...) Expand all Loading... |
32 root = "." | 33 root = "." |
33 absroot = os.path.abspath(root) | 34 absroot = os.path.abspath(root) |
34 if not root: | 35 if not root: |
35 raise Exception("Could not get root directory.") | 36 raise Exception("Could not get root directory.") |
36 log = Backquote(['git', 'show', '--name-only', | 37 log = Backquote(['git', 'show', '--name-only', |
37 '--pretty=format:%H%n%s%n%n%b']) | 38 '--pretty=format:%H%n%s%n%n%b']) |
38 m = re.match(r'^(\w+)\n(.*)$', log, re.MULTILINE|re.DOTALL) | 39 m = re.match(r'^(\w+)\n(.*)$', log, re.MULTILINE|re.DOTALL) |
39 if not m: | 40 if not m: |
40 raise Exception("Could not parse log message: %s" % log) | 41 raise Exception("Could not parse log message: %s" % log) |
41 name = m.group(1) | 42 name = m.group(1) |
42 description = m.group(2) | |
43 files = scm.GIT.CaptureStatus([root], upstream_branch) | 43 files = scm.GIT.CaptureStatus([root], upstream_branch) |
44 issue = Backquote(['git', 'cl', 'status', '--field=id']) | 44 issue = Backquote(['git', 'cl', 'status', '--field=id']) |
| 45 if issue == "None": |
| 46 description = m.group(2) |
| 47 else: |
| 48 description = gcl.GetIssueDescription(int(issue)) |
45 patchset = None | 49 patchset = None |
46 self.change = presubmit_support.GitChange(name, description, absroot, files, | 50 self.change = presubmit_support.GitChange(name, description, absroot, files, |
47 issue, patchset) | 51 issue, patchset) |
48 | 52 |
49 | 53 |
50 def RunHooks(hook_name, upstream_branch): | 54 def RunHooks(hook_name, upstream_branch): |
51 commit = (hook_name == 'pre-cl-dcommit') | 55 commit = (hook_name == 'pre-cl-dcommit') |
52 | 56 |
53 # Create our options based on the command-line args and the current checkout. | 57 # Create our options based on the command-line args and the current checkout. |
54 options = ChangeOptions(commit=commit, upstream_branch=upstream_branch) | 58 options = ChangeOptions(commit=commit, upstream_branch=upstream_branch) |
(...skipping 10 matching lines...) Expand all Loading... |
65 if presubmit_support.DoPresubmitChecks(options.change, | 69 if presubmit_support.DoPresubmitChecks(options.change, |
66 options.commit, | 70 options.commit, |
67 options.verbose, | 71 options.verbose, |
68 sys.stdout, | 72 sys.stdout, |
69 sys.stdin, | 73 sys.stdin, |
70 options.default_presubmit, | 74 options.default_presubmit, |
71 options.may_prompt): | 75 options.may_prompt): |
72 sys.exit(0) | 76 sys.exit(0) |
73 else: | 77 else: |
74 sys.exit(1) | 78 sys.exit(1) |
OLD | NEW |