mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-29 23:17:32 +02:00
Parallelize fetching current branch
This commit is contained in:
parent
e6e4513f45
commit
7c09ce3871
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/jesseduffield/generics/slices"
|
"github.com/jesseduffield/generics/slices"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
@ -27,10 +28,24 @@ func (gui *Gui) handleCreateRecentReposMenu() error {
|
|||||||
// we skip the first one because we're currently in it
|
// we skip the first one because we're currently in it
|
||||||
recentRepoPaths := gui.c.GetAppState().RecentRepos[1:]
|
recentRepoPaths := gui.c.GetAppState().RecentRepos[1:]
|
||||||
|
|
||||||
|
currentBranches := sync.Map{}
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(len(recentRepoPaths))
|
||||||
|
|
||||||
|
for _, path := range recentRepoPaths {
|
||||||
|
go func(path string) {
|
||||||
|
defer wg.Done()
|
||||||
|
currentBranches.Store(path, gui.getCurrentBranch(path))
|
||||||
|
}(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
menuItems := slices.Map(recentRepoPaths, func(path string) *types.MenuItem {
|
menuItems := slices.Map(recentRepoPaths, func(path string) *types.MenuItem {
|
||||||
branchName, _ := currentBranches.Load(path)
|
branchName, _ := currentBranches.Load(path)
|
||||||
if icons.IsIconEnabled() {
|
if icons.IsIconEnabled() {
|
||||||
branchName = icons.BRANCH_ICON + " " + branchName
|
branchName = icons.BRANCH_ICON + " " + fmt.Sprintf("%v", branchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user