mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Collect the current branches of the recent repos in a slice
Nothing needs to look up the branch of a repo by its path, so a slice indexed like the list of paths does the job, and its elements are plain strings instead of the values of type "any" that a sync.Map hands back. The next commits measure and truncate the branch name, which needs a string. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c07f4d381b
commit
1e1d8a8fcd
|
|
@ -2,7 +2,6 @@ package helpers
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -112,24 +111,24 @@ func (self *ReposHelper) CreateRecentReposMenu() error {
|
|||
recentRepoPaths = self.c.GetAppState().RecentRepos[1:]
|
||||
}
|
||||
|
||||
currentBranches := sync.Map{}
|
||||
currentBranches := make([]string, len(recentRepoPaths))
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(recentRepoPaths))
|
||||
|
||||
for _, path := range recentRepoPaths {
|
||||
go func(path string) {
|
||||
for i, path := range recentRepoPaths {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
currentBranches.Store(path, self.getCurrentBranch(path))
|
||||
}(path)
|
||||
currentBranches[i] = self.getCurrentBranch(path)
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
menuItems := lo.Map(recentRepoPaths, func(path string, _ int) *types.MenuItem {
|
||||
branchName, _ := currentBranches.Load(path)
|
||||
menuItems := lo.Map(recentRepoPaths, func(path string, i int) *types.MenuItem {
|
||||
branchName := currentBranches[i]
|
||||
if icons.IsIconEnabled() {
|
||||
branchName = icons.BRANCH_ICON + " " + fmt.Sprintf("%v", branchName)
|
||||
branchName = icons.BRANCH_ICON + " " + branchName
|
||||
}
|
||||
|
||||
return &types.MenuItem{
|
||||
|
|
|
|||
Loading…
Reference in a new issue