diff options
author | Shawn O. Pearce <sop@google.com> | 2012-01-11 14:58:54 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2012-01-11 16:18:40 -0800 |
commit | c9571423f843340de19ef576ccaa418ac72fdb58 (patch) | |
tree | 938fdcdde76dfc1cc8b299e0f6d96648242902e1 /project.py | |
parent | 34fb20f67c7bdca2b1321a40f2fd558f9a34d866 (diff) | |
download | git-repo-c9571423f843340de19ef576ccaa418ac72fdb58.tar.gz |
upload: Support uploading to Gerrit over https://v1.7.8.2
If SSH is not available, Gerrit returns NOT_AVAILABLE to the /ssh_info
query made by repo upload. In this case fallback to the /p/$PROJECT URL
that Gerrit also exports and use that for uploads.
Change-Id: I1e3e39ab709ecc0a692614a41a42446426f39c08
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -866,31 +866,30 @@ class Project(object): | |||
866 | branch.remote.projectname = self.name | 866 | branch.remote.projectname = self.name |
867 | branch.remote.Save() | 867 | branch.remote.Save() |
868 | 868 | ||
869 | if branch.remote.ReviewProtocol == 'ssh': | 869 | url = branch.remote.ReviewUrl(self.UserEmail) |
870 | if dest_branch.startswith(R_HEADS): | 870 | if url is None: |
871 | dest_branch = dest_branch[len(R_HEADS):] | 871 | raise UploadError('review not configured') |
872 | cmd = ['push'] | ||
872 | 873 | ||
874 | if url.startswith('ssh://'): | ||
873 | rp = ['gerrit receive-pack'] | 875 | rp = ['gerrit receive-pack'] |
874 | for e in people[0]: | 876 | for e in people[0]: |
875 | rp.append('--reviewer=%s' % sq(e)) | 877 | rp.append('--reviewer=%s' % sq(e)) |
876 | for e in people[1]: | 878 | for e in people[1]: |
877 | rp.append('--cc=%s' % sq(e)) | 879 | rp.append('--cc=%s' % sq(e)) |
878 | |||
879 | ref_spec = '%s:refs/for/%s' % (R_HEADS + branch.name, dest_branch) | ||
880 | if auto_topic: | ||
881 | ref_spec = ref_spec + '/' + branch.name | ||
882 | |||
883 | cmd = ['push'] | ||
884 | cmd.append('--receive-pack=%s' % " ".join(rp)) | 880 | cmd.append('--receive-pack=%s' % " ".join(rp)) |
885 | cmd.append(branch.remote.SshReviewUrl(self.UserEmail)) | ||
886 | cmd.append(ref_spec) | ||
887 | 881 | ||
888 | if GitCommand(self, cmd, bare = True).Wait() != 0: | 882 | cmd.append(url) |
889 | raise UploadError('Upload failed') | ||
890 | 883 | ||
891 | else: | 884 | if dest_branch.startswith(R_HEADS): |
892 | raise UploadError('Unsupported protocol %s' \ | 885 | dest_branch = dest_branch[len(R_HEADS):] |
893 | % branch.remote.review) | 886 | ref_spec = '%s:refs/for/%s' % (R_HEADS + branch.name, dest_branch) |
887 | if auto_topic: | ||
888 | ref_spec = ref_spec + '/' + branch.name | ||
889 | cmd.append(ref_spec) | ||
890 | |||
891 | if GitCommand(self, cmd, bare = True).Wait() != 0: | ||
892 | raise UploadError('Upload failed') | ||
894 | 893 | ||
895 | msg = "posted to %s for %s" % (branch.remote.review, dest_branch) | 894 | msg = "posted to %s for %s" % (branch.remote.review, dest_branch) |
896 | self.bare_git.UpdateRef(R_PUB + branch.name, | 895 | self.bare_git.UpdateRef(R_PUB + branch.name, |