diff options
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 95b4f80a4..2059ac97f 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -118,11 +118,7 @@ func (gui *Gui) stageSelectedFile(g *gocui.Gui) error { return gui.GitCommand.StageFile(file.Name) } -func (gui *Gui) handleSwitchToStagingPanel(g *gocui.Gui, v *gocui.View) error { - stagingView, err := g.View("staging") - if err != nil { - return err - } +func (gui *Gui) handleEnterFile(g *gocui.Gui, v *gocui.View) error { file, err := gui.getSelectedFile(g) if err != nil { if err != gui.Errors.ErrNoFiles { @@ -130,10 +126,17 @@ func (gui *Gui) handleSwitchToStagingPanel(g *gocui.Gui, v *gocui.View) error { } return nil } + if file.HasMergeConflicts { + return gui.handleSwitchToMerge(g, v) + } if !file.HasUnstagedChanges { gui.Log.WithField("staging", "staging").Info("making error panel") return gui.createErrorPanel(g, gui.Tr.SLocalize("FileStagingRequirements")) } + stagingView, err := g.View("staging") + if err != nil { + return err + } if err := gui.switchFocus(g, v, stagingView); err != nil { return err } @@ -256,7 +259,7 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { - if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { + if len(gui.stagedFiles()) == 0 && gui.State.WorkingTreeState == "normal" { return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit")) } commitMessageView := gui.getCommitMessageView(g) @@ -270,7 +273,7 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { } func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) error { - if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { + if len(gui.stagedFiles()) == 0 && gui.State.WorkingTreeState == "normal" { return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit")) } title := strings.Title(gui.Tr.SLocalize("AmendLastCommit")) @@ -294,7 +297,7 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro // handleCommitEditorPress - handle when the user wants to commit changes via // their editor rather than via the popup panel func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error { - if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { + if len(gui.stagedFiles()) == 0 && gui.State.WorkingTreeState == "normal" { return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit")) } gui.PrepareSubProcess(g, "git", "commit") @@ -347,15 +350,27 @@ func (gui *Gui) refreshStateFiles() { files := gui.GitCommand.GetStatusFiles() gui.State.Files = gui.GitCommand.MergeStatusFiles(gui.State.Files, files) gui.refreshSelectedLine(&gui.State.Panels.Files.SelectedLine, len(gui.State.Files)) - gui.updateHasMergeConflictStatus() + gui.updateWorkTreeState() } -func (gui *Gui) updateHasMergeConflictStatus() error { +func (gui *Gui) updateWorkTreeState() error { merging, err := gui.GitCommand.IsInMergeState() if err != nil { return err } - gui.State.HasMergeConflicts = merging + if merging { + gui.State.WorkingTreeState = "merging" + return nil + } + rebasing, err := gui.GitCommand.IsInRebaseState() + if err != nil { + return err + } + if rebasing { + gui.State.WorkingTreeState = "rebasing" + return nil + } + gui.State.WorkingTreeState = "normal" return nil } |