From 9f6bf39024d809812ab284bb0af6b4b76cd8f56e Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 23 Oct 2024 13:07:14 +0000 Subject: fix(source): dynamically identify host --- internal/yae/source.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/yae/source.go b/internal/yae/source.go index 185aba7..625a0f8 100644 --- a/internal/yae/source.go +++ b/internal/yae/source.go @@ -2,6 +2,7 @@ package yae import ( "fmt" + "net/url" "strings" "github.com/charmbracelet/log" @@ -91,7 +92,15 @@ func (source *Source) Update(sources *Sources, name string, force bool, forcePin func (source *Source) fetchLatestGitTag() (string, error) { if source.Type == "git" { - repository := "https://github.com/" + strings.Split(source.URL, "/")[3] + "/" + strings.Split(source.URL, "/")[4] + url, err := url.Parse(source.URL) + + if err != nil { + return "", err + } + + domain := url.Host + pathSegments := strings.Split(url.Path, "/") + repository := url.Scheme + "://" + domain + "/" + pathSegments[1] + "/" + pathSegments[2] remotes, err := command("bash", false, "-c", fmt.Sprintf("git ls-remote %s | awk -F'/' '{print $NF}' | sort -V", repository)) if err != nil { -- cgit v1.2.3