summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-12-30 13:35:10 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-01-04 09:07:15 +1100
commit66e840bc3f83903852408ed8db0be0c6153b5487 (patch)
tree2e3578e0ceff2fb44b8a7060f87400808eedaef7 /pkg/gui
parent5b3572424380418f86df88d201347b54634be530 (diff)
more refactoring
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/commits_panel.go11
-rw-r--r--pkg/gui/merge_panel.go4
-rw-r--r--pkg/gui/modes.go4
-rw-r--r--pkg/gui/patch_options_panel.go6
-rw-r--r--pkg/gui/rebase_options_panel.go18
-rw-r--r--pkg/gui/status_panel.go6
-rw-r--r--pkg/gui/sub_commits_panel.go7
-rw-r--r--pkg/gui/undoing.go6
8 files changed, 32 insertions, 30 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index f88557cdd..cd85dafd5 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -5,6 +5,7 @@ import (
"sync"
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/loaders"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/utils"
@@ -119,10 +120,10 @@ func (gui *Gui) refreshCommitsWithLimit() error {
gui.Mutexes.BranchCommitsMutex.Lock()
defer gui.Mutexes.BranchCommitsMutex.Unlock()
- builder := commands.NewCommitListBuilder(gui.Common, gui.GitCommand, gui.OSCommand)
+ loader := commands.NewCommitLoader(gui.Common, gui.GitCommand, gui.OSCommand)
- commits, err := builder.GetCommits(
- commands.GetCommitsOptions{
+ commits, err := loader.GetCommits(
+ loaders.GetCommitsOptions{
Limit: gui.State.Panels.Commits.LimitCommits,
FilterPath: gui.State.Modes.Filtering.GetPath(),
IncludeRebaseCommits: true,
@@ -142,9 +143,9 @@ func (gui *Gui) refreshRebaseCommits() error {
gui.Mutexes.BranchCommitsMutex.Lock()
defer gui.Mutexes.BranchCommitsMutex.Unlock()
- builder := commands.NewCommitListBuilder(gui.Common, gui.GitCommand, gui.OSCommand)
+ loader := commands.NewCommitLoader(gui.Common, gui.GitCommand, gui.OSCommand)
- updatedCommits, err := builder.MergeRebasingCommits(gui.State.Commits)
+ updatedCommits, err := loader.MergeRebasingCommits(gui.State.Commits)
if err != nil {
return err
}
diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go
index 8054a0348..5afbd64b2 100644
--- a/pkg/gui/merge_panel.go
+++ b/pkg/gui/merge_panel.go
@@ -9,8 +9,8 @@ import (
"github.com/go-errors/errors"
"github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts"
)
@@ -262,7 +262,7 @@ func (gui *Gui) handleCompleteMerge() error {
}
// if we got conflicts after unstashing, we don't want to call any git
// commands to continue rebasing/merging here
- if gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_NONE {
+ if gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_NONE {
return gui.handleEscapeMerge()
}
// if there are no more files with merge conflicts, we should ask whether the user wants to continue
diff --git a/pkg/gui/modes.go b/pkg/gui/modes.go
index 025767b82..c8e2749e3 100644
--- a/pkg/gui/modes.go
+++ b/pkg/gui/modes.go
@@ -1,7 +1,7 @@
package gui
import (
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/gui/style"
)
@@ -61,7 +61,7 @@ func (gui *Gui) modeStatuses() []modeStatus {
},
{
isActive: func() bool {
- return gui.GitCommand.WorkingTreeState() != commands.REBASE_MODE_NONE
+ return gui.GitCommand.WorkingTreeState() != enums.REBASE_MODE_NONE
},
description: func() string {
workingTreeState := gui.GitCommand.WorkingTreeState()
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go
index 8a57e9244..facaa08db 100644
--- a/pkg/gui/patch_options_panel.go
+++ b/pkg/gui/patch_options_panel.go
@@ -3,7 +3,7 @@ package gui
import (
"fmt"
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
)
func (gui *Gui) handleCreatePatchOptionsMenu() error {
@@ -26,7 +26,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
},
}
- if gui.GitCommand.PatchManager.CanRebase && gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_NONE {
+ if gui.GitCommand.PatchManager.CanRebase && gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_NONE {
menuItems = append(menuItems, []*menuItem{
{
displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.To),
@@ -74,7 +74,7 @@ func (gui *Gui) getPatchCommitIndex() int {
}
func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
- if gui.GitCommand.WorkingTreeState() != commands.REBASE_MODE_NONE {
+ if gui.GitCommand.WorkingTreeState() != enums.REBASE_MODE_NONE {
return false, gui.createErrorPanel(gui.Tr.CantPatchWhileRebasingError)
}
return true, nil
diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go
index 514cdf5ae..6cc9f113b 100644
--- a/pkg/gui/rebase_options_panel.go
+++ b/pkg/gui/rebase_options_panel.go
@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
)
type RebaseOption string
@@ -18,7 +18,7 @@ const (
func (gui *Gui) handleCreateRebaseOptionsMenu() error {
options := []string{REBASE_OPTION_CONTINUE, REBASE_OPTION_ABORT}
- if gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_REBASING {
+ if gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_REBASING {
options = append(options, REBASE_OPTION_SKIP)
}
@@ -35,7 +35,7 @@ func (gui *Gui) handleCreateRebaseOptionsMenu() error {
}
var title string
- if gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_MERGING {
+ if gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_MERGING {
title = gui.Tr.MergeOptionsTitle
} else {
title = gui.Tr.RebaseOptionsTitle
@@ -47,7 +47,7 @@ func (gui *Gui) handleCreateRebaseOptionsMenu() error {
func (gui *Gui) genericMergeCommand(command string) error {
status := gui.GitCommand.WorkingTreeState()
- if status != commands.REBASE_MODE_MERGING && status != commands.REBASE_MODE_REBASING {
+ if status != enums.REBASE_MODE_MERGING && status != enums.REBASE_MODE_REBASING {
return gui.createErrorPanel(gui.Tr.NotMergingOrRebasing)
}
@@ -55,16 +55,16 @@ func (gui *Gui) genericMergeCommand(command string) error {
commandType := ""
switch status {
- case commands.REBASE_MODE_MERGING:
+ case enums.REBASE_MODE_MERGING:
commandType = "merge"
- case commands.REBASE_MODE_REBASING:
+ case enums.REBASE_MODE_REBASING:
commandType = "rebase"
}
// we should end up with a command like 'git merge --continue'
// it's impossible for a rebase to require a commit so we'll use a subprocess only if it's a merge
- if status == commands.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && gui.UserConfig.Git.Merging.ManualCommit {
+ if status == enums.REBASE_MODE_MERGING && command != REBASE_OPTION_ABORT && gui.UserConfig.Git.Merging.ManualCommit {
sub := gitCommand.Cmd.New("git " + commandType + " --" + command)
if sub != nil {
return gui.runSubprocessWithSuspenseAndRefresh(sub)
@@ -144,9 +144,9 @@ func (gui *Gui) abortMergeOrRebaseWithConfirm() error {
func (gui *Gui) workingTreeStateNoun() string {
workingTreeState := gui.GitCommand.WorkingTreeState()
switch workingTreeState {
- case commands.REBASE_MODE_NONE:
+ case enums.REBASE_MODE_NONE:
return ""
- case commands.REBASE_MODE_MERGING:
+ case enums.REBASE_MODE_MERGING:
return "merge"
default:
return "rebase"
diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go
index ee09f6187..d6985dd0d 100644
--- a/pkg/gui/status_panel.go
+++ b/pkg/gui/status_panel.go
@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/style"
@@ -28,7 +28,7 @@ func (gui *Gui) refreshStatus() {
status += presentation.ColoredBranchStatus(currentBranch) + " "
}
- if gui.GitCommand.WorkingTreeState() != commands.REBASE_MODE_NONE {
+ if gui.GitCommand.WorkingTreeState() != enums.REBASE_MODE_NONE {
status += style.FgYellow.Sprintf("(%s) ", gui.GitCommand.WorkingTreeState())
}
@@ -72,7 +72,7 @@ func (gui *Gui) handleStatusClick() error {
upstreamStatus := presentation.BranchStatus(currentBranch)
repoName := utils.GetCurrentRepoName()
switch gui.GitCommand.WorkingTreeState() {
- case commands.REBASE_MODE_REBASING, commands.REBASE_MODE_MERGING:
+ case enums.REBASE_MODE_REBASING, enums.REBASE_MODE_MERGING:
workingTreeStatus := fmt.Sprintf("(%s)", gui.GitCommand.WorkingTreeState())
if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) {
return gui.handleCreateRebaseOptionsMenu()
diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go
index c212e3caa..a41ccb315 100644
--- a/pkg/gui/sub_commits_panel.go
+++ b/pkg/gui/sub_commits_panel.go
@@ -2,6 +2,7 @@ package gui
import (
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/loaders"
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
@@ -75,10 +76,10 @@ func (gui *Gui) handleViewSubCommitFiles() error {
func (gui *Gui) switchToSubCommitsContext(refName string) error {
// need to populate my sub commits
- builder := commands.NewCommitListBuilder(gui.Common, gui.GitCommand, gui.OSCommand)
+ loader := commands.NewCommitLoader(gui.Common, gui.GitCommand, gui.OSCommand)
- commits, err := builder.GetCommits(
- commands.GetCommitsOptions{
+ commits, err := loader.GetCommits(
+ loaders.GetCommitsOptions{
Limit: gui.State.Panels.Commits.LimitCommits,
FilterPath: gui.State.Modes.Filtering.GetPath(),
IncludeRebaseCommits: false,
diff --git a/pkg/gui/undoing.go b/pkg/gui/undoing.go
index 76a391730..cb9a46c2c 100644
--- a/pkg/gui/undoing.go
+++ b/pkg/gui/undoing.go
@@ -1,7 +1,7 @@
package gui
import (
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -88,7 +88,7 @@ func (gui *Gui) reflogUndo() error {
undoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit undo]"}
undoingStatus := gui.Tr.UndoingStatus
- if gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_REBASING {
+ if gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_REBASING {
return gui.createErrorPanel(gui.Tr.LcCantUndoWhileRebasing)
}
@@ -123,7 +123,7 @@ func (gui *Gui) reflogRedo() error {
redoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit redo]"}
redoingStatus := gui.Tr.RedoingStatus
- if gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_REBASING {
+ if gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_REBASING {
return gui.createErrorPanel(gui.Tr.LcCantRedoWhileRebasing)
}