From a90de4f8481e9c28a682da3189f84948dffd1bd8 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 9 Jul 2024 11:01:49 -0600 Subject: [PATCH] update to fetch tag first --- git_fleximod/submodule.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/git_fleximod/submodule.py b/git_fleximod/submodule.py index 713ea34..4865727 100644 --- a/git_fleximod/submodule.py +++ b/git_fleximod/submodule.py @@ -1,6 +1,7 @@ import os import textwrap import shutil +import string from configparser import NoOptionError from git_fleximod import utils from git_fleximod.gitinterface import GitInterface @@ -162,7 +163,8 @@ def _add_remote(self, git): if remotes: upstream = git.git_operation("ls-remote", "--get-url").rstrip() newremote = "newremote.00" - line = next((s for s in remotes if self.url or tmpurl in s), None) + tmpurl = self.url.replace("git@github.com:", "https://github.com/") + line = next((s for s in remotes if self.url in s or tmpurl in s), None) if line: newremote = line.split()[0] return newremote @@ -357,6 +359,13 @@ def update(self): if self.fxtag: smgit = GitInterface(repodir, self.logger) + newremote = self._add_remote(smgit) + # Trying to distingush a tag from a hash + allowed = set(string.digits + 'abcdef') + if not set(self.fxtag) <= allowed: + # This is a tag + tag = f"refs/tags/{self.fxtag}:refs/tags/{self.fxtag}" + smgit.git_operation("fetch", newremote, tag) smgit.git_operation("checkout", self.fxtag) if not os.path.exists(os.path.join(repodir, ".git")):