fix(git): detect upstream-gone status correctly

This commit is contained in:
L. Yeung 2022-04-13 14:00:49 +08:00 committed by Jan De Dobbeleer
parent 693111c0c6
commit 0c7afaa7f7
2 changed files with 7 additions and 4 deletions

View file

@ -265,6 +265,8 @@ func (g *Git) setGitStatus() {
UPSTREAM = "# branch.upstream "
BRANCHSTATUS = "# branch.ab "
)
// firstly assume that upstream is gone
g.UpstreamGone = true
g.Working = &GitStatus{}
g.Staging = &GitStatus{}
output := g.getGitCommandOutput("status", "-unormal", "--branch", "--porcelain=2")

View file

@ -374,10 +374,11 @@ func TestSetGitStatus(t *testing.T) {
1 .U N...
1 A. N...
`,
ExpectedWorking: &GitStatus{ScmStatus: ScmStatus{Modified: 4, Added: 2, Deleted: 1, Unmerged: 1}},
ExpectedStaging: &GitStatus{ScmStatus: ScmStatus{Added: 1}},
ExpectedHash: "1234567",
ExpectedRef: "rework-git-status",
ExpectedWorking: &GitStatus{ScmStatus: ScmStatus{Modified: 4, Added: 2, Deleted: 1, Unmerged: 1}},
ExpectedStaging: &GitStatus{ScmStatus: ScmStatus{Added: 1}},
ExpectedHash: "1234567",
ExpectedRef: "rework-git-status",
ExpectedUpstreamGone: true,
},
{
Case: "all different options on working and staging, with remote",