From 19e0efc1fc53240d1fdf98827cf407136d21914d Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Fri, 20 Jan 2023 21:27:59 +0100 Subject: [PATCH] fix(git): do not process remote when empty resolves #3377 --- src/segments/git.go | 4 ++++ src/segments/git_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/src/segments/git.go b/src/segments/git.go index c0540ebb..51a5e94f 100644 --- a/src/segments/git.go +++ b/src/segments/git.go @@ -390,7 +390,11 @@ func (g *Git) getUpstreamIcon() string { url = strings.ReplaceAll(url, ":", "/") return fmt.Sprintf("https://%s", url) } + g.RawUpstreamURL = g.getRemoteURL() + if len(g.RawUpstreamURL) == 0 { + return "" + } g.UpstreamURL = cleanSSHURL(g.RawUpstreamURL) // allow overrides first diff --git a/src/segments/git_test.go b/src/segments/git_test.go index 223d796a..ec58c7ce 100644 --- a/src/segments/git_test.go +++ b/src/segments/git_test.go @@ -593,6 +593,7 @@ func TestGitUpstream(t *testing.T) { Expected string Upstream string }{ + {Case: "No upstream", Expected: "", Upstream: ""}, {Case: "GitHub", Expected: "GH", Upstream: "github.com/test"}, {Case: "Gitlab", Expected: "GL", Upstream: "gitlab.com/test"}, {Case: "Bitbucket", Expected: "BB", Upstream: "bitbucket.org/test"},