Skip to content

Commit

Permalink
allow applying patch directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Mar 26, 2020
1 parent 83757f1 commit 95b1470
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/gui/patch_options_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error
displayString: "pull patch out into index",
onPress: gui.handlePullPatchIntoWorkingTree,
},
{
displayString: "apply patch",
onPress: gui.handleApplyPatch,
},
{
displayString: "reset patch",
onPress: gui.handleResetPatch,
Expand Down Expand Up @@ -116,6 +120,17 @@ func (gui *Gui) handlePullPatchIntoWorkingTree() error {
})
}

func (gui *Gui) handleApplyPatch() error {
if err := gui.returnFocusFromLineByLinePanelIfNecessary(); err != nil {
return err
}

if err := gui.GitCommand.PatchManager.ApplyPatches(false); err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}
return gui.refreshSidePanels(gui.g)
}

func (gui *Gui) handleResetPatch() error {
gui.GitCommand.PatchManager.Reset()
return gui.refreshCommitFilesView()
Expand Down

0 comments on commit 95b1470

Please sign in to comment.