From 2d694272c04085de9a9808d34b0a54d030f6d4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 25 Feb 2019 14:13:21 +0100 Subject: [PATCH] Resolve git branches in scm_dict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the config uses SCM dicts that include branch or tag names, they will be resolved to specific commit ids. It goes through the caching resolver. The main motivation for that is to correctly support the --offline flag. It's highly unlikely there will be two scm_dicts in the config with the same repo. JIRA: COMPOSE-3279 Signed-off-by: Lubomír Sedlář --- pungi/checks.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pungi/checks.py b/pungi/checks.py index 137f5b0e..b2949cfa 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -293,6 +293,21 @@ def _extend_with_default_and_alias(validator_class, offline=False): except util.GitUrlResolveError as exc: yield ConfigOptionError(exc) + # Resolve branch in scm dicts. + if ( + # Schema says it can be an scm dict + subschema.get("$ref") == "#/definitions/str_or_scm_dict" + # and the data is actually a dict + and isinstance(instance.get(property), dict) + # and it's git + and instance[property]["scm"] == "git" + # and there's a repo URL specified + and "repo" in instance[property] + ): + instance[property]["branch"] = util.resolve_git_ref( + instance[property]["repo"], instance[property].get("branch", "HEAD") + ) + for error in _hook_errors(properties, instance, schema): yield error