Skip to content

Commit

Permalink
update to fetch tag first
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Jul 9, 2024
1 parent a6e43fc commit a90de4f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion git_fleximod/submodule.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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("[email protected]:", "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
Expand Down Expand Up @@ -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")):
Expand Down

0 comments on commit a90de4f

Please sign in to comment.