1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-07 22:02:56 +03: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 ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -16,12 +17,14 @@ import (
) )
func (gui *Gui) getCurrentBranch(path string) string { func (gui *Gui) getCurrentBranch(path string) string {
if branch, err := gui.os.Cmd.New( if headFile, err := ioutil.ReadFile(fmt.Sprintf("%s/.git/HEAD", path)); err == nil {
fmt.Sprintf("git -C %s rev-parse --abbrev-ref HEAD", gui.os.Quote(path)), content := strings.TrimSpace(string(headFile))
).DontLog().RunWithOutput(); err == nil { branch := strings.TrimPrefix(content, "ref: refs/heads/")
return strings.Trim(branch, "\n") 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 { func (gui *Gui) handleCreateRecentReposMenu() error {