1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

simplify fetch

This commit is contained in:
Jesse Duffield
2022-01-06 22:05:18 +11:00
parent 93729ba61b
commit 0d3e5e6a1d
3 changed files with 19 additions and 11 deletions

View File

@ -210,19 +210,15 @@ func (gui *Gui) handleMouseDownSecondary() error {
return nil
}
func (gui *Gui) fetch(canPromptForCredentials bool, action string) (err error) {
func (gui *Gui) fetch() (err error) {
gui.Mutexes.FetchMutex.Lock()
defer gui.Mutexes.FetchMutex.Unlock()
fetchOpts := commands.FetchOptions{}
if canPromptForCredentials {
gui.logAction(action)
fetchOpts.PromptUserForCredential = gui.promptUserForCredential
}
gui.logAction("Fetch")
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)
}
@ -231,6 +227,17 @@ func (gui *Gui) fetch(canPromptForCredentials bool, action string) (err error) {
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 {
// important to note that this assumes we've selected an item in a side context
itemId := gui.getSideContextSelectedItemId()