1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-23 22:24:51 +02:00

Trigger background fetch on repo switch only if enough time has passed since the last one

This commit is contained in:
Stefan Haller
2025-11-16 13:15:31 +01:00
parent d45f27b6ee
commit 2af56de5d2
2 changed files with 16 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ import (
"sort"
"strings"
"sync"
"time"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazycore/pkg/boxlayout"
@@ -253,6 +254,8 @@ type GuiRepoState struct {
ScreenMode types.ScreenMode
CurrentPopupOpts *types.CreatePopupPanelOpts
LastBackgroundFetchTime time.Time
}
var _ types.IRepoStateAccessor = new(GuiRepoState)
@@ -308,7 +311,9 @@ func (self *GuiRepoState) GetSplitMainPanel() bool {
func (gui *Gui) onSwitchToNewRepo(startArgs appTypes.StartArgs, contextKey types.ContextKey) error {
err := gui.onNewRepo(startArgs, contextKey)
if err == nil && gui.UserConfig().Git.AutoFetch && gui.UserConfig().Refresher.FetchInterval > 0 {
gui.BackgroundRoutineMgr.triggerImmediateFetch()
if time.Since(gui.State.LastBackgroundFetchTime) > gui.UserConfig().Refresher.FetchIntervalDuration() {
gui.BackgroundRoutineMgr.triggerImmediateFetch()
}
}
return err
}