OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 """Wrapper for trychange.py for git checkout.""" | |
6 | |
7 import logging | |
8 import sys | |
9 | |
10 import breakpad # pylint: disable=W0611 | |
11 | |
12 from scm import GIT | |
13 import subprocess2 | |
14 import third_party.upload | |
15 import trychange | |
16 import git_cl | |
17 | |
18 | |
19 def GetRietveldIssueNumber(): | |
20 try: | |
21 return GIT.Capture( | |
22 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch('.')], | |
23 '.').strip() | |
24 except subprocess2.CalledProcessError: | |
25 return None | |
26 | |
27 | |
28 def GetRietveldPatchsetNumber(): | |
29 try: | |
30 return GIT.Capture( | |
31 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch('.')], | |
32 '.').strip() | |
33 except subprocess2.CalledProcessError: | |
34 return None | |
35 | |
36 | |
37 def GetRietveldServerUrl(): | |
38 try: | |
39 return GIT.Capture(['config', 'rietveld.server'], '.').strip() | |
40 except subprocess2.CalledProcessError: | |
41 return None | |
42 | |
43 | |
44 if __name__ == '__main__': | |
45 args = sys.argv[1:] | |
46 patchset = GetRietveldPatchsetNumber() | |
47 if patchset: | |
48 args.extend([ | |
49 '--issue', GetRietveldIssueNumber(), | |
50 '--patchset', patchset, | |
51 ]) | |
52 else: | |
53 rietveld_url = GetRietveldServerUrl() | |
54 if rietveld_url: | |
55 args.extend(['--rietveld_url', GetRietveldServerUrl()]) | |
56 try: | |
57 cl = git_cl.Changelist() | |
58 change = cl.GetChange(cl.GetUpstreamBranch(), None) | |
59 # Hack around a limitation in logging. | |
60 logging.getLogger().handlers = [] | |
61 sys.exit(trychange.TryChange( | |
62 args, change, swallow_exception=False, | |
63 prog='git try', | |
64 extra_epilog='\n' | |
65 'git try will diff against your tracked branch and will ' | |
66 'detect your rietveld\n' | |
67 'code review if you are using git-cl\n')) | |
68 except third_party.upload.ClientLoginError, e: | |
69 print('Got an exception while trying to log in to Rietveld.') | |
70 print(str(e)) | |
OLD | NEW |