mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
fix(git): resolve bare repo pointer
This commit is contained in:
parent
3fddcac9bf
commit
1c908a8ce6
|
@ -280,12 +280,7 @@ func (g *Git) shouldDisplay() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
gitdir, err := g.env.HasParentFilePath(".git", true)
|
||||
if err != nil {
|
||||
if !g.props.GetBool(FetchBareInfo, false) {
|
||||
return false
|
||||
}
|
||||
|
||||
if g.props.GetBool(FetchBareInfo, false) {
|
||||
g.realDir = g.env.Pwd()
|
||||
bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository")
|
||||
if bare == trueStr {
|
||||
|
@ -293,7 +288,10 @@ func (g *Git) shouldDisplay() bool {
|
|||
g.workingDir = g.realDir
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
gitdir, err := g.env.HasParentFilePath(".git", true)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -325,6 +323,13 @@ func (g *Git) setUser() {
|
|||
}
|
||||
|
||||
func (g *Git) getBareRepoInfo() {
|
||||
// we can still have a pointer to a bare repo
|
||||
if file, err := g.env.HasParentFilePath(".git", true); err == nil && !file.IsDir {
|
||||
content := g.FileContents(file.ParentFolder, ".git")
|
||||
path := strings.TrimPrefix(content, "gitdir: ")
|
||||
g.workingDir = filepath.Join(file.ParentFolder, path)
|
||||
}
|
||||
|
||||
head := g.FileContents(g.workingDir, "HEAD")
|
||||
branchIcon := g.props.GetString(BranchIcon, "\uE0A0")
|
||||
g.Ref = strings.Replace(head, "ref: refs/heads/", "", 1)
|
||||
|
@ -345,6 +350,7 @@ func (g *Git) setDir(dir string) {
|
|||
g.Dir = strings.TrimSuffix(dir, `\.git`)
|
||||
return
|
||||
}
|
||||
|
||||
g.Dir = strings.TrimSuffix(dir, "/.git")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue