refactor: make true string constant

This commit is contained in:
Jan De Dobbeleer 2023-11-09 17:09:37 +01:00 committed by Jan De Dobbeleer
parent 1298129b87
commit 54c5262a27
2 changed files with 5 additions and 3 deletions

View file

@ -113,6 +113,8 @@ const (
DETACHED = "(detached)" DETACHED = "(detached)"
BRANCHPREFIX = "ref: refs/heads/" BRANCHPREFIX = "ref: refs/heads/"
GITCOMMAND = "git" GITCOMMAND = "git"
trueStr = "true"
) )
type Git struct { type Git struct {
@ -278,7 +280,7 @@ func (g *Git) shouldDisplay() bool {
} }
g.realDir = g.env.Pwd() g.realDir = g.env.Pwd()
bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository") bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository")
if bare == "true" { if bare == trueStr {
g.IsBare = true g.IsBare = true
g.workingDir = g.realDir g.workingDir = g.realDir
return true return true

View file

@ -165,7 +165,7 @@ func TestEnabledInBareRepo(t *testing.T) {
}{ }{
{ {
Case: "Bare repo on main", Case: "Bare repo on main",
IsBare: "true", IsBare: trueStr,
HEAD: "ref: refs/heads/main", HEAD: "ref: refs/heads/main",
ExpectedEnabled: true, ExpectedEnabled: true,
ExpectedHEAD: "main", ExpectedHEAD: "main",
@ -176,7 +176,7 @@ func TestEnabledInBareRepo(t *testing.T) {
}, },
{ {
Case: "Bare repo on main remote enabled", Case: "Bare repo on main remote enabled",
IsBare: "true", IsBare: trueStr,
HEAD: "ref: refs/heads/main", HEAD: "ref: refs/heads/main",
ExpectedEnabled: true, ExpectedEnabled: true,
ExpectedHEAD: "main", ExpectedHEAD: "main",