summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/branches_panel.go3
-rw-r--r--pkg/gui/global_handlers.go23
-rw-r--r--pkg/gui/gui.go4
3 files changed, 19 insertions, 11 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 7481104cf..dbb2ae8da 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -127,8 +127,9 @@ func (gui *Gui) handleGitFetch() error {
if err := gui.createLoaderPanel(gui.Tr.FetchWait); err != nil {
return err
}
+
go utils.Safe(func() {
- err := gui.fetch(true, "Fetch")
+ err := gui.fetch()
gui.handleCredentialsPopup(err)
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC})
})
diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go
index 8b437e6e0..68f2b6402 100644
--- a/pkg/gui/global_handlers.go
+++ b/pkg/gui/global_handlers.go
@@ -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()
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 456a62a6c..9b4279f29 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -718,7 +718,7 @@ func (gui *Gui) startBackgroundFetch() {
if !isNew {
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 {
_ = gui.ask(askOpts{
title: gui.Tr.NoAutomaticGitFetchTitle,
@@ -726,7 +726,7 @@ func (gui *Gui) startBackgroundFetch() {
})
} else {
gui.goEvery(time.Second*time.Duration(userConfig.Refresher.FetchInterval), gui.stopChan, func() error {
- err := gui.fetch(false, "")
+ err := gui.backgroundFetch()
gui.render()
return err
})