From 488bf092d5992bd1b8f8681c444f2cc283d05bcb Mon Sep 17 00:00:00 2001 From: Timo Lotterbach Date: Fri, 15 Jul 2016 16:55:39 +0200 Subject: [PATCH] Repo: fall back to http, if ssh connection fails for http repos if a gerrit server has ssh and https access enabled, but user access (for some users) is limited to https, 'repo upload' command will fail for them. Gerrit returns a ssh configuration (gerrit/ssh_info), that does not work for users limited to https. With this patch repo will test, if the returned ssh configuration from gerrit/ssh_info is working. if not, it will fall back to https for upload. Change-Id: If98f472e994f350bf71f35610cd649b163f1ab33 --- git_config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git_config.py b/git_config.py index 0379181a..09c4b48f 100644 --- a/git_config.py +++ b/git_config.py @@ -638,7 +638,10 @@ class Remote(object): self._review_url = http_url else: host, port = info.split() - self._review_url = self._SshReviewUrl(userEmail, host, port) + if _open_ssh(host, port): + self._review_url = self._SshReviewUrl(userEmail, host, port) + else: + self._review_url = http_url except urllib.error.HTTPError as e: raise UploadError('%s: %s' % (self.review, str(e))) except urllib.error.URLError as e: