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)"
BRANCHPREFIX = "ref: refs/heads/"
GITCOMMAND = "git"
trueStr = "true"
)
type Git struct {
@ -278,7 +280,7 @@ func (g *Git) shouldDisplay() bool {
}
g.realDir = g.env.Pwd()
bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository")
if bare == "true" {
if bare == trueStr {
g.IsBare = true
g.workingDir = g.realDir
return true

View file

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