mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
more refactoring
This commit is contained in:
28
pkg/commands/loader_adapters.go
Normal file
28
pkg/commands/loader_adapters.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
// this file defines constructors for loaders, passing in all the dependencies required based on a smaller set of arguments passed in by the client.
|
||||||
|
|
||||||
|
func NewCommitLoader(
|
||||||
|
cmn *common.Common,
|
||||||
|
gitCommand *GitCommand,
|
||||||
|
osCommand *oscommands.OSCommand,
|
||||||
|
) *loaders.CommitLoader {
|
||||||
|
return loaders.NewCommitLoader(
|
||||||
|
cmn,
|
||||||
|
gitCommand.Cmd,
|
||||||
|
gitCommand.CurrentBranchName,
|
||||||
|
gitCommand.RebaseMode,
|
||||||
|
ioutil.ReadFile,
|
||||||
|
filepath.Walk,
|
||||||
|
gitCommand.DotGitDir,
|
||||||
|
)
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
package commands
|
package loaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -11,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"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/common"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
)
|
)
|
||||||
@ -23,31 +23,35 @@ import (
|
|||||||
|
|
||||||
const SEPARATION_CHAR = "|"
|
const SEPARATION_CHAR = "|"
|
||||||
|
|
||||||
// CommitListBuilder returns a list of Commit objects for the current repo
|
// CommitLoader returns a list of Commit objects for the current repo
|
||||||
type CommitListBuilder struct {
|
type CommitLoader struct {
|
||||||
*common.Common
|
*common.Common
|
||||||
cmd oscommands.ICmdObjBuilder
|
cmd oscommands.ICmdObjBuilder
|
||||||
|
|
||||||
getCurrentBranchName func() (string, string, error)
|
getCurrentBranchName func() (string, string, error)
|
||||||
getRebaseMode func() (RebaseMode, error)
|
getRebaseMode func() (enums.RebaseMode, error)
|
||||||
readFile func(filename string) ([]byte, error)
|
readFile func(filename string) ([]byte, error)
|
||||||
walkFiles func(root string, fn filepath.WalkFunc) error
|
walkFiles func(root string, fn filepath.WalkFunc) error
|
||||||
dotGitDir string
|
dotGitDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommitListBuilder(
|
func NewCommitLoader(
|
||||||
cmn *common.Common,
|
common *common.Common,
|
||||||
gitCommand *GitCommand,
|
cmd oscommands.ICmdObjBuilder,
|
||||||
osCommand *oscommands.OSCommand,
|
getCurrentBranchName func() (string, string, error),
|
||||||
) *CommitListBuilder {
|
getRebaseMode func() (enums.RebaseMode, error),
|
||||||
return &CommitListBuilder{
|
readFile func(filename string) ([]byte, error),
|
||||||
Common: cmn,
|
walkFiles func(root string, fn filepath.WalkFunc) error,
|
||||||
cmd: gitCommand.Cmd,
|
dotGitDir string,
|
||||||
getCurrentBranchName: gitCommand.CurrentBranchName,
|
) *CommitLoader {
|
||||||
getRebaseMode: gitCommand.RebaseMode,
|
return &CommitLoader{
|
||||||
dotGitDir: gitCommand.DotGitDir,
|
Common: common,
|
||||||
readFile: ioutil.ReadFile,
|
cmd: cmd,
|
||||||
walkFiles: filepath.Walk,
|
getCurrentBranchName: getCurrentBranchName,
|
||||||
|
getRebaseMode: getRebaseMode,
|
||||||
|
readFile: readFile,
|
||||||
|
walkFiles: walkFiles,
|
||||||
|
dotGitDir: dotGitDir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +65,7 @@ type GetCommitsOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetCommits obtains the commits of the current branch
|
// GetCommits obtains the commits of the current branch
|
||||||
func (self *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit, error) {
|
func (self *CommitLoader) GetCommits(opts GetCommitsOptions) ([]*models.Commit, error) {
|
||||||
commits := []*models.Commit{}
|
commits := []*models.Commit{}
|
||||||
var rebasingCommits []*models.Commit
|
var rebasingCommits []*models.Commit
|
||||||
rebaseMode, err := self.getRebaseMode()
|
rebaseMode, err := self.getRebaseMode()
|
||||||
@ -104,7 +108,7 @@ func (self *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Com
|
|||||||
return commits, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if rebaseMode != REBASE_MODE_NONE {
|
if rebaseMode != enums.REBASE_MODE_NONE {
|
||||||
currentCommit := commits[len(rebasingCommits)]
|
currentCommit := commits[len(rebasingCommits)]
|
||||||
youAreHere := style.FgYellow.Sprintf("<-- %s ---", self.Tr.YouAreHere)
|
youAreHere := style.FgYellow.Sprintf("<-- %s ---", self.Tr.YouAreHere)
|
||||||
currentCommit.Name = fmt.Sprintf("%s %s", youAreHere, currentCommit.Name)
|
currentCommit.Name = fmt.Sprintf("%s %s", youAreHere, currentCommit.Name)
|
||||||
@ -118,7 +122,7 @@ func (self *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Com
|
|||||||
return commits, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([]*models.Commit, error) {
|
func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*models.Commit, error) {
|
||||||
// chances are we have as many commits as last time so we'll set the capacity to be the old length
|
// chances are we have as many commits as last time so we'll set the capacity to be the old length
|
||||||
result := make([]*models.Commit, 0, len(commits))
|
result := make([]*models.Commit, 0, len(commits))
|
||||||
for i, commit := range commits {
|
for i, commit := range commits {
|
||||||
@ -133,7 +137,7 @@ func (self *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if rebaseMode == REBASE_MODE_NONE {
|
if rebaseMode == enums.REBASE_MODE_NONE {
|
||||||
// not in rebase mode so return original commits
|
// not in rebase mode so return original commits
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@ -153,7 +157,7 @@ func (self *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([
|
|||||||
// then puts them into a commit object
|
// then puts them into a commit object
|
||||||
// example input:
|
// example input:
|
||||||
// 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag
|
// 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag
|
||||||
func (self *CommitListBuilder) extractCommitFromLine(line string) *models.Commit {
|
func (self *CommitLoader) extractCommitFromLine(line string) *models.Commit {
|
||||||
split := strings.Split(line, SEPARATION_CHAR)
|
split := strings.Split(line, SEPARATION_CHAR)
|
||||||
|
|
||||||
sha := split[0]
|
sha := split[0]
|
||||||
@ -186,7 +190,7 @@ func (self *CommitListBuilder) extractCommitFromLine(line string) *models.Commit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitListBuilder) getHydratedRebasingCommits(rebaseMode RebaseMode) ([]*models.Commit, error) {
|
func (self *CommitLoader) getHydratedRebasingCommits(rebaseMode enums.RebaseMode) ([]*models.Commit, error) {
|
||||||
commits, err := self.getRebasingCommits(rebaseMode)
|
commits, err := self.getRebasingCommits(rebaseMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -232,18 +236,18 @@ func (self *CommitListBuilder) getHydratedRebasingCommits(rebaseMode RebaseMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getRebasingCommits obtains the commits that we're in the process of rebasing
|
// getRebasingCommits obtains the commits that we're in the process of rebasing
|
||||||
func (self *CommitListBuilder) getRebasingCommits(rebaseMode RebaseMode) ([]*models.Commit, error) {
|
func (self *CommitLoader) getRebasingCommits(rebaseMode enums.RebaseMode) ([]*models.Commit, error) {
|
||||||
switch rebaseMode {
|
switch rebaseMode {
|
||||||
case REBASE_MODE_MERGING:
|
case enums.REBASE_MODE_MERGING:
|
||||||
return self.getNormalRebasingCommits()
|
return self.getNormalRebasingCommits()
|
||||||
case REBASE_MODE_INTERACTIVE:
|
case enums.REBASE_MODE_INTERACTIVE:
|
||||||
return self.getInteractiveRebasingCommits()
|
return self.getInteractiveRebasingCommits()
|
||||||
default:
|
default:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, error) {
|
func (self *CommitLoader) getNormalRebasingCommits() ([]*models.Commit, error) {
|
||||||
rewrittenCount := 0
|
rewrittenCount := 0
|
||||||
bytesContent, err := self.readFile(filepath.Join(self.dotGitDir, "rebase-apply/rewritten"))
|
bytesContent, err := self.readFile(filepath.Join(self.dotGitDir, "rebase-apply/rewritten"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -296,7 +300,7 @@ func (self *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, err
|
|||||||
// getInteractiveRebasingCommits takes our git-rebase-todo and our git-rebase-todo.backup files
|
// getInteractiveRebasingCommits takes our git-rebase-todo and our git-rebase-todo.backup files
|
||||||
// and extracts out the sha and names of commits that we still have to go
|
// and extracts out the sha and names of commits that we still have to go
|
||||||
// in the rebase:
|
// in the rebase:
|
||||||
func (self *CommitListBuilder) getInteractiveRebasingCommits() ([]*models.Commit, error) {
|
func (self *CommitLoader) getInteractiveRebasingCommits() ([]*models.Commit, error) {
|
||||||
bytesContent, err := self.readFile(filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo"))
|
bytesContent, err := self.readFile(filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.Log.Error(fmt.Sprintf("error occurred reading git-rebase-todo: %s", err.Error()))
|
self.Log.Error(fmt.Sprintf("error occurred reading git-rebase-todo: %s", err.Error()))
|
||||||
@ -330,7 +334,7 @@ func (self *CommitListBuilder) getInteractiveRebasingCommits() ([]*models.Commit
|
|||||||
// From: Lazygit Tester <test@example.com>
|
// From: Lazygit Tester <test@example.com>
|
||||||
// Date: Wed, 5 Dec 2018 21:03:23 +1100
|
// Date: Wed, 5 Dec 2018 21:03:23 +1100
|
||||||
// Subject: second commit on master
|
// Subject: second commit on master
|
||||||
func (self *CommitListBuilder) commitFromPatch(content string) (*models.Commit, error) {
|
func (self *CommitLoader) commitFromPatch(content string) (*models.Commit, error) {
|
||||||
lines := strings.Split(content, "\n")
|
lines := strings.Split(content, "\n")
|
||||||
sha := strings.Split(lines[0], " ")[1]
|
sha := strings.Split(lines[0], " ")[1]
|
||||||
name := strings.TrimPrefix(lines[3], "Subject: ")
|
name := strings.TrimPrefix(lines[3], "Subject: ")
|
||||||
@ -341,7 +345,7 @@ func (self *CommitListBuilder) commitFromPatch(content string) (*models.Commit,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitListBuilder) setCommitMergedStatuses(refName string, commits []*models.Commit) ([]*models.Commit, error) {
|
func (self *CommitLoader) setCommitMergedStatuses(refName string, commits []*models.Commit) ([]*models.Commit, error) {
|
||||||
ancestor, err := self.getMergeBase(refName)
|
ancestor, err := self.getMergeBase(refName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -364,7 +368,7 @@ func (self *CommitListBuilder) setCommitMergedStatuses(refName string, commits [
|
|||||||
return commits, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitListBuilder) getMergeBase(refName string) (string, error) {
|
func (self *CommitLoader) getMergeBase(refName string) (string, error) {
|
||||||
currentBranch, _, err := self.getCurrentBranchName()
|
currentBranch, _, err := self.getCurrentBranchName()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -392,7 +396,7 @@ func ignoringWarnings(commandOutput string) string {
|
|||||||
|
|
||||||
// getFirstPushedCommit returns the first commit SHA which has been pushed to the ref's upstream.
|
// getFirstPushedCommit returns the first commit SHA which has been pushed to the ref's upstream.
|
||||||
// all commits above this are deemed unpushed and marked as such.
|
// all commits above this are deemed unpushed and marked as such.
|
||||||
func (self *CommitListBuilder) getFirstPushedCommit(refName string) (string, error) {
|
func (self *CommitLoader) getFirstPushedCommit(refName string) (string, error) {
|
||||||
output, err := self.cmd.
|
output, err := self.cmd.
|
||||||
New(
|
New(
|
||||||
fmt.Sprintf("git merge-base %s %s@{u}", self.cmd.Quote(refName), self.cmd.Quote(refName)),
|
fmt.Sprintf("git merge-base %s %s@{u}", self.cmd.Quote(refName), self.cmd.Quote(refName)),
|
||||||
@ -406,7 +410,7 @@ func (self *CommitListBuilder) getFirstPushedCommit(refName string) (string, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getLog gets the git log.
|
// getLog gets the git log.
|
||||||
func (self *CommitListBuilder) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
||||||
limitFlag := ""
|
limitFlag := ""
|
||||||
if opts.Limit {
|
if opts.Limit {
|
||||||
limitFlag = " -300"
|
limitFlag = " -300"
|
@ -1,4 +1,4 @@
|
|||||||
package commands
|
package loaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -6,18 +6,19 @@ import (
|
|||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDummyCommitListBuilder() *CommitListBuilder {
|
func NewDummyCommitLoader() *CommitLoader {
|
||||||
cmn := utils.NewDummyCommon()
|
cmn := utils.NewDummyCommon()
|
||||||
|
|
||||||
return &CommitListBuilder{
|
return &CommitLoader{
|
||||||
Common: cmn,
|
Common: cmn,
|
||||||
cmd: nil,
|
cmd: nil,
|
||||||
getCurrentBranchName: func() (string, string, error) { return "master", "master", nil },
|
getCurrentBranchName: func() (string, string, error) { return "master", "master", nil },
|
||||||
getRebaseMode: func() (RebaseMode, error) { return REBASE_MODE_NONE, nil },
|
getRebaseMode: func() (enums.RebaseMode, error) { return enums.REBASE_MODE_NONE, nil },
|
||||||
dotGitDir: ".git",
|
dotGitDir: ".git",
|
||||||
readFile: func(filename string) ([]byte, error) {
|
readFile: func(filename string) ([]byte, error) {
|
||||||
return []byte(""), nil
|
return []byte(""), nil
|
||||||
@ -43,7 +44,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
runner oscommands.ICmdObjRunner
|
runner oscommands.ICmdObjRunner
|
||||||
expectedCommits []*models.Commit
|
expectedCommits []*models.Commit
|
||||||
expectedError error
|
expectedError error
|
||||||
rebaseMode RebaseMode
|
rebaseMode enums.RebaseMode
|
||||||
currentBranchName string
|
currentBranchName string
|
||||||
opts GetCommitsOptions
|
opts GetCommitsOptions
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
testName: "should return no commits if there are none",
|
testName: "should return no commits if there are none",
|
||||||
rebaseMode: REBASE_MODE_NONE,
|
rebaseMode: enums.REBASE_MODE_NONE,
|
||||||
currentBranchName: "master",
|
currentBranchName: "master",
|
||||||
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
@ -63,7 +64,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "should return commits if they are present",
|
testName: "should return commits if they are present",
|
||||||
rebaseMode: REBASE_MODE_NONE,
|
rebaseMode: enums.REBASE_MODE_NONE,
|
||||||
currentBranchName: "master",
|
currentBranchName: "master",
|
||||||
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
@ -186,13 +187,13 @@ func TestGetCommits(t *testing.T) {
|
|||||||
|
|
||||||
for _, scenario := range scenarios {
|
for _, scenario := range scenarios {
|
||||||
t.Run(scenario.testName, func(t *testing.T) {
|
t.Run(scenario.testName, func(t *testing.T) {
|
||||||
builder := &CommitListBuilder{
|
builder := &CommitLoader{
|
||||||
Common: utils.NewDummyCommon(),
|
Common: utils.NewDummyCommon(),
|
||||||
cmd: oscommands.NewCmdObjBuilderDummy(scenario.runner),
|
cmd: oscommands.NewCmdObjBuilderDummy(scenario.runner),
|
||||||
getCurrentBranchName: func() (string, string, error) {
|
getCurrentBranchName: func() (string, string, error) {
|
||||||
return scenario.currentBranchName, scenario.currentBranchName, nil
|
return scenario.currentBranchName, scenario.currentBranchName, nil
|
||||||
},
|
},
|
||||||
getRebaseMode: func() (RebaseMode, error) { return scenario.rebaseMode, nil },
|
getRebaseMode: func() (enums.RebaseMode, error) { return scenario.rebaseMode, nil },
|
||||||
dotGitDir: ".git",
|
dotGitDir: ".git",
|
||||||
readFile: func(filename string) ([]byte, error) {
|
readFile: func(filename string) ([]byte, error) {
|
||||||
return []byte(""), nil
|
return []byte(""), nil
|
@ -20,6 +20,8 @@ import (
|
|||||||
// if we find out we need to use one of these functions in the git.go file, we
|
// if we find out we need to use one of these functions in the git.go file, we
|
||||||
// can just pull them out of here and put them there and then call them from in here
|
// can just pull them out of here and put them there and then call them from in here
|
||||||
|
|
||||||
|
const SEPARATION_CHAR = "|"
|
||||||
|
|
||||||
// BranchListBuilder returns a list of Branch objects for the current repo
|
// BranchListBuilder returns a list of Branch objects for the current repo
|
||||||
type BranchListBuilder struct {
|
type BranchListBuilder struct {
|
||||||
*common.Common
|
*common.Common
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// for use in testing
|
||||||
|
|
||||||
type FakeCmdObjRunner struct {
|
type FakeCmdObjRunner struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
expectedCmds []func(ICmdObj) (string, error)
|
expectedCmds []func(ICmdObj) (string, error)
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeletePatchesFromCommit applies a patch in reverse for a commit
|
// DeletePatchesFromCommit applies a patch in reverse for a commit
|
||||||
@ -149,7 +150,7 @@ func (c *GitCommand) MovePatchIntoIndex(commits []*models.Commit, commitIdx int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := p.ApplyPatches(true); err != nil {
|
if err := p.ApplyPatches(true); err != nil {
|
||||||
if c.WorkingTreeState() == REBASE_MODE_REBASING {
|
if c.WorkingTreeState() == enums.REBASE_MODE_REBASING {
|
||||||
if err := c.GenericMergeOrRebaseAction("rebase", "abort"); err != nil {
|
if err := c.GenericMergeOrRebaseAction("rebase", "abort"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ func (c *GitCommand) MovePatchIntoIndex(commits []*models.Commit, commitIdx int,
|
|||||||
c.onSuccessfulContinue = func() error {
|
c.onSuccessfulContinue = func() error {
|
||||||
// add patches to index
|
// add patches to index
|
||||||
if err := p.ApplyPatches(false); err != nil {
|
if err := p.ApplyPatches(false); err != nil {
|
||||||
if c.WorkingTreeState() == REBASE_MODE_REBASING {
|
if c.WorkingTreeState() == enums.REBASE_MODE_REBASING {
|
||||||
if err := c.GenericMergeOrRebaseAction("rebase", "abort"); err != nil {
|
if err := c.GenericMergeOrRebaseAction("rebase", "abort"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -4,49 +4,37 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
gogit "github.com/jesseduffield/go-git/v5"
|
gogit "github.com/jesseduffield/go-git/v5"
|
||||||
)
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
|
|
||||||
type RebaseMode int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// this means we're neither rebasing nor merging
|
|
||||||
REBASE_MODE_NONE RebaseMode = iota
|
|
||||||
// this means normal rebase as opposed to interactive rebase
|
|
||||||
REBASE_MODE_NORMAL
|
|
||||||
REBASE_MODE_INTERACTIVE
|
|
||||||
// REBASE_MODE_REBASING is a general state that captures both REBASE_MODE_NORMAL and REBASE_MODE_INTERACTIVE
|
|
||||||
REBASE_MODE_REBASING
|
|
||||||
REBASE_MODE_MERGING
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RebaseMode returns "" for non-rebase mode, "normal" for normal rebase
|
// RebaseMode returns "" for non-rebase mode, "normal" for normal rebase
|
||||||
// and "interactive" for interactive rebase
|
// and "interactive" for interactive rebase
|
||||||
func (c *GitCommand) RebaseMode() (RebaseMode, error) {
|
func (c *GitCommand) RebaseMode() (enums.RebaseMode, error) {
|
||||||
exists, err := c.OSCommand.FileExists(filepath.Join(c.DotGitDir, "rebase-apply"))
|
exists, err := c.OSCommand.FileExists(filepath.Join(c.DotGitDir, "rebase-apply"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return REBASE_MODE_NONE, err
|
return enums.REBASE_MODE_NONE, err
|
||||||
}
|
}
|
||||||
if exists {
|
if exists {
|
||||||
return REBASE_MODE_NORMAL, nil
|
return enums.REBASE_MODE_NORMAL, nil
|
||||||
}
|
}
|
||||||
exists, err = c.OSCommand.FileExists(filepath.Join(c.DotGitDir, "rebase-merge"))
|
exists, err = c.OSCommand.FileExists(filepath.Join(c.DotGitDir, "rebase-merge"))
|
||||||
if exists {
|
if exists {
|
||||||
return REBASE_MODE_INTERACTIVE, err
|
return enums.REBASE_MODE_INTERACTIVE, err
|
||||||
} else {
|
} else {
|
||||||
return REBASE_MODE_NONE, err
|
return enums.REBASE_MODE_NONE, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) WorkingTreeState() RebaseMode {
|
func (c *GitCommand) WorkingTreeState() enums.RebaseMode {
|
||||||
rebaseMode, _ := c.RebaseMode()
|
rebaseMode, _ := c.RebaseMode()
|
||||||
if rebaseMode != REBASE_MODE_NONE {
|
if rebaseMode != enums.REBASE_MODE_NONE {
|
||||||
return REBASE_MODE_REBASING
|
return enums.REBASE_MODE_REBASING
|
||||||
}
|
}
|
||||||
merging, _ := c.IsInMergeState()
|
merging, _ := c.IsInMergeState()
|
||||||
if merging {
|
if merging {
|
||||||
return REBASE_MODE_MERGING
|
return enums.REBASE_MODE_MERGING
|
||||||
}
|
}
|
||||||
return REBASE_MODE_NONE
|
return enums.REBASE_MODE_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsInMergeState states whether we are still mid-merge
|
// IsInMergeState states whether we are still mid-merge
|
||||||
|
14
pkg/commands/types/enums/enums.go
Normal file
14
pkg/commands/types/enums/enums.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package enums
|
||||||
|
|
||||||
|
type RebaseMode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// this means we're neither rebasing nor merging
|
||||||
|
REBASE_MODE_NONE RebaseMode = iota
|
||||||
|
// this means normal rebase as opposed to interactive rebase
|
||||||
|
REBASE_MODE_NORMAL
|
||||||
|
REBASE_MODE_INTERACTIVE
|
||||||
|
// REBASE_MODE_REBASING is a general state that captures both REBASE_MODE_NORMAL and REBASE_MODE_INTERACTIVE
|
||||||
|
REBASE_MODE_REBASING
|
||||||
|
REBASE_MODE_MERGING
|
||||||
|
)
|
@ -5,6 +5,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"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/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
@ -119,10 +120,10 @@ func (gui *Gui) refreshCommitsWithLimit() error {
|
|||||||
gui.Mutexes.BranchCommitsMutex.Lock()
|
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||||
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
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(
|
commits, err := loader.GetCommits(
|
||||||
commands.GetCommitsOptions{
|
loaders.GetCommitsOptions{
|
||||||
Limit: gui.State.Panels.Commits.LimitCommits,
|
Limit: gui.State.Panels.Commits.LimitCommits,
|
||||||
FilterPath: gui.State.Modes.Filtering.GetPath(),
|
FilterPath: gui.State.Modes.Filtering.GetPath(),
|
||||||
IncludeRebaseCommits: true,
|
IncludeRebaseCommits: true,
|
||||||
@ -142,9 +143,9 @@ func (gui *Gui) refreshRebaseCommits() error {
|
|||||||
gui.Mutexes.BranchCommitsMutex.Lock()
|
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||||
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts"
|
"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
|
// if we got conflicts after unstashing, we don't want to call any git
|
||||||
// commands to continue rebasing/merging here
|
// 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()
|
return gui.handleEscapeMerge()
|
||||||
}
|
}
|
||||||
// if there are no more files with merge conflicts, we should ask whether the user wants to continue
|
// if there are no more files with merge conflicts, we should ask whether the user wants to continue
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ func (gui *Gui) modeStatuses() []modeStatus {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
isActive: func() bool {
|
isActive: func() bool {
|
||||||
return gui.GitCommand.WorkingTreeState() != commands.REBASE_MODE_NONE
|
return gui.GitCommand.WorkingTreeState() != enums.REBASE_MODE_NONE
|
||||||
},
|
},
|
||||||
description: func() string {
|
description: func() string {
|
||||||
workingTreeState := gui.GitCommand.WorkingTreeState()
|
workingTreeState := gui.GitCommand.WorkingTreeState()
|
||||||
|
@ -3,7 +3,7 @@ package gui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
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{
|
menuItems = append(menuItems, []*menuItem{
|
||||||
{
|
{
|
||||||
displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.To),
|
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) {
|
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 false, gui.createErrorPanel(gui.Tr.CantPatchWhileRebasingError)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RebaseOption string
|
type RebaseOption string
|
||||||
@ -18,7 +18,7 @@ const (
|
|||||||
func (gui *Gui) handleCreateRebaseOptionsMenu() error {
|
func (gui *Gui) handleCreateRebaseOptionsMenu() error {
|
||||||
options := []string{REBASE_OPTION_CONTINUE, REBASE_OPTION_ABORT}
|
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)
|
options = append(options, REBASE_OPTION_SKIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ func (gui *Gui) handleCreateRebaseOptionsMenu() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var title string
|
var title string
|
||||||
if gui.GitCommand.WorkingTreeState() == commands.REBASE_MODE_MERGING {
|
if gui.GitCommand.WorkingTreeState() == enums.REBASE_MODE_MERGING {
|
||||||
title = gui.Tr.MergeOptionsTitle
|
title = gui.Tr.MergeOptionsTitle
|
||||||
} else {
|
} else {
|
||||||
title = gui.Tr.RebaseOptionsTitle
|
title = gui.Tr.RebaseOptionsTitle
|
||||||
@ -47,7 +47,7 @@ func (gui *Gui) handleCreateRebaseOptionsMenu() error {
|
|||||||
func (gui *Gui) genericMergeCommand(command string) error {
|
func (gui *Gui) genericMergeCommand(command string) error {
|
||||||
status := gui.GitCommand.WorkingTreeState()
|
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)
|
return gui.createErrorPanel(gui.Tr.NotMergingOrRebasing)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,16 +55,16 @@ func (gui *Gui) genericMergeCommand(command string) error {
|
|||||||
|
|
||||||
commandType := ""
|
commandType := ""
|
||||||
switch status {
|
switch status {
|
||||||
case commands.REBASE_MODE_MERGING:
|
case enums.REBASE_MODE_MERGING:
|
||||||
commandType = "merge"
|
commandType = "merge"
|
||||||
case commands.REBASE_MODE_REBASING:
|
case enums.REBASE_MODE_REBASING:
|
||||||
commandType = "rebase"
|
commandType = "rebase"
|
||||||
}
|
}
|
||||||
|
|
||||||
// we should end up with a command like 'git merge --continue'
|
// 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
|
// 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)
|
sub := gitCommand.Cmd.New("git " + commandType + " --" + command)
|
||||||
if sub != nil {
|
if sub != nil {
|
||||||
return gui.runSubprocessWithSuspenseAndRefresh(sub)
|
return gui.runSubprocessWithSuspenseAndRefresh(sub)
|
||||||
@ -144,9 +144,9 @@ func (gui *Gui) abortMergeOrRebaseWithConfirm() error {
|
|||||||
func (gui *Gui) workingTreeStateNoun() string {
|
func (gui *Gui) workingTreeStateNoun() string {
|
||||||
workingTreeState := gui.GitCommand.WorkingTreeState()
|
workingTreeState := gui.GitCommand.WorkingTreeState()
|
||||||
switch workingTreeState {
|
switch workingTreeState {
|
||||||
case commands.REBASE_MODE_NONE:
|
case enums.REBASE_MODE_NONE:
|
||||||
return ""
|
return ""
|
||||||
case commands.REBASE_MODE_MERGING:
|
case enums.REBASE_MODE_MERGING:
|
||||||
return "merge"
|
return "merge"
|
||||||
default:
|
default:
|
||||||
return "rebase"
|
return "rebase"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"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/constants"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
@ -28,7 +28,7 @@ func (gui *Gui) refreshStatus() {
|
|||||||
status += presentation.ColoredBranchStatus(currentBranch) + " "
|
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())
|
status += style.FgYellow.Sprintf("(%s) ", gui.GitCommand.WorkingTreeState())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ func (gui *Gui) handleStatusClick() error {
|
|||||||
upstreamStatus := presentation.BranchStatus(currentBranch)
|
upstreamStatus := presentation.BranchStatus(currentBranch)
|
||||||
repoName := utils.GetCurrentRepoName()
|
repoName := utils.GetCurrentRepoName()
|
||||||
switch gui.GitCommand.WorkingTreeState() {
|
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())
|
workingTreeStatus := fmt.Sprintf("(%s)", gui.GitCommand.WorkingTreeState())
|
||||||
if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) {
|
if cursorInSubstring(cx, upstreamStatus+" ", workingTreeStatus) {
|
||||||
return gui.handleCreateRebaseOptionsMenu()
|
return gui.handleCreateRebaseOptionsMenu()
|
||||||
|
@ -2,6 +2,7 @@ package gui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"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/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -75,10 +76,10 @@ func (gui *Gui) handleViewSubCommitFiles() error {
|
|||||||
|
|
||||||
func (gui *Gui) switchToSubCommitsContext(refName string) error {
|
func (gui *Gui) switchToSubCommitsContext(refName string) error {
|
||||||
// need to populate my sub commits
|
// 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(
|
commits, err := loader.GetCommits(
|
||||||
commands.GetCommitsOptions{
|
loaders.GetCommitsOptions{
|
||||||
Limit: gui.State.Panels.Commits.LimitCommits,
|
Limit: gui.State.Panels.Commits.LimitCommits,
|
||||||
FilterPath: gui.State.Modes.Filtering.GetPath(),
|
FilterPath: gui.State.Modes.Filtering.GetPath(),
|
||||||
IncludeRebaseCommits: false,
|
IncludeRebaseCommits: false,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func (gui *Gui) reflogUndo() error {
|
|||||||
undoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit undo]"}
|
undoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit undo]"}
|
||||||
undoingStatus := gui.Tr.UndoingStatus
|
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)
|
return gui.createErrorPanel(gui.Tr.LcCantUndoWhileRebasing)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ func (gui *Gui) reflogRedo() error {
|
|||||||
redoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit redo]"}
|
redoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit redo]"}
|
||||||
redoingStatus := gui.Tr.RedoingStatus
|
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)
|
return gui.createErrorPanel(gui.Tr.LcCantRedoWhileRebasing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user