1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

Gotta go fast

This commit is contained in:
Luka Markušić 2022-07-30 17:28:07 +02:00
parent 7c09ce3871
commit 25ddac0d8f

View File

@ -2,6 +2,7 @@ package gui
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -16,12 +17,14 @@ import (
)
func (gui *Gui) getCurrentBranch(path string) string {
if branch, err := gui.os.Cmd.New(
fmt.Sprintf("git -C %s rev-parse --abbrev-ref HEAD", gui.os.Quote(path)),
).DontLog().RunWithOutput(); err == nil {
return strings.Trim(branch, "\n")
if headFile, err := ioutil.ReadFile(fmt.Sprintf("%s/.git/HEAD", path)); err == nil {
content := strings.TrimSpace(string(headFile))
branch := strings.TrimPrefix(content, "ref: refs/heads/")
return branch
}
return ""
// worktrees don't have `.git/HEAD`
// and detached HEAD repos have only a hash in `.git/HEAD`
return "HEAD"
}
func (gui *Gui) handleCreateRecentReposMenu() error {