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:
@@ -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 {
|
||||||
|
Reference in New Issue
Block a user