mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-15 13:17:53 -08:00
feat: git HEAD context
This commit is contained in:
parent
dabc9d4f20
commit
e0adc584e5
|
@ -47,6 +47,8 @@ const (
|
||||||
LocalStagingIcon Property = "local_staged_icon"
|
LocalStagingIcon Property = "local_staged_icon"
|
||||||
//DisplayStatus shows the status of the repository
|
//DisplayStatus shows the status of the repository
|
||||||
DisplayStatus Property = "display_status"
|
DisplayStatus Property = "display_status"
|
||||||
|
//RebaseIcon shows before the rebase context
|
||||||
|
RebaseIcon Property = "rebase_icon"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *git) enabled() bool {
|
func (g *git) enabled() bool {
|
||||||
|
@ -121,9 +123,17 @@ func (g *git) getGitOutputForCommand(args ...string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *git) getGitDetachedBranch() string {
|
func (g *git) getGitDetachedBranch() string {
|
||||||
ref := g.getGitOutputForCommand("symbolic-ref", "--short", "HEAD")
|
commit := g.getGitOutputForCommand("rev-parse", "--short", "HEAD")
|
||||||
|
rebase := g.getGitOutputForCommand("rebase", "--show-current-patch")
|
||||||
|
if rebase != "" {
|
||||||
|
return fmt.Sprintf("%s%s", g.props.getString(RebaseIcon, "REBASE: "), commit)
|
||||||
|
}
|
||||||
|
ref := g.getGitOutputForCommand("symbolic-ref", "-q", "--short", "HEAD")
|
||||||
if ref == "" {
|
if ref == "" {
|
||||||
return "unknown"
|
ref = g.getGitOutputForCommand("describe", "--tags", "--exact-match")
|
||||||
|
}
|
||||||
|
if ref == "" {
|
||||||
|
ref = commit
|
||||||
}
|
}
|
||||||
return ref
|
return ref
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,11 +138,11 @@ func TestParseGitBranchInfoBehindandAhead(t *testing.T) {
|
||||||
assert.Equal(t, "1", got["ahead"])
|
assert.Equal(t, "1", got["ahead"])
|
||||||
}
|
}
|
||||||
|
|
||||||
// func TestGetGitStatus(t *testing.T) {
|
func TestGetGitStatus(t *testing.T) {
|
||||||
// env := new(environment)
|
env := new(environment)
|
||||||
// writer := gitWriter{
|
git := git{
|
||||||
// env: env,
|
env: env,
|
||||||
// }
|
}
|
||||||
// writer.getGitStatus()
|
git.getGitStatus()
|
||||||
// assert.NotEmpty(t, writer.repo)
|
assert.NotEmpty(t, git.repo)
|
||||||
// }
|
}
|
||||||
|
|
Loading…
Reference in a new issue