mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
fix(git): set Detached on when fetch_status is false
This commit is contained in:
parent
f24ddbdfca
commit
4cf65fddfb
|
@ -735,6 +735,7 @@ func (g *Git) setPrettyHEADName() {
|
|||
// we didn't fetch status, fallback to parsing the HEAD file
|
||||
if len(g.ShortHash) == 0 {
|
||||
HEADRef := g.FileContents(g.workingDir, "HEAD")
|
||||
g.Detached = !strings.HasPrefix(HEADRef, "ref:")
|
||||
if strings.HasPrefix(HEADRef, BRANCHPREFIX) {
|
||||
branchName := strings.TrimPrefix(HEADRef, BRANCHPREFIX)
|
||||
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(BranchIcon, "\uE0A0"), g.formatHEAD(branchName))
|
||||
|
@ -746,17 +747,20 @@ func (g *Git) setPrettyHEADName() {
|
|||
g.Hash = HEADRef[0:]
|
||||
}
|
||||
}
|
||||
|
||||
// check for tag
|
||||
tagName := g.getGitCommandOutput("describe", "--tags", "--exact-match")
|
||||
if len(tagName) > 0 {
|
||||
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(TagIcon, "\uF412"), tagName)
|
||||
return
|
||||
}
|
||||
|
||||
// fallback to commit
|
||||
if len(g.ShortHash) == 0 {
|
||||
g.HEAD = g.props.GetString(NoCommitsIcon, "\uF594 ")
|
||||
return
|
||||
}
|
||||
|
||||
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(CommitIcon, "\uF417"), g.ShortHash)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue