mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-06 23:46:13 +02:00
configurable auto-fetch
This commit is contained in:
parent
1c704e11f2
commit
8f786e3fd9
@ -249,6 +249,7 @@ func GetDefaultConfig() []byte {
|
|||||||
merging:
|
merging:
|
||||||
manualCommit: false
|
manualCommit: false
|
||||||
skipHookPrefix: 'WIP'
|
skipHookPrefix: 'WIP'
|
||||||
|
autoFetch: true
|
||||||
update:
|
update:
|
||||||
method: prompt # can be: prompt | background | never
|
method: prompt # can be: prompt | background | never
|
||||||
days: 14 # how often a update is checked for
|
days: 14 # how often a update is checked for
|
||||||
|
@ -619,6 +619,25 @@ func (gui *Gui) goEvery(interval time.Duration, function func() error) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) startBackgroundFetch() error {
|
||||||
|
g := gui.g
|
||||||
|
gui.waitForIntro.Wait()
|
||||||
|
isNew := gui.Config.GetIsNewRepo()
|
||||||
|
if !isNew {
|
||||||
|
time.After(60 * time.Second)
|
||||||
|
}
|
||||||
|
_, err := gui.fetch(g, g.CurrentView(), false)
|
||||||
|
if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew {
|
||||||
|
_ = gui.createConfirmationPanel(g, g.CurrentView(), gui.Tr.SLocalize("NoAutomaticGitFetchTitle"), gui.Tr.SLocalize("NoAutomaticGitFetchBody"), nil, nil)
|
||||||
|
} else {
|
||||||
|
gui.goEvery(time.Second*60, func() error {
|
||||||
|
_, err := gui.fetch(gui.g, gui.g.CurrentView(), false)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Run setup the gui with keybindings and start the mainloop
|
// Run setup the gui with keybindings and start the mainloop
|
||||||
func (gui *Gui) Run() error {
|
func (gui *Gui) Run() error {
|
||||||
g, err := gocui.NewGui(gocui.OutputNormal, OverlappingEdges)
|
g, err := gocui.NewGui(gocui.OutputNormal, OverlappingEdges)
|
||||||
@ -643,22 +662,9 @@ func (gui *Gui) Run() error {
|
|||||||
gui.waitForIntro.Add(1)
|
gui.waitForIntro.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
if gui.Config.GetUserConfig().GetBool("gui.git.autoFetch") {
|
||||||
gui.waitForIntro.Wait()
|
go gui.startBackgroundFetch()
|
||||||
isNew := gui.Config.GetIsNewRepo()
|
}
|
||||||
if !isNew {
|
|
||||||
time.After(60 * time.Second)
|
|
||||||
}
|
|
||||||
_, err := gui.fetch(g, g.CurrentView(), false)
|
|
||||||
if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew {
|
|
||||||
_ = gui.createConfirmationPanel(g, g.CurrentView(), gui.Tr.SLocalize("NoAutomaticGitFetchTitle"), gui.Tr.SLocalize("NoAutomaticGitFetchBody"), nil, nil)
|
|
||||||
} else {
|
|
||||||
gui.goEvery(time.Second*60, func() error {
|
|
||||||
_, err := gui.fetch(gui.g, gui.g.CurrentView(), false)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
gui.goEvery(time.Second*10, gui.refreshFiles)
|
gui.goEvery(time.Second*10, gui.refreshFiles)
|
||||||
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
|
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user