mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -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
|
// we didn't fetch status, fallback to parsing the HEAD file
|
||||||
if len(g.ShortHash) == 0 {
|
if len(g.ShortHash) == 0 {
|
||||||
HEADRef := g.FileContents(g.workingDir, "HEAD")
|
HEADRef := g.FileContents(g.workingDir, "HEAD")
|
||||||
|
g.Detached = !strings.HasPrefix(HEADRef, "ref:")
|
||||||
if strings.HasPrefix(HEADRef, BRANCHPREFIX) {
|
if strings.HasPrefix(HEADRef, BRANCHPREFIX) {
|
||||||
branchName := strings.TrimPrefix(HEADRef, BRANCHPREFIX)
|
branchName := strings.TrimPrefix(HEADRef, BRANCHPREFIX)
|
||||||
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(BranchIcon, "\uE0A0"), g.formatHEAD(branchName))
|
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:]
|
g.Hash = HEADRef[0:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for tag
|
// check for tag
|
||||||
tagName := g.getGitCommandOutput("describe", "--tags", "--exact-match")
|
tagName := g.getGitCommandOutput("describe", "--tags", "--exact-match")
|
||||||
if len(tagName) > 0 {
|
if len(tagName) > 0 {
|
||||||
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(TagIcon, "\uF412"), tagName)
|
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(TagIcon, "\uF412"), tagName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback to commit
|
// fallback to commit
|
||||||
if len(g.ShortHash) == 0 {
|
if len(g.ShortHash) == 0 {
|
||||||
g.HEAD = g.props.GetString(NoCommitsIcon, "\uF594 ")
|
g.HEAD = g.props.GetString(NoCommitsIcon, "\uF594 ")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(CommitIcon, "\uF417"), g.ShortHash)
|
g.HEAD = fmt.Sprintf("%s%s", g.props.GetString(CommitIcon, "\uF417"), g.ShortHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue