fix(git): clean ssh remote url correctly

resolves #3378
This commit is contained in:
Jan De Dobbeleer 2023-01-20 21:32:57 +01:00 committed by Jan De Dobbeleer
parent 19e0efc1fc
commit 25b29bc5bd
2 changed files with 2 additions and 1 deletions

View file

@ -384,10 +384,10 @@ func (g *Git) getUpstreamIcon() string {
if strings.HasPrefix(url, "http") {
return url
}
url = strings.TrimPrefix(url, "ssh://")
url = strings.TrimPrefix(url, "git://")
url = strings.TrimPrefix(url, "git@")
url = strings.TrimSuffix(url, ".git")
url = strings.ReplaceAll(url, ":", "/")
return fmt.Sprintf("https://%s", url)
}

View file

@ -594,6 +594,7 @@ func TestGitUpstream(t *testing.T) {
Upstream string
}{
{Case: "No upstream", Expected: "", Upstream: ""},
{Case: "SSH url", Expected: "G", Upstream: "ssh://git@git.my.domain:3001/ADIX7/dotconfig.git"},
{Case: "GitHub", Expected: "GH", Upstream: "github.com/test"},
{Case: "Gitlab", Expected: "GL", Upstream: "gitlab.com/test"},
{Case: "Bitbucket", Expected: "BB", Upstream: "bitbucket.org/test"},