Skip to content

Commit

Permalink
allow fastforwarding the current branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Feb 18, 2020
1 parent 0f0da9c commit 66e6369
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/commands/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ func (c *GitCommand) Pull(args string, ask func(string) string) error {
return c.OSCommand.DetectUnamePass("git pull --no-edit "+args, ask)
}

// PullWithoutPasswordCheck assumes that the pull will not prompt the user for a password
func (c *GitCommand) PullWithoutPasswordCheck(args string) error {
return c.OSCommand.RunCommand("git pull --no-edit " + args)
}

// Push pushes to a branch
func (c *GitCommand) Push(branchName string, force bool, upstream string, args string, ask func(string) string) error {
forceFlag := ""
Expand Down
13 changes: 10 additions & 3 deletions pkg/gui/branches_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,19 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
go func() {
_ = gui.createLoaderPanel(gui.g, v, message)

if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil {
_ = gui.createErrorPanel(gui.g, err.Error())
if gui.State.Panels.Branches.SelectedLine == 0 {
if err := gui.GitCommand.PullWithoutPasswordCheck("--ff-only"); err != nil {
_ = gui.createErrorPanel(gui.g, err.Error())
}
_ = gui.refreshSidePanels(gui.g)
} else {
_ = gui.closeConfirmationPrompt(gui.g, true)
if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil {
_ = gui.createErrorPanel(gui.g, err.Error())
}
_ = gui.RenderSelectedBranchUpstreamDifferences()
}

_ = gui.closeConfirmationPrompt(gui.g, true)
}()
return nil
}
Expand Down

0 comments on commit 66e6369

Please sign in to comment.