summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/commit_files_panel.go20
-rw-r--r--pkg/gui/patch_building_panel.go4
-rw-r--r--pkg/gui/patch_options_panel.go9
3 files changed, 16 insertions, 17 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 0141e25b8..c0cab24cb 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -136,8 +136,8 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
}
toggleTheFile := func() error {
- if gui.GitCommand.PatchManager == nil {
- if err := gui.createPatchManager(); err != nil {
+ if gui.GitCommand.PatchManager.IsEmpty() {
+ if err := gui.startPatchManager(); err != nil {
return err
}
}
@@ -147,9 +147,9 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
return gui.refreshCommitFilesView()
}
- if gui.GitCommand.PatchManager != nil && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha {
+ if !gui.GitCommand.PatchManager.IsEmpty() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha {
return gui.createConfirmationPanel(g, v, true, gui.Tr.SLocalize("DiscardPatch"), gui.Tr.SLocalize("DiscardPatchConfirm"), func(g *gocui.Gui, v *gocui.View) error {
- gui.GitCommand.PatchManager = nil
+ gui.GitCommand.PatchManager.Reset()
return toggleTheFile()
}, nil)
}
@@ -157,7 +157,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
return toggleTheFile()
}
-func (gui *Gui) createPatchManager() error {
+func (gui *Gui) startPatchManager() error {
diffMap := map[string]string{}
for _, commitFile := range gui.State.CommitFiles {
commitText, err := gui.GitCommand.ShowCommitFile(commitFile.Sha, commitFile.Name, true)
@@ -172,7 +172,7 @@ func (gui *Gui) createPatchManager() error {
return errors.New("No commit selected")
}
- gui.GitCommand.PatchManager = commands.NewPatchManager(gui.Log, gui.GitCommand.ApplyPatch, commit.Sha, diffMap)
+ gui.GitCommand.PatchManager.Start(commit.Sha, diffMap)
return nil
}
@@ -187,8 +187,8 @@ func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error {
}
enterTheFile := func() error {
- if gui.GitCommand.PatchManager == nil {
- if err := gui.createPatchManager(); err != nil {
+ if gui.GitCommand.PatchManager.IsEmpty() {
+ if err := gui.startPatchManager(); err != nil {
return err
}
}
@@ -202,9 +202,9 @@ func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error {
return gui.refreshPatchBuildingPanel()
}
- if gui.GitCommand.PatchManager != nil && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha {
+ if !gui.GitCommand.PatchManager.IsEmpty() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha {
return gui.createConfirmationPanel(g, v, false, gui.Tr.SLocalize("DiscardPatch"), gui.Tr.SLocalize("DiscardPatchConfirm"), func(g *gocui.Gui, v *gocui.View) error {
- gui.GitCommand.PatchManager = nil
+ gui.GitCommand.PatchManager.Reset()
return enterTheFile()
}, nil)
}
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go
index b32253557..26196f6d1 100644
--- a/pkg/gui/patch_building_panel.go
+++ b/pkg/gui/patch_building_panel.go
@@ -5,7 +5,7 @@ import (
)
func (gui *Gui) refreshPatchBuildingPanel() error {
- if gui.GitCommand.PatchManager == nil {
+ if gui.GitCommand.PatchManager.IsEmpty() {
return gui.handleEscapePatchBuildingPanel(gui.g, nil)
}
@@ -91,7 +91,7 @@ func (gui *Gui) handleEscapePatchBuildingPanel(g *gocui.Gui, v *gocui.View) erro
}
func (gui *Gui) refreshSecondaryPatchPanel() error {
- if gui.GitCommand.PatchManager != nil {
+ if !gui.GitCommand.PatchManager.IsEmpty() {
gui.State.SplitMainPanel = true
secondaryView := gui.getSecondaryView()
secondaryView.Highlight = true
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go
index a966040e2..748f70365 100644
--- a/pkg/gui/patch_options_panel.go
+++ b/pkg/gui/patch_options_panel.go
@@ -17,15 +17,14 @@ func (o *patchMenuOption) GetDisplayStrings(isFocused bool) []string {
}
func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error {
- m := gui.GitCommand.PatchManager
- if m == nil {
+ if gui.GitCommand.PatchManager.IsEmpty() {
return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("NoPatchError"))
}
options := []*patchMenuOption{
{displayName: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.CommitSha), function: gui.handleDeletePatchFromCommit},
{displayName: "pull patch out into index", function: gui.handlePullPatchIntoWorkingTree},
- {displayName: "reset patch", function: gui.handleClearPatch},
+ {displayName: "reset patch", function: gui.handleResetPatch},
}
selectedCommit := gui.getSelectedCommit(gui.g)
@@ -122,7 +121,7 @@ func (gui *Gui) handlePullPatchIntoWorkingTree() error {
})
}
-func (gui *Gui) handleClearPatch() error {
- gui.GitCommand.PatchManager = nil
+func (gui *Gui) handleResetPatch() error {
+ gui.GitCommand.PatchManager.Reset()
return gui.refreshCommitFilesView()
}