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

Side by Side Diff: git_cl.py

Issue 967453004: Stop defaulting unrecognized branches to master except for handful of special refs (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Initial upload Created 5 years, 9 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.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 import subprocess2 49 import subprocess2
50 import watchlists 50 import watchlists
51 51
52 __version__ = '1.0' 52 __version__ = '1.0'
53 53
54 DEFAULT_SERVER = 'https://codereview.appspot.com' 54 DEFAULT_SERVER = 'https://codereview.appspot.com'
55 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' 55 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
56 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' 56 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
57 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' 57 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit'
58 CHANGE_ID = 'Change-Id:' 58 CHANGE_ID = 'Change-Id:'
59 REFS_THAT_DEFAULT_TO_MASTER = ('refs/remotes/origin/lkgr',
agable 2015/03/02 23:11:34 It might make more sense to have a REFS_THAT_ALIAS
rmistry 2015/03/03 12:26:23 Lets try the general route for forwards-compatibil
60 'refs/remotes/origin/lkcr')
59 61
60 # Valid extensions for files we want to lint. 62 # Valid extensions for files we want to lint.
61 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" 63 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)"
62 DEFAULT_LINT_IGNORE_REGEX = r"$^" 64 DEFAULT_LINT_IGNORE_REGEX = r"$^"
63 65
64 # Shortcut since it quickly becomes redundant. 66 # Shortcut since it quickly becomes redundant.
65 Fore = colorama.Fore 67 Fore = colorama.Fore
66 68
67 # Initialized in main() 69 # Initialized in main()
68 settings = None 70 settings = None
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 ) 1785 )
1784 match = None 1786 match = None
1785 for regex, replacement in prefix_replacements: 1787 for regex, replacement in prefix_replacements:
1786 match = re.search(regex, target_branch) 1788 match = re.search(regex, target_branch)
1787 if match: 1789 if match:
1788 remote_branch = target_branch.replace(match.group(0), replacement) 1790 remote_branch = target_branch.replace(match.group(0), replacement)
1789 break 1791 break
1790 if not match: 1792 if not match:
1791 # This is a branch path but not one we recognize; use as-is. 1793 # This is a branch path but not one we recognize; use as-is.
1792 remote_branch = target_branch 1794 remote_branch = target_branch
1793 elif (not remote_branch.startswith('refs/remotes/branch-heads') and 1795 elif remote_branch in REFS_THAT_DEFAULT_TO_MASTER:
1794 not remote_branch.startswith('refs/remotes/%s/refs' % remote)): 1796 # Handle the special refs that should land in master.
1795 # Default to master for refs that are not branches.
1796 remote_branch = 'refs/remotes/%s/master' % remote 1797 remote_branch = 'refs/remotes/%s/master' % remote
1797 1798
1798 # Create the true path to the remote branch. 1799 # Create the true path to the remote branch.
1799 # Does the following translation: 1800 # Does the following translation:
1800 # * refs/remotes/origin/refs/diff/test -> refs/diff/test 1801 # * refs/remotes/origin/refs/diff/test -> refs/diff/test
1801 # * refs/remotes/origin/master -> refs/heads/master 1802 # * refs/remotes/origin/master -> refs/heads/master
1802 # * refs/remotes/branch-heads/test -> refs/branch-heads/test 1803 # * refs/remotes/branch-heads/test -> refs/branch-heads/test
1803 if remote_branch.startswith('refs/remotes/%s/refs/' % remote): 1804 if remote_branch.startswith('refs/remotes/%s/refs/' % remote):
1804 remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, '') 1805 remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, '')
1805 elif remote_branch.startswith('refs/remotes/%s/' % remote): 1806 elif remote_branch.startswith('refs/remotes/%s/' % remote):
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 if __name__ == '__main__': 3095 if __name__ == '__main__':
3095 # These affect sys.stdout so do it outside of main() to simplify mocks in 3096 # These affect sys.stdout so do it outside of main() to simplify mocks in
3096 # unit testing. 3097 # unit testing.
3097 fix_encoding.fix_encoding() 3098 fix_encoding.fix_encoding()
3098 colorama.init() 3099 colorama.init()
3099 try: 3100 try:
3100 sys.exit(main(sys.argv[1:])) 3101 sys.exit(main(sys.argv[1:]))
3101 except KeyboardInterrupt: 3102 except KeyboardInterrupt:
3102 sys.stderr.write('interrupted\n') 3103 sys.stderr.write('interrupted\n')
3103 sys.exit(1) 3104 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