mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-22 05:29:44 +02:00
simplify fetch
This commit is contained in:
parent
93729ba61b
commit
0d3e5e6a1d
@ -127,8 +127,9 @@ func (gui *Gui) handleGitFetch() error {
|
|||||||
if err := gui.createLoaderPanel(gui.Tr.FetchWait); err != nil {
|
if err := gui.createLoaderPanel(gui.Tr.FetchWait); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
go utils.Safe(func() {
|
go utils.Safe(func() {
|
||||||
err := gui.fetch(true, "Fetch")
|
err := gui.fetch()
|
||||||
gui.handleCredentialsPopup(err)
|
gui.handleCredentialsPopup(err)
|
||||||
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||||
})
|
})
|
||||||
|
@ -210,19 +210,15 @@ func (gui *Gui) handleMouseDownSecondary() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) fetch(canPromptForCredentials bool, action string) (err error) {
|
func (gui *Gui) fetch() (err error) {
|
||||||
gui.Mutexes.FetchMutex.Lock()
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
defer gui.Mutexes.FetchMutex.Unlock()
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
|
||||||
fetchOpts := commands.FetchOptions{}
|
gui.logAction("Fetch")
|
||||||
if canPromptForCredentials {
|
|
||||||
gui.logAction(action)
|
|
||||||
fetchOpts.PromptUserForCredential = gui.promptUserForCredential
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gui.GitCommand.Fetch(fetchOpts)
|
err = gui.GitCommand.Fetch(commands.FetchOptions{PromptUserForCredential: gui.promptUserForCredential})
|
||||||
|
|
||||||
if canPromptForCredentials && err != nil && strings.Contains(err.Error(), "exit status 128") {
|
if err != nil && strings.Contains(err.Error(), "exit status 128") {
|
||||||
_ = gui.createErrorPanel(gui.Tr.PassUnameWrong)
|
_ = gui.createErrorPanel(gui.Tr.PassUnameWrong)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,6 +227,17 @@ func (gui *Gui) fetch(canPromptForCredentials bool, action string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) backgroundFetch() (err error) {
|
||||||
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
|
||||||
|
err = gui.GitCommand.Fetch(commands.FetchOptions{})
|
||||||
|
|
||||||
|
_ = gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{BRANCHES, COMMITS, REMOTES, TAGS}, mode: ASYNC})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
|
func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
|
||||||
// important to note that this assumes we've selected an item in a side context
|
// important to note that this assumes we've selected an item in a side context
|
||||||
itemId := gui.getSideContextSelectedItemId()
|
itemId := gui.getSideContextSelectedItemId()
|
||||||
|
@ -718,7 +718,7 @@ func (gui *Gui) startBackgroundFetch() {
|
|||||||
if !isNew {
|
if !isNew {
|
||||||
time.After(time.Duration(userConfig.Refresher.FetchInterval) * time.Second)
|
time.After(time.Duration(userConfig.Refresher.FetchInterval) * time.Second)
|
||||||
}
|
}
|
||||||
err := gui.fetch(false, "")
|
err := gui.backgroundFetch()
|
||||||
if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew {
|
if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew {
|
||||||
_ = gui.ask(askOpts{
|
_ = gui.ask(askOpts{
|
||||||
title: gui.Tr.NoAutomaticGitFetchTitle,
|
title: gui.Tr.NoAutomaticGitFetchTitle,
|
||||||
@ -726,7 +726,7 @@ func (gui *Gui) startBackgroundFetch() {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
gui.goEvery(time.Second*time.Duration(userConfig.Refresher.FetchInterval), gui.stopChan, func() error {
|
gui.goEvery(time.Second*time.Duration(userConfig.Refresher.FetchInterval), gui.stopChan, func() error {
|
||||||
err := gui.fetch(false, "")
|
err := gui.backgroundFetch()
|
||||||
gui.render()
|
gui.render()
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user