From 38baea3dcf053203ea85e29008b03ec878054a9e Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 2 Jan 2023 19:14:33 +0000 Subject: [PATCH] Fix wrong scheme used when Git cloning Fixes #408 --- app/utils/git.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/utils/git.py b/app/utils/git.py index 327d933f..e1363245 100644 --- a/app/utils/git.py +++ b/app/utils/git.py @@ -22,10 +22,14 @@ from git import GitCommandError from app.tasks import TaskError from app.utils import randomString -def generateGitURL(urlstr): + +def generate_git_url(urlstr): scheme, netloc, path, query, frag = urlsplit(urlstr) - return "http://:@" + netloc + path + query + if not scheme.startswith("http"): + scheme = "http" + + return scheme + "://:@" + netloc + path + query @contextlib.contextmanager @@ -45,7 +49,7 @@ def clone_repo(urlstr, ref=None, recursive=False): err = None try: - gitUrl = generateGitURL(urlstr) + gitUrl = generate_git_url(urlstr) print("Cloning from " + gitUrl) if ref is None: @@ -79,7 +83,7 @@ def clone_repo(urlstr, ref=None, recursive=False): def get_latest_commit(git_url, ref_name=None): - git_url = generateGitURL(git_url) + git_url = generate_git_url(git_url) if ref_name: ref_name = "refs/heads/" + ref_name