mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-26 03:24:04 -08:00
refactor(git): fetch branch name from HEAD file
This commit is contained in:
parent
f6c79050d0
commit
dff3986258
|
@ -406,7 +406,12 @@ func (g *git) getGitRefFileSymbolicName(refFile string) string {
|
|||
}
|
||||
|
||||
func (g *git) getPrettyHEADName() string {
|
||||
ref := g.getGitCommandOutput("branch", "--show-current")
|
||||
var ref string
|
||||
HEAD := g.getGitFileContents("HEAD")
|
||||
branchPrefix := "ref: refs/heads/"
|
||||
if strings.HasPrefix(HEAD, branchPrefix) {
|
||||
ref = strings.TrimPrefix(HEAD, branchPrefix)
|
||||
}
|
||||
if ref != "" {
|
||||
ref = g.truncateBranch(ref)
|
||||
return fmt.Sprintf("%s%s", g.props.getString(BranchIcon, "\uE0A0"), ref)
|
||||
|
|
|
@ -105,6 +105,7 @@ func setupHEADContextEnv(context *detachedContext) *git {
|
|||
env.On("getFileContent", "/REVERT_HEAD").Return(context.revertSHA)
|
||||
env.On("getFileContent", "/MERGE_MSG").Return(fmt.Sprintf("Merge branch '%s' into %s", context.mergeHEAD, context.onto))
|
||||
env.On("getFileContent", "/sequencer/todo").Return(context.sequencerTodo)
|
||||
env.On("getFileContent", "/HEAD").Return(context.branchName)
|
||||
env.On("hasFilesInDir", "", "CHERRY_PICK_HEAD").Return(context.cherryPick)
|
||||
env.On("hasFilesInDir", "", "REVERT_HEAD").Return(context.revert)
|
||||
env.On("hasFilesInDir", "", "MERGE_MSG").Return(context.merge)
|
||||
|
|
Loading…
Reference in a new issue