From e899019948145360bf36a1f95d952495bc0da377 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 11 Oct 2024 12:54:14 +0000 Subject: refactor(yae): simple tag predicate handling --- flake.nix | 1 + yae.go | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 1b0f0b6..01814cb 100644 --- a/flake.nix +++ b/flake.nix @@ -58,6 +58,7 @@ src = pkgs.lib.cleanSource ./.; vendorHash = "sha256-mN/QjzJ4eGfbW1H92cCKvC0wDhCR6IUes2HCZ5YBdPA="; buildInputs = [ pkgs.musl ]; + propagatedBuildInputs = [ pkgs.gitMinimal ]; ldflags = [ "-s" diff --git a/yae.go b/yae.go index 85502ef..9a2e73d 100644 --- a/yae.go +++ b/yae.go @@ -252,7 +252,7 @@ func command(name string, show bool, args ...string) (string, error) { func fetchLatestGitTag(source Source, show bool) (string, error) { if source.Type == "git" { repository := "https://github.com/" + strings.Split(source.URI, "/")[3] + "/" + strings.Split(source.URI, "/")[4] - remotes, err := command("git", show, "ls-remote", "--tags", repository) + remotes, err := command("bash", show, "-c", fmt.Sprintf("git ls-remote --tags %s | awk -F'/' '{print $NF}' | sort -V", repository)) if err != nil { return "", err @@ -263,14 +263,10 @@ func fetchLatestGitTag(source Source, show bool) (string, error) { if source.TagPredicate == "" { latest = refs[len(refs)-2] - - if strings.Contains(latest, "refs/tags/") { - latest = strings.Split(latest, "/")[2] - } } else { for i := len(refs) - 2; i >= 0; i-- { if strings.Contains(refs[i], source.TagPredicate) { - latest = strings.Split(refs[i], "/")[2] + latest = refs[i] break } -- cgit v1.2.3