From 69fbd152bc92f2ee3cfb623a0586182106bde0b7 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de> Date: Tue, 14 May 2024 12:52:08 +0200 Subject: [PATCH] Use a simple heuristic to determine if a git_tag is actually a git rev If it's 40 characters long hexadecimal string it's very likely a rev Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de> --- dependency_manager/src/edm_tool/__init__.py | 2 +- dependency_manager/src/edm_tool/edm.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dependency_manager/src/edm_tool/__init__.py b/dependency_manager/src/edm_tool/__init__.py index de546da..74605d2 100644 --- a/dependency_manager/src/edm_tool/__init__.py +++ b/dependency_manager/src/edm_tool/__init__.py @@ -4,7 +4,7 @@ # """Everest Dependency Manager.""" from edm_tool import edm -__version__ = "0.6.1" +__version__ = "0.6.2" def get_parser(): diff --git a/dependency_manager/src/edm_tool/edm.py b/dependency_manager/src/edm_tool/edm.py index d0f978c..f53fb08 100755 --- a/dependency_manager/src/edm_tool/edm.py +++ b/dependency_manager/src/edm_tool/edm.py @@ -19,6 +19,7 @@ import requests import re import datetime +import string log = logging.getLogger("edm") @@ -617,7 +618,7 @@ def create_config(cls, working_dir: Path, new_config: dict, external_in_config: log.debug(f" tag: {tag}") entry["git_tag"] = tag except subprocess.CalledProcessError: - log.warning(f"Skipping {name} because no branch or tag could be determined.") + log.warning(f"No branch or tag could be determined for dependency {name}.") continue new_config[name] = entry @@ -851,6 +852,12 @@ def clone_dependency_repo(git: str, git_tag: str, checkout_dir: Path) -> None: log.debug(f" Repo is not dirty, checking out requested git tag \"{git_tag}\"") GitInfo.checkout_rev(checkout_dir, git_tag) else: + # check if git_tag is a 40 character hex string and assume it is a git_rev + if len(git_tag) == 40 and all(character in string.hexdigits for character in git_tag): + log.debug(f" git_tag \"{git_tag}\" might be a git_rev, trying to checkout this rev.") + git_rev = git_tag + git_tag = None + git_tag_is_git_rev = True try: clone_dependency_repo(git, git_tag, checkout_dir) except LocalDependencyCheckoutError as e: