summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-11 20:18:50 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-12 18:47:16 +1000
commit79e73d2effc3232122e1faa3b84d6e3953dbd3c7 (patch)
tree9d4c5c62acb2da4f5e5a1073b17ca96f129675b7
parent23299f88e9c5da84902cc872772333c4ab755946 (diff)
minor cleanup
WIP
-rw-r--r--pkg/gui/branches_panel.go4
-rw-r--r--pkg/gui/credentials_panel.go6
-rw-r--r--pkg/gui/files_panel.go14
-rw-r--r--pkg/gui/global_handlers.go6
-rw-r--r--pkg/gui/gui.go4
5 files changed, 16 insertions, 18 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index d42d3512c..3317a8ff4 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -129,8 +129,8 @@ func (gui *Gui) handleGitFetch(g *gocui.Gui, v *gocui.View) error {
return err
}
go func() {
- unamePassOpend, err := gui.fetch(g, v, true)
- gui.HandleCredentialsPopup(g, unamePassOpend, err)
+ err := gui.fetch(g, v, true)
+ gui.HandleCredentialsPopup(g, err)
}()
return nil
}
diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go
index e1b918e56..37565e155 100644
--- a/pkg/gui/credentials_panel.go
+++ b/pkg/gui/credentials_panel.go
@@ -77,10 +77,8 @@ func (gui *Gui) handleCredentialsViewFocused(g *gocui.Gui, v *gocui.View) error
}
// HandleCredentialsPopup handles the views after executing a command that might ask for credentials
-func (gui *Gui) HandleCredentialsPopup(g *gocui.Gui, popupOpened bool, cmdErr error) {
- if popupOpened {
- _, _ = gui.g.SetViewOnBottom("credentials")
- }
+func (gui *Gui) HandleCredentialsPopup(g *gocui.Gui, cmdErr error) {
+ _, _ = gui.g.SetViewOnBottom("credentials")
if cmdErr != nil {
errMessage := cmdErr.Error()
if strings.Contains(errMessage, "Invalid username or password") {
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 0c6d2c9f3..f2bbb27c4 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -471,13 +471,17 @@ func (gui *Gui) pullFiles(v *gocui.View, args string) error {
return err
}
+ // we want to first fetch, handling username if it comes up, then either merge or rebase. If merging we might have a merge conflict, likewise if rebasing we might have a conflict too.
+ // we need a way of saying .then or .catch
+
+ // what if we had a struct which contained an array of functions to run, each of which return a function, or perhaps write to a channel when they're done, and if there is no error, we run the next thing. In this case we first want to fetch, potentially handling a credential popup, then we want to rebase.
+
go func() {
- unamePassOpend := false
err := gui.GitCommand.Pull(args, func(passOrUname string) string {
- unamePassOpend = true
return gui.waitForPassUname(gui.g, v, passOrUname)
})
- gui.HandleCredentialsPopup(gui.g, unamePassOpend, err)
+ // gui.handleGenericMergeCommandResult(err)
+ gui.HandleCredentialsPopup(gui.g, err)
}()
return nil
@@ -488,13 +492,11 @@ func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstr
return err
}
go func() {
- unamePassOpend := false
branchName := gui.getCheckedOutBranch().Name
err := gui.GitCommand.Push(branchName, force, upstream, args, func(passOrUname string) string {
- unamePassOpend = true
return gui.waitForPassUname(g, v, passOrUname)
})
- gui.HandleCredentialsPopup(g, unamePassOpend, err)
+ gui.HandleCredentialsPopup(g, err)
}()
return nil
}
diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go
index d1947eff1..d46e4ab75 100644
--- a/pkg/gui/global_handlers.go
+++ b/pkg/gui/global_handlers.go
@@ -166,10 +166,8 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error {
return nil
}
-func (gui *Gui) fetch(g *gocui.Gui, v *gocui.View, canAskForCredentials bool) (unamePassOpend bool, err error) {
- unamePassOpend = false
+func (gui *Gui) fetch(g *gocui.Gui, v *gocui.View, canAskForCredentials bool) (err error) {
err = gui.GitCommand.Fetch(func(passOrUname string) string {
- unamePassOpend = true
return gui.waitForPassUname(gui.g, v, passOrUname)
}, canAskForCredentials)
@@ -184,5 +182,5 @@ func (gui *Gui) fetch(g *gocui.Gui, v *gocui.View, canAskForCredentials bool) (u
gui.refreshSidePanels(refreshOptions{scope: []int{BRANCHES, COMMITS, REMOTES, TAGS}, mode: ASYNC})
- return unamePassOpend, err
+ return err
}
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 735a5465e..0d039de0b 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -501,12 +501,12 @@ func (gui *Gui) startBackgroundFetch() {
if !isNew {
time.After(60 * time.Second)
}
- _, err := gui.fetch(gui.g, gui.g.CurrentView(), false)
+ err := gui.fetch(gui.g, gui.g.CurrentView(), false)
if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew {
_ = gui.createConfirmationPanel(gui.g, gui.g.CurrentView(), true, gui.Tr.SLocalize("NoAutomaticGitFetchTitle"), gui.Tr.SLocalize("NoAutomaticGitFetchBody"), nil, nil)
} else {
gui.goEvery(time.Second*60, gui.stopChan, func() error {
- _, err := gui.fetch(gui.g, gui.g.CurrentView(), false)
+ err := gui.fetch(gui.g, gui.g.CurrentView(), false)
return err
})
}