Fix wrong scheme used when Git cloning

Fixes #408
This commit is contained in:
rubenwardy 2023-01-02 19:14:33 +00:00
parent ad0e958736
commit 38baea3dcf

@ -22,10 +22,14 @@ from git import GitCommandError
from app.tasks import TaskError from app.tasks import TaskError
from app.utils import randomString from app.utils import randomString
def generateGitURL(urlstr):
def generate_git_url(urlstr):
scheme, netloc, path, query, frag = urlsplit(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 @contextlib.contextmanager
@ -45,7 +49,7 @@ def clone_repo(urlstr, ref=None, recursive=False):
err = None err = None
try: try:
gitUrl = generateGitURL(urlstr) gitUrl = generate_git_url(urlstr)
print("Cloning from " + gitUrl) print("Cloning from " + gitUrl)
if ref is None: 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): def get_latest_commit(git_url, ref_name=None):
git_url = generateGitURL(git_url) git_url = generate_git_url(git_url)
if ref_name: if ref_name:
ref_name = "refs/heads/" + ref_name ref_name = "refs/heads/" + ref_name