From 78384504f784fdadd2c8303733a25a60466bc16b Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Fri, 21 Apr 2017 12:34:30 +0200 Subject: [PATCH] allow plain local paths in the place of SCM URLs Translate local paths into valid file:// URLs before further processing. --- module_build_service/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/module_build_service/utils.py b/module_build_service/utils.py index 7268db1e..74226ec6 100644 --- a/module_build_service/utils.py +++ b/module_build_service/utils.py @@ -706,8 +706,16 @@ def submit_module_build_from_yaml(username, handle, optional_params=None): return submit_module_build(username, None, mmd, None, yaml, optional_params) +_url_check_re = re.compile(r"^[^:/]+:.*$") + def submit_module_build_from_scm(username, url, branch, allow_local_url=False, optional_params=None): + # Translate local paths into file:// URL + if allow_local_url and not _url_check_re.match(url): + log.info( + "'{}' is not a valid URL, assuming local path".format(url)) + url = os.path.abspath(url) + url = "file://" + url mmd, scm, yaml = _fetch_mmd(url, branch, allow_local_url) return submit_module_build(username, url, mmd, scm, yaml, optional_params)