mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-29 04:49: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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
gitdir, err := g.env.HasParentFilePath(".git", true)
|
if g.props.GetBool(FetchBareInfo, false) {
|
||||||
if err != nil {
|
|
||||||
if !g.props.GetBool(FetchBareInfo, false) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
g.realDir = g.env.Pwd()
|
g.realDir = g.env.Pwd()
|
||||||
bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository")
|
bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository")
|
||||||
if bare == trueStr {
|
if bare == trueStr {
|
||||||
|
@ -293,7 +288,10 @@ func (g *Git) shouldDisplay() bool {
|
||||||
g.workingDir = g.realDir
|
g.workingDir = g.realDir
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gitdir, err := g.env.HasParentFilePath(".git", true)
|
||||||
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,6 +323,13 @@ func (g *Git) setUser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Git) getBareRepoInfo() {
|
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")
|
head := g.FileContents(g.workingDir, "HEAD")
|
||||||
branchIcon := g.props.GetString(BranchIcon, "\uE0A0")
|
branchIcon := g.props.GetString(BranchIcon, "\uE0A0")
|
||||||
g.Ref = strings.Replace(head, "ref: refs/heads/", "", 1)
|
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`)
|
g.Dir = strings.TrimSuffix(dir, `\.git`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
g.Dir = strings.TrimSuffix(dir, "/.git")
|
g.Dir = strings.TrimSuffix(dir, "/.git")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue