mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
parent
96cac5f689
commit
284f2cbccf
|
@ -206,7 +206,9 @@ func (g *git) setGitStatus() {
|
||||||
if status["local"] != "" {
|
if status["local"] != "" {
|
||||||
g.repo.ahead, _ = strconv.Atoi(status["ahead"])
|
g.repo.ahead, _ = strconv.Atoi(status["ahead"])
|
||||||
g.repo.behind, _ = strconv.Atoi(status["behind"])
|
g.repo.behind, _ = strconv.Atoi(status["behind"])
|
||||||
g.repo.upstream = status["upstream"]
|
if status["upstream_status"] != "gone" {
|
||||||
|
g.repo.upstream = status["upstream"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.repo.HEAD = g.getGitHEADContext(status["local"])
|
g.repo.HEAD = g.getGitHEADContext(status["local"])
|
||||||
g.repo.stashCount = g.getStashContext()
|
g.repo.stashCount = g.getStashContext()
|
||||||
|
@ -346,7 +348,7 @@ func (g *git) getStashContext() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *git) parseGitStatusInfo(branchInfo string) map[string]string {
|
func (g *git) parseGitStatusInfo(branchInfo string) map[string]string {
|
||||||
var branchRegex = regexp.MustCompile(`^## (?P<local>\S+?)(\.{3}(?P<upstream>\S+?)( \[(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?])?)?$`)
|
var branchRegex = regexp.MustCompile(`^## (?P<local>\S+?)(\.{3}(?P<upstream>\S+?)( \[(?P<upstream_status>(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?(gone)?)])?)?$`)
|
||||||
return groupDict(branchRegex, branchInfo)
|
return groupDict(branchRegex, branchInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,6 +267,14 @@ func TestParseGitBranchInfoNoRemote(t *testing.T) {
|
||||||
assert.Empty(t, got["upstream"])
|
assert.Empty(t, got["upstream"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseGitBranchInfoRemoteGone(t *testing.T) {
|
||||||
|
g := git{}
|
||||||
|
branchInfo := "## test-branch...origin/test-branch [gone]"
|
||||||
|
got := g.parseGitStatusInfo(branchInfo)
|
||||||
|
assert.Equal(t, "test-branch", got["local"])
|
||||||
|
assert.Equal(t, "gone", got["upstream_status"])
|
||||||
|
}
|
||||||
|
|
||||||
func TestGitStatusUnmerged(t *testing.T) {
|
func TestGitStatusUnmerged(t *testing.T) {
|
||||||
expected := "<#123456>working: x1</>"
|
expected := "<#123456>working: x1</>"
|
||||||
status := &gitStatus{
|
status := &gitStatus{
|
||||||
|
|
Loading…
Reference in a new issue