Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: git_cl_hooks.py

Issue 2832006: Fix git cl code to get the changelist description without using gcl.... (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
13 import presubmit_support 12 import presubmit_support
14 import scm 13 import scm
15 import watchlists 14 import watchlists
16 15
17 def Backquote(cmd, cwd=None): 16 def Backquote(cmd, cwd=None):
18 """Like running `cmd` in a shell script.""" 17 """Like running `cmd` in a shell script."""
19 return subprocess.Popen(cmd, 18 return subprocess.Popen(cmd,
20 cwd=cwd, 19 cwd=cwd,
21 stdout=subprocess.PIPE).communicate()[0].strip() 20 stdout=subprocess.PIPE).communicate()[0].strip()
22 21
(...skipping 21 matching lines...) Expand all
44 log = Backquote(['git', 'show', '--name-only', 43 log = Backquote(['git', 'show', '--name-only',
45 '--pretty=format:%H%n%s%n%n%b']) 44 '--pretty=format:%H%n%s%n%n%b'])
46 m = re.match(r'^(\w+)\n(.*)$', log, re.MULTILINE|re.DOTALL) 45 m = re.match(r'^(\w+)\n(.*)$', log, re.MULTILINE|re.DOTALL)
47 if not m: 46 if not m:
48 raise Exception("Could not parse log message: %s" % log) 47 raise Exception("Could not parse log message: %s" % log)
49 name = m.group(1) 48 name = m.group(1)
50 files = scm.GIT.CaptureStatus([root], upstream_branch) 49 files = scm.GIT.CaptureStatus([root], upstream_branch)
51 issue = BackquoteAsInteger(['git', 'cl', 'status', '--field=id']) 50 issue = BackquoteAsInteger(['git', 'cl', 'status', '--field=id'])
52 patchset = BackquoteAsInteger(['git', 'cl', 'status', '--field=patch']) 51 patchset = BackquoteAsInteger(['git', 'cl', 'status', '--field=patch'])
53 if issue: 52 if issue:
54 description = gcl.GetIssueDescription(issue) 53 description = Backquote(['git', 'cl', 'status', '--field=desc'])
55 else: 54 else:
56 description = m.group(2) 55 description = m.group(2)
57 self.change = presubmit_support.GitChange(name, description, absroot, files, 56 self.change = presubmit_support.GitChange(name, description, absroot, files,
58 issue, patchset) 57 issue, patchset)
59 58
60 59
61 def RunHooks(hook_name, upstream_branch): 60 def RunHooks(hook_name, upstream_branch):
62 commit = (hook_name == 'pre-cl-dcommit') 61 commit = (hook_name == 'pre-cl-dcommit')
63 62
64 # Create our options based on the command-line args and the current checkout. 63 # Create our options based on the command-line args and the current checkout.
(...skipping 11 matching lines...) Expand all
76 if presubmit_support.DoPresubmitChecks(options.change, 75 if presubmit_support.DoPresubmitChecks(options.change,
77 options.commit, 76 options.commit,
78 options.verbose, 77 options.verbose,
79 sys.stdout, 78 sys.stdout,
80 sys.stdin, 79 sys.stdin,
81 options.default_presubmit, 80 options.default_presubmit,
82 options.may_prompt): 81 options.may_prompt):
83 sys.exit(0) 82 sys.exit(0)
84 else: 83 else:
85 sys.exit(1) 84 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698