summaryrefslogtreecommitdiffstats
path: root/pkg/gui/commit_files_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-21 20:31:21 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commite6a1bd656620d2b786266b593b197721d669085a (patch)
tree1c515c9856ad0e4bcbf3a66ba09c09e22e0d7c0d /pkg/gui/commit_files_panel.go
parent609f3f4bfaa71e0d94eac845ee0f8f6ffcf2e624 (diff)
generalise patch building stuff
Diffstat (limited to 'pkg/gui/commit_files_panel.go')
-rw-r--r--pkg/gui/commit_files_panel.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 327c4450c..2cdf0c02f 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -2,7 +2,6 @@ package gui
import (
"github.com/davecgh/go-spew/spew"
- "github.com/go-errors/errors"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
)
@@ -122,7 +121,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
}
toggleTheFile := func() error {
- if !gui.GitCommand.PatchManager.CommitSelected() {
+ if !gui.GitCommand.PatchManager.Active() {
if err := gui.startPatchManager(); err != nil {
return err
}
@@ -133,7 +132,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
return gui.refreshCommitFilesView()
}
- if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Parent {
+ if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.Parent != commitFile.Parent {
return gui.ask(askOpts{
returnToView: v,
returnFocusOnClose: true,
@@ -151,6 +150,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) startPatchManager() error {
diffMap := map[string]string{}
+ // TODO: only load these files as we need to
for _, commitFile := range gui.State.CommitFiles {
commitText, err := gui.GitCommand.ShowCommitFile(commitFile.Parent, commitFile.Name, true)
if err != nil {
@@ -159,12 +159,7 @@ func (gui *Gui) startPatchManager() error {
diffMap[commitFile.Name] = commitText
}
- commit := gui.getSelectedCommit()
- if commit == nil {
- return errors.New("No commit selected")
- }
-
- gui.GitCommand.PatchManager.Start(commit.Sha, diffMap)
+ gui.GitCommand.PatchManager.Start(gui.State.Panels.CommitFiles.refName, diffMap)
return nil
}
@@ -184,7 +179,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
}
enterTheFile := func(selectedLineIdx int) error {
- if !gui.GitCommand.PatchManager.CommitSelected() {
+ if !gui.GitCommand.PatchManager.Active() {
if err := gui.startPatchManager(); err != nil {
return err
}
@@ -196,7 +191,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
return gui.refreshPatchBuildingPanel(selectedLineIdx)
}
- if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Parent {
+ if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.Parent != commitFile.Parent {
return gui.ask(askOpts{
returnToView: gui.getCommitFilesView(),
returnFocusOnClose: false,