mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
revert to using the direct git command for getting the current branch because it breaks if you've just done a git init
This commit is contained in:
parent
eb9f01ecfa
commit
95b7c1d0a4
1 changed files with 10 additions and 10 deletions
|
@ -22,13 +22,10 @@ func newBranchListBuilder() *branchListBuilder {
|
|||
}
|
||||
|
||||
func (b *branchListBuilder) obtainCurrentBranch() Branch {
|
||||
// Using git-go whenever possible
|
||||
head, err := r.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
name := head.Name().Short()
|
||||
return Branch{Name: name, Recency: " *"}
|
||||
// I used go-git for this, but that breaks if you've just done a git init,
|
||||
// even though you're on 'master'
|
||||
branchName, _ := runDirectCommand("git symbolic-ref --short HEAD")
|
||||
return Branch{Name: strings.TrimSpace(branchName), Recency: " *"}
|
||||
}
|
||||
|
||||
func (*branchListBuilder) obtainReflogBranches() []Branch {
|
||||
|
@ -77,12 +74,15 @@ func (b *branchListBuilder) appendNewBranches(finalBranches, newBranches, existi
|
|||
func (b *branchListBuilder) build() []Branch {
|
||||
branches := make([]Branch, 0)
|
||||
head := b.obtainCurrentBranch()
|
||||
validBranches := b.obtainSafeBranches()
|
||||
safeBranches := b.obtainSafeBranches()
|
||||
if len(safeBranches) == 0 {
|
||||
return append(branches, head)
|
||||
}
|
||||
reflogBranches := b.obtainReflogBranches()
|
||||
reflogBranches = uniqueByName(append([]Branch{head}, reflogBranches...))
|
||||
|
||||
branches = b.appendNewBranches(branches, reflogBranches, validBranches, true)
|
||||
branches = b.appendNewBranches(branches, validBranches, branches, false)
|
||||
branches = b.appendNewBranches(branches, reflogBranches, safeBranches, true)
|
||||
branches = b.appendNewBranches(branches, safeBranches, branches, false)
|
||||
|
||||
return branches
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue