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

Side by Side Diff: git_cl.py

Issue 1878613003: Fix git cl checkout when no branch has issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: actual fix Created 4 years, 8 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
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 4532 matching lines...) Expand 10 before | Expand all | Expand 10 after
4543 parser.print_help() 4543 parser.print_help()
4544 return 1 4544 return 1
4545 4545
4546 issue_arg = ParseIssueNumberArgument(args[0]) 4546 issue_arg = ParseIssueNumberArgument(args[0])
4547 if not issue_arg.valid: 4547 if not issue_arg.valid:
4548 parser.print_help() 4548 parser.print_help()
4549 return 1 4549 return 1
4550 target_issue = str(issue_arg.issue) 4550 target_issue = str(issue_arg.issue)
4551 4551
4552 def find_issues(issueprefix): 4552 def find_issues(issueprefix):
4553 key_and_issues = [x.split() for x in RunGit( 4553 output = RunGit(['config', '--local', '--get-regexp',
4554 ['config', '--local', '--get-regexp', r'branch\..*\.%s' % issueprefix]) 4554 r'branch\..*\.%s' % issueprefix],
4555 .splitlines()] 4555 error_ok=True)
4556 for key, issue in key_and_issues: 4556 for key, issue in [x.split() for x in output.splitlines()]:
4557 if issue == target_issue: 4557 if issue == target_issue:
4558 yield re.sub(r'branch\.(.*)\.%s' % issueprefix, r'\1', key) 4558 yield re.sub(r'branch\.(.*)\.%s' % issueprefix, r'\1', key)
4559 4559
4560 branches = [] 4560 branches = []
4561 for cls in _CODEREVIEW_IMPLEMENTATIONS.values(): 4561 for cls in _CODEREVIEW_IMPLEMENTATIONS.values():
4562 branches.extend(find_issues(cls.IssueSettingPrefix())) 4562 branches.extend(find_issues(cls.IssueSettingPrefix()))
4563 if len(branches) == 0: 4563 if len(branches) == 0:
4564 print 'No branch found for issue %s.' % target_issue 4564 print 'No branch found for issue %s.' % target_issue
4565 return 1 4565 return 1
4566 if len(branches) == 1: 4566 if len(branches) == 1:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4634 if __name__ == '__main__': 4634 if __name__ == '__main__':
4635 # These affect sys.stdout so do it outside of main() to simplify mocks in 4635 # These affect sys.stdout so do it outside of main() to simplify mocks in
4636 # unit testing. 4636 # unit testing.
4637 fix_encoding.fix_encoding() 4637 fix_encoding.fix_encoding()
4638 setup_color.init() 4638 setup_color.init()
4639 try: 4639 try:
4640 sys.exit(main(sys.argv[1:])) 4640 sys.exit(main(sys.argv[1:]))
4641 except KeyboardInterrupt: 4641 except KeyboardInterrupt:
4642 sys.stderr.write('interrupted\n') 4642 sys.stderr.write('interrupted\n')
4643 sys.exit(1) 4643 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698