diff options
| author | Fuwn <[email protected]> | 2024-10-11 12:54:14 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-11 12:54:19 +0000 |
| commit | e899019948145360bf36a1f95d952495bc0da377 (patch) | |
| tree | 9f1c0f31c7bf1c2bdb09c5c027fcf005096d4acc | |
| parent | fix(yae): default tag predicate for release references (diff) | |
| download | yae-e899019948145360bf36a1f95d952495bc0da377.tar.xz yae-e899019948145360bf36a1f95d952495bc0da377.zip | |
refactor(yae): simple tag predicate handling
| -rw-r--r-- | flake.nix | 1 | ||||
| -rw-r--r-- | yae.go | 8 |
2 files changed, 3 insertions, 6 deletions
@@ -58,6 +58,7 @@ src = pkgs.lib.cleanSource ./.; vendorHash = "sha256-mN/QjzJ4eGfbW1H92cCKvC0wDhCR6IUes2HCZ5YBdPA="; buildInputs = [ pkgs.musl ]; + propagatedBuildInputs = [ pkgs.gitMinimal ]; ldflags = [ "-s" @@ -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 } |