Index: git_cl.py |
diff --git a/git_cl.py b/git_cl.py |
index 4c91b6c762147b7ce5c886df94d8fdd906995725..0053241667a7af0002200ec484992036f5f25f43 100755 |
--- a/git_cl.py |
+++ b/git_cl.py |
@@ -1749,18 +1749,29 @@ def RietveldUpload(options, args, cl, change): |
upload_args.extend(['--base_url', remote_url]) |
remote, remote_branch = cl.GetRemoteBranch() |
if remote and remote_branch: |
- # Create the true path to the remote branch. |
- # Does the following translation: |
- # * refs/remotes/origin/refs/diff/test -> refs/diff/test |
- # * refs/remotes/origin/master -> refs/heads/master |
- # * refs/remotes/branch-heads/test -> refs/branch-heads/test |
- if remote_branch.startswith('refs/remotes/%s/refs/' % remote): |
- remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, '') |
- elif remote_branch.startswith('refs/remotes/%s/' % remote): |
- remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, |
- 'refs/heads/') |
- elif remote_branch.startswith('refs/remotes/branch-heads'): |
- remote_branch = remote_branch.replace('refs/remotes/', 'refs/') |
+ if options.target_branch: |
agable
2015/01/07 21:45:09
And what if the user passes --target_branch=refs/h
Mike Wittman
2015/01/07 23:55:33
Good point. I've updated the branch recognition to
|
+ if options.target_branch.startswith('branch-heads/'): |
+ remote_branch = 'refs/%s' % options.target_branch |
+ else: |
+ remote_branch = 'refs/heads/%s' % options.target_branch |
+ else: |
+ # Create the true path to the remote branch. |
+ # Does the following translation: |
+ # * refs/remotes/origin/refs/diff/test -> refs/diff/test |
+ # * refs/remotes/origin/master -> refs/heads/master |
+ # * refs/remotes/branch-heads/test -> refs/branch-heads/test |
+ if remote_branch.startswith('refs/remotes/%s/refs/' % remote): |
+ remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, '') |
+ elif remote_branch.startswith('refs/remotes/%s/' % remote): |
+ remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, |
+ 'refs/heads/') |
+ elif remote_branch.startswith('refs/remotes/branch-heads'): |
+ remote_branch = remote_branch.replace('refs/remotes/', 'refs/') |
+ |
+ # Default to master for refs that are not branches. |
+ if not remote_branch.startswith('refs/branch-heads'): |
+ remote_branch = 'refs/heads/master' |
+ |
pending_prefix = settings.GetPendingRefPrefix() |
# If a pending prefix exists then replace refs/ with it. |
if pending_prefix: |
@@ -1842,8 +1853,8 @@ def CMDupload(parser, args): |
help='set the review private (rietveld only)') |
parser.add_option('--target_branch', |
'--target-branch', |
- help='When uploading to gerrit, remote branch to ' |
- 'use for CL. Default: master') |
+ help='Remote branch to use for CL. ' + |
agable
2015/01/07 21:45:09
As noted above, this text is not explicit enough t
Mike Wittman
2015/01/07 23:55:33
We should now handle all of these cases.
|
+ 'Default: remote branch head, or master') |
parser.add_option('--email', default=None, |
help='email address to use to connect to Rietveld') |
parser.add_option('--tbr-owners', dest='tbr_owners', action='store_true', |
@@ -1852,9 +1863,6 @@ def CMDupload(parser, args): |
add_git_similarity(parser) |
(options, args) = parser.parse_args(args) |
- if options.target_branch and not settings.GetIsGerrit(): |
- parser.error('Use --target_branch for non gerrit repository.') |
- |
if is_dirty_git_tree('upload'): |
return 1 |