Handle 400 error code when attempting to fetch clone bundle.

Gitlab returns a 400 error when trying to fetch clone.bundle
from a repository containing the git-repo tool. The repo
launcher doesn't then fall back to not using a clone.bundle
file and the repo init fails.

Change-Id: Ia3390d0638ef9a39fb2fab84625b269d28caf1cc
Signed-off-by: Craig Northway <cnorthway@codeaurora.org>
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305382
Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Craig Northway 2021-05-05 08:49:26 -07:00 committed by Mike Frysinger
parent 23ea754524
commit 0e8828c47b

7
repo
View File

@ -859,11 +859,10 @@ def _DownloadBundle(url, cwd, quiet, verbose):
try: try:
r = urllib.request.urlopen(url) r = urllib.request.urlopen(url)
except urllib.error.HTTPError as e: except urllib.error.HTTPError as e:
if e.code in [401, 403, 404, 501]: if e.code not in [400, 401, 403, 404, 501]:
print('warning: Cannot get %s' % url, file=sys.stderr)
print('warning: HTTP error %s' % e.code, file=sys.stderr)
return False return False
print('fatal: Cannot get %s' % url, file=sys.stderr)
print('fatal: HTTP error %s' % e.code, file=sys.stderr)
raise CloneFailure()
except urllib.error.URLError as e: except urllib.error.URLError as e:
print('fatal: Cannot get %s' % url, file=sys.stderr) print('fatal: Cannot get %s' % url, file=sys.stderr)
print('fatal: error %s' % e.reason, file=sys.stderr) print('fatal: error %s' % e.reason, file=sys.stderr)