diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-11 23:22:09 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-11 23:30:30 +1100 |
commit | 12b84307acd67c93122d1fb971effb9700524592 (patch) | |
tree | 8ba62a274804a85c78898fa11dd2e6797893b9bc /pkg/gui | |
parent | 6843741d9e86bee57c96023a0c66e08cd43b3474 (diff) |
specify upstream when pushing a branch for the first timev0.10.4
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/branches_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/confirmation_panel.go | 7 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 24 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 2 |
5 files changed, 25 insertions, 14 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 5cf440909..23aa17a26 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -207,7 +207,7 @@ func (gui *Gui) handleCheckoutBranch(branchName string) error { } func (gui *Gui) handleCheckoutByName(g *gocui.Gui, v *gocui.View) error { - gui.createPromptPanel(g, v, gui.Tr.SLocalize("BranchName")+":", func(g *gocui.Gui, v *gocui.View) error { + gui.createPromptPanel(g, v, gui.Tr.SLocalize("BranchName")+":", "", func(g *gocui.Gui, v *gocui.View) error { return gui.handleCheckoutBranch(gui.trimmedContent(v)) }) return nil @@ -221,7 +221,7 @@ func (gui *Gui) handleNewBranch(g *gocui.Gui, v *gocui.View) error { "branchName": branch.Name, }, ) - gui.createPromptPanel(g, v, message, func(g *gocui.Gui, v *gocui.View) error { + gui.createPromptPanel(g, v, message, "", func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.NewBranch(gui.trimmedContent(v)); err != nil { return gui.createErrorPanel(g, err.Error()) } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index d58e89ebf..a20c52f45 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -237,7 +237,7 @@ func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error { if gui.State.Panels.Commits.SelectedLine != 0 { return gui.createErrorPanel(g, gui.Tr.SLocalize("OnlyRenameTopCommit")) } - return gui.createPromptPanel(g, v, gui.Tr.SLocalize("renameCommit"), func(g *gocui.Gui, v *gocui.View) error { + return gui.createPromptPanel(g, v, gui.Tr.SLocalize("renameCommit"), "", func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.RenameCommit(v.Buffer()); err != nil { return gui.createErrorPanel(g, err.Error()) } diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 6913400a1..f9e2dbfbd 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -64,13 +64,16 @@ func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt s height/2 + panelHeight/2 } -func (gui *Gui) createPromptPanel(g *gocui.Gui, currentView *gocui.View, title string, handleConfirm func(*gocui.Gui, *gocui.View) error) error { +func (gui *Gui) createPromptPanel(g *gocui.Gui, currentView *gocui.View, title string, initialContent string, handleConfirm func(*gocui.Gui, *gocui.View) error) error { gui.onNewPopupPanel() - confirmationView, err := gui.prepareConfirmationPanel(currentView, title, "", false) + confirmationView, err := gui.prepareConfirmationPanel(currentView, title, initialContent, false) if err != nil { return err } confirmationView.Editable = true + if err := gui.renderString(g, "confirmation", initialContent); err != nil { + return err + } // in the future we might want to give createPromptPanel the returnFocusOnClose arg too, but for now we're always setting it to true return gui.setKeyBindings(g, handleConfirm, nil, true) } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index ba5c56db2..034860115 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -424,14 +424,14 @@ func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error { return nil } -func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool) error { +func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstream string) error { if err := gui.createLoaderPanel(gui.g, v, gui.Tr.SLocalize("PushWait")); err != nil { return err } go func() { unamePassOpend := false branchName := gui.State.Branches[0].Name - err := gui.GitCommand.Push(branchName, force, func(passOrUname string) string { + err := gui.GitCommand.Push(branchName, force, upstream, func(passOrUname string) string { unamePassOpend = true return gui.waitForPassUname(g, v, passOrUname) }) @@ -443,13 +443,21 @@ func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool) error func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error { // if we have pullables we'll ask if the user wants to force push _, pullables := gui.GitCommand.GetCurrentBranchUpstreamDifferenceCount() - if pullables == "?" || pullables == "0" { - return gui.pushWithForceFlag(g, v, false) + currentBranchName, err := gui.GitCommand.CurrentBranchName() + if err != nil { + return err + } + + if pullables == "?" { + return gui.createPromptPanel(g, v, gui.Tr.SLocalize("EnterUpstream"), "origin "+currentBranchName, func(g *gocui.Gui, v *gocui.View) error { + return gui.pushWithForceFlag(g, v, false, gui.trimmedContent(v)) + }) + } else if pullables == "0" { + return gui.pushWithForceFlag(g, v, false, "") } - err := gui.createConfirmationPanel(g, nil, true, gui.Tr.SLocalize("ForcePush"), gui.Tr.SLocalize("ForcePushPrompt"), func(g *gocui.Gui, v *gocui.View) error { - return gui.pushWithForceFlag(g, v, true) + return gui.createConfirmationPanel(g, nil, true, gui.Tr.SLocalize("ForcePush"), gui.Tr.SLocalize("ForcePushPrompt"), func(g *gocui.Gui, v *gocui.View) error { + return gui.pushWithForceFlag(g, v, true, "") }, nil) - return err } func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error { @@ -626,7 +634,7 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error { - return gui.createPromptPanel(g, v, gui.Tr.SLocalize("CustomCommand"), func(g *gocui.Gui, v *gocui.View) error { + return gui.createPromptPanel(g, v, gui.Tr.SLocalize("CustomCommand"), "", func(g *gocui.Gui, v *gocui.View) error { command := gui.trimmedContent(v) gui.SubProcess = gui.OSCommand.RunCustomCommand(command) return gui.Errors.ErrSubProcess diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index 4ed35489d..055a4773d 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -139,7 +139,7 @@ func (gui *Gui) handleStashSave(stashFunc func(message string) error) error { if len(gui.trackedFiles()) == 0 && len(gui.stagedFiles()) == 0 { return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("NoTrackedStagedFilesStash")) } - return gui.createPromptPanel(gui.g, gui.getFilesView(), gui.Tr.SLocalize("StashChanges"), func(g *gocui.Gui, v *gocui.View) error { + return gui.createPromptPanel(gui.g, gui.getFilesView(), gui.Tr.SLocalize("StashChanges"), "", func(g *gocui.Gui, v *gocui.View) error { if err := stashFunc(gui.trimmedContent(v)); err != nil { gui.createErrorPanel(g, err.Error()) } |