mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Fix ssh://user@domain@server.com/ in git repo link (Issue #149)
This commit is contained in:
parent
d2d3e595af
commit
575f391ba7
@ -7,11 +7,10 @@ from tempfile import mkstemp
|
|||||||
import attr
|
import attr
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from furl import furl
|
|
||||||
from pathlib2 import Path
|
from pathlib2 import Path
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
|
|
||||||
from .util import get_command_output
|
from .util import get_command_output, remove_user_pass_from_url
|
||||||
from ....backend_api import Session
|
from ....backend_api import Session
|
||||||
from ....debugging import get_logger
|
from ....debugging import get_logger
|
||||||
from .detectors import GitEnvDetector, GitDetector, HgEnvDetector, HgDetector, Result as DetectionResult
|
from .detectors import GitEnvDetector, GitDetector, HgEnvDetector, HgDetector, Result as DetectionResult
|
||||||
@ -634,7 +633,7 @@ class ScriptInfo(object):
|
|||||||
script_requirements = None
|
script_requirements = None
|
||||||
|
|
||||||
script_info = dict(
|
script_info = dict(
|
||||||
repository=furl(repo_info.url).remove(username=True, password=True).tostr(),
|
repository=remove_user_pass_from_url(repo_info.url),
|
||||||
branch=repo_info.branch,
|
branch=repo_info.branch,
|
||||||
version_num=repo_info.commit,
|
version_num=repo_info.commit,
|
||||||
entry_point=entry_point,
|
entry_point=entry_point,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
|
|
||||||
|
from furl import furl
|
||||||
|
|
||||||
|
|
||||||
def get_command_output(command, path=None):
|
def get_command_output(command, path=None):
|
||||||
"""
|
"""
|
||||||
@ -10,3 +12,23 @@ def get_command_output(command, path=None):
|
|||||||
"""
|
"""
|
||||||
with open(os.devnull, "wb") as devnull:
|
with open(os.devnull, "wb") as devnull:
|
||||||
return check_output(command, cwd=path, stderr=devnull).decode().strip()
|
return check_output(command, cwd=path, stderr=devnull).decode().strip()
|
||||||
|
|
||||||
|
|
||||||
|
def remove_user_pass_from_url(url):
|
||||||
|
# remove user / password, if we have it embedded in the git repo
|
||||||
|
url = str(url)
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
url = furl(url).remove(username=True, password=True).tostr()
|
||||||
|
except ValueError:
|
||||||
|
# check if for any reason we have two @
|
||||||
|
# (e.g. ssh://user@abc.com@domain.com/path or ssh://user@abc.com:pass@domain.com/path)
|
||||||
|
if len(url.split('@')) >= 3:
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
url = furl(url.replace('@', '_', 1)).remove(username=True, password=True).tostr()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return url
|
||||||
|
Loading…
Reference in New Issue
Block a user