mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Move types/enums/enums.go to working_tree_state.go
It looks like enums.go was supposed to be file that collects a bunch of enums, but actually there's only one in there, and since it has methods, it deserves to be in a file of its own, named after the type.
This commit is contained in:
parent
e1eb95b2b3
commit
8af8f7754b
16 changed files with 36 additions and 45 deletions
|
@ -13,7 +13,6 @@ import (
|
|||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
|
@ -31,7 +30,7 @@ type CommitLoader struct {
|
|||
*common.Common
|
||||
cmd oscommands.ICmdObjBuilder
|
||||
|
||||
getWorkingTreeState func() enums.WorkingTreeState
|
||||
getWorkingTreeState func() models.WorkingTreeState
|
||||
readFile func(filename string) ([]byte, error)
|
||||
walkFiles func(root string, fn filepath.WalkFunc) error
|
||||
dotGitDir string
|
||||
|
@ -42,7 +41,7 @@ type CommitLoader struct {
|
|||
func NewCommitLoader(
|
||||
cmn *common.Common,
|
||||
cmd oscommands.ICmdObjBuilder,
|
||||
getWorkingTreeState func() enums.WorkingTreeState,
|
||||
getWorkingTreeState func() models.WorkingTreeState,
|
||||
gitCommon *GitCommon,
|
||||
) *CommitLoader {
|
||||
return &CommitLoader{
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/go-errors/errors"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/stefanhaller/git-todo-parser/todo"
|
||||
|
@ -304,7 +303,7 @@ func TestGetCommits(t *testing.T) {
|
|||
builder := &CommitLoader{
|
||||
Common: common,
|
||||
cmd: cmd,
|
||||
getWorkingTreeState: func() enums.WorkingTreeState { return enums.WORKING_TREE_STATE_NONE },
|
||||
getWorkingTreeState: func() models.WorkingTreeState { return models.WORKING_TREE_STATE_NONE },
|
||||
dotGitDir: ".git",
|
||||
readFile: func(filename string) ([]byte, error) {
|
||||
return []byte(""), nil
|
||||
|
@ -487,7 +486,7 @@ func TestCommitLoader_getConflictedCommitImpl(t *testing.T) {
|
|||
builder := &CommitLoader{
|
||||
Common: common,
|
||||
cmd: oscommands.NewDummyCmdObjBuilder(oscommands.NewFakeRunner(t)),
|
||||
getWorkingTreeState: func() enums.WorkingTreeState { return enums.WORKING_TREE_STATE_REBASING },
|
||||
getWorkingTreeState: func() models.WorkingTreeState { return models.WORKING_TREE_STATE_REBASING },
|
||||
dotGitDir: ".git",
|
||||
readFile: func(filename string) ([]byte, error) {
|
||||
return []byte(""), nil
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/jesseduffield/lazygit/pkg/app/daemon"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||
"github.com/stefanhaller/git-todo-parser/todo"
|
||||
)
|
||||
|
||||
|
@ -229,7 +228,7 @@ func (self *PatchCommands) MovePatchIntoIndex(commits []*models.Commit, commitId
|
|||
}
|
||||
|
||||
if err := self.ApplyCustomPatch(true, true); err != nil {
|
||||
if self.status.WorkingTreeState() == enums.WORKING_TREE_STATE_REBASING {
|
||||
if self.status.WorkingTreeState() == models.WORKING_TREE_STATE_REBASING {
|
||||
_ = self.rebase.AbortRebase()
|
||||
}
|
||||
return err
|
||||
|
@ -253,7 +252,7 @@ func (self *PatchCommands) MovePatchIntoIndex(commits []*models.Commit, commitId
|
|||
self.rebase.onSuccessfulContinue = func() error {
|
||||
// add patches to index
|
||||
if err := self.ApplyPatch(patch, ApplyPatchOpts{Index: true, ThreeWay: true}); err != nil {
|
||||
if self.status.WorkingTreeState() == enums.WORKING_TREE_STATE_REBASING {
|
||||
if self.status.WorkingTreeState() == models.WORKING_TREE_STATE_REBASING {
|
||||
_ = self.rebase.AbortRebase()
|
||||
}
|
||||
return err
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
)
|
||||
|
||||
type StatusCommands struct {
|
||||
|
@ -20,16 +20,16 @@ func NewStatusCommands(
|
|||
}
|
||||
}
|
||||
|
||||
func (self *StatusCommands) WorkingTreeState() enums.WorkingTreeState {
|
||||
func (self *StatusCommands) WorkingTreeState() models.WorkingTreeState {
|
||||
isInRebase, _ := self.IsInRebase()
|
||||
if isInRebase {
|
||||
return enums.WORKING_TREE_STATE_REBASING
|
||||
return models.WORKING_TREE_STATE_REBASING
|
||||
}
|
||||
merging, _ := self.IsInMergeState()
|
||||
if merging {
|
||||
return enums.WORKING_TREE_STATE_MERGING
|
||||
return models.WORKING_TREE_STATE_MERGING
|
||||
}
|
||||
return enums.WORKING_TREE_STATE_NONE
|
||||
return models.WORKING_TREE_STATE_NONE
|
||||
}
|
||||
|
||||
func (self *StatusCommands) IsBareRepo() bool {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package enums
|
||||
package models
|
||||
|
||||
import "github.com/jesseduffield/lazygit/pkg/i18n"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue