mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
refactor to group up more commonly used git command stuff
This commit is contained in:
@ -92,32 +92,27 @@ func NewGitCommandAux(
|
|||||||
// This is admittedly messy, but allows us to test each command struct in isolation,
|
// This is admittedly messy, but allows us to test each command struct in isolation,
|
||||||
// and allows for better namespacing when compared to having every method living
|
// and allows for better namespacing when compared to having every method living
|
||||||
// on the one struct.
|
// on the one struct.
|
||||||
|
// common ones are: cmn, osCommand, dotGitDir, configCommands
|
||||||
configCommands := git_commands.NewConfigCommands(cmn, gitConfig, repo)
|
configCommands := git_commands.NewConfigCommands(cmn, gitConfig, repo)
|
||||||
statusCommands := git_commands.NewStatusCommands(cmn, osCommand, repo, dotGitDir)
|
gitCommon := git_commands.NewGitCommon(cmn, cmd, osCommand, dotGitDir, repo, configCommands)
|
||||||
|
|
||||||
|
statusCommands := git_commands.NewStatusCommands(gitCommon)
|
||||||
fileLoader := loaders.NewFileLoader(cmn, cmd, configCommands)
|
fileLoader := loaders.NewFileLoader(cmn, cmd, configCommands)
|
||||||
flowCommands := git_commands.NewFlowCommands(cmn, cmd, configCommands)
|
flowCommands := git_commands.NewFlowCommands(gitCommon)
|
||||||
remoteCommands := git_commands.NewRemoteCommands(cmn, cmd)
|
remoteCommands := git_commands.NewRemoteCommands(gitCommon)
|
||||||
branchCommands := git_commands.NewBranchCommands(cmn, cmd)
|
branchCommands := git_commands.NewBranchCommands(gitCommon)
|
||||||
syncCommands := git_commands.NewSyncCommands(cmn, cmd)
|
syncCommands := git_commands.NewSyncCommands(gitCommon)
|
||||||
tagCommands := git_commands.NewTagCommands(cmn, cmd)
|
tagCommands := git_commands.NewTagCommands(gitCommon)
|
||||||
commitCommands := git_commands.NewCommitCommands(cmn, cmd)
|
commitCommands := git_commands.NewCommitCommands(gitCommon)
|
||||||
customCommands := git_commands.NewCustomCommands(cmn, cmd)
|
customCommands := git_commands.NewCustomCommands(gitCommon)
|
||||||
fileCommands := git_commands.NewFileCommands(cmn, cmd, configCommands, osCommand)
|
fileCommands := git_commands.NewFileCommands(gitCommon)
|
||||||
submoduleCommands := git_commands.NewSubmoduleCommands(cmn, cmd, dotGitDir)
|
submoduleCommands := git_commands.NewSubmoduleCommands(gitCommon)
|
||||||
workingTreeCommands := git_commands.NewWorkingTreeCommands(cmn, cmd, submoduleCommands, osCommand, fileLoader)
|
workingTreeCommands := git_commands.NewWorkingTreeCommands(gitCommon, submoduleCommands, fileLoader)
|
||||||
rebaseCommands := git_commands.NewRebaseCommands(
|
rebaseCommands := git_commands.NewRebaseCommands(gitCommon, commitCommands, workingTreeCommands)
|
||||||
cmn,
|
stashCommands := git_commands.NewStashCommands(gitCommon, fileLoader, workingTreeCommands)
|
||||||
cmd,
|
|
||||||
osCommand,
|
|
||||||
commitCommands,
|
|
||||||
workingTreeCommands,
|
|
||||||
configCommands,
|
|
||||||
dotGitDir,
|
|
||||||
)
|
|
||||||
stashCommands := git_commands.NewStashCommands(cmn, cmd, osCommand, fileLoader, workingTreeCommands)
|
|
||||||
// TODO: have patch manager take workingTreeCommands in its entirety
|
// TODO: have patch manager take workingTreeCommands in its entirety
|
||||||
patchManager := patch.NewPatchManager(cmn.Log, workingTreeCommands.ApplyPatch, workingTreeCommands.ShowFileDiff)
|
patchManager := patch.NewPatchManager(cmn.Log, workingTreeCommands.ApplyPatch, workingTreeCommands.ShowFileDiff)
|
||||||
patchCommands := git_commands.NewPatchCommands(cmn, cmd, rebaseCommands, commitCommands, configCommands, statusCommands, patchManager)
|
patchCommands := git_commands.NewPatchCommands(gitCommon, rebaseCommands, commitCommands, statusCommands, stashCommands, patchManager)
|
||||||
|
|
||||||
return &GitCommand{
|
return &GitCommand{
|
||||||
Branch: branchCommands,
|
Branch: branchCommands,
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,18 +16,12 @@ import (
|
|||||||
const CurrentBranchNameRegex = `(?m)^\*.*?([^ ]*?)\)?$`
|
const CurrentBranchNameRegex = `(?m)^\*.*?([^ ]*?)\)?$`
|
||||||
|
|
||||||
type BranchCommands struct {
|
type BranchCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBranchCommands(
|
func NewBranchCommands(gitCommon *GitCommon) *BranchCommands {
|
||||||
common *common.Common,
|
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
) *BranchCommands {
|
|
||||||
return &BranchCommands{
|
return &BranchCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,9 @@ import (
|
|||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBranchCommandsWithRunner(runner *oscommands.FakeCmdObjRunner) *BranchCommands {
|
|
||||||
builder := oscommands.NewDummyCmdObjBuilder(runner)
|
|
||||||
return NewBranchCommands(utils.NewDummyCommon(), builder)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBranchGetCommitDifferences(t *testing.T) {
|
func TestBranchGetCommitDifferences(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
testName string
|
testName string
|
||||||
@ -48,7 +42,7 @@ func TestBranchGetCommitDifferences(t *testing.T) {
|
|||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
s := s
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := buildBranchCommands(commonDeps{runner: s.runner})
|
||||||
pushables, pullables := instance.GetCommitDifferences("HEAD", "@{u}")
|
pushables, pullables := instance.GetCommitDifferences("HEAD", "@{u}")
|
||||||
assert.EqualValues(t, s.expectedPushables, pushables)
|
assert.EqualValues(t, s.expectedPushables, pushables)
|
||||||
assert.EqualValues(t, s.expectedPullables, pullables)
|
assert.EqualValues(t, s.expectedPullables, pullables)
|
||||||
@ -60,7 +54,7 @@ func TestBranchGetCommitDifferences(t *testing.T) {
|
|||||||
func TestBranchNewBranch(t *testing.T) {
|
func TestBranchNewBranch(t *testing.T) {
|
||||||
runner := oscommands.NewFakeRunner(t).
|
runner := oscommands.NewFakeRunner(t).
|
||||||
Expect(`git checkout -b "test" "master"`, "", nil)
|
Expect(`git checkout -b "test" "master"`, "", nil)
|
||||||
instance := NewBranchCommandsWithRunner(runner)
|
instance := buildBranchCommands(commonDeps{runner: runner})
|
||||||
|
|
||||||
assert.NoError(t, instance.New("test", "master"))
|
assert.NoError(t, instance.New("test", "master"))
|
||||||
runner.CheckForMissingCalls()
|
runner.CheckForMissingCalls()
|
||||||
@ -96,7 +90,7 @@ func TestBranchDeleteBranch(t *testing.T) {
|
|||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
s := s
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := buildBranchCommands(commonDeps{runner: s.runner})
|
||||||
|
|
||||||
s.test(instance.Delete("test", s.force))
|
s.test(instance.Delete("test", s.force))
|
||||||
s.runner.CheckForMissingCalls()
|
s.runner.CheckForMissingCalls()
|
||||||
@ -107,7 +101,7 @@ func TestBranchDeleteBranch(t *testing.T) {
|
|||||||
func TestBranchMerge(t *testing.T) {
|
func TestBranchMerge(t *testing.T) {
|
||||||
runner := oscommands.NewFakeRunner(t).
|
runner := oscommands.NewFakeRunner(t).
|
||||||
Expect(`git merge --no-edit "test"`, "", nil)
|
Expect(`git merge --no-edit "test"`, "", nil)
|
||||||
instance := NewBranchCommandsWithRunner(runner)
|
instance := buildBranchCommands(commonDeps{runner: runner})
|
||||||
|
|
||||||
assert.NoError(t, instance.Merge("test", MergeOpts{}))
|
assert.NoError(t, instance.Merge("test", MergeOpts{}))
|
||||||
runner.CheckForMissingCalls()
|
runner.CheckForMissingCalls()
|
||||||
@ -143,7 +137,7 @@ func TestBranchCheckout(t *testing.T) {
|
|||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
s := s
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := buildBranchCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.Checkout("test", CheckoutOptions{Force: s.force}))
|
s.test(instance.Checkout("test", CheckoutOptions{Force: s.force}))
|
||||||
s.runner.CheckForMissingCalls()
|
s.runner.CheckForMissingCalls()
|
||||||
})
|
})
|
||||||
@ -154,7 +148,7 @@ func TestBranchGetBranchGraph(t *testing.T) {
|
|||||||
runner := oscommands.NewFakeRunner(t).ExpectGitArgs([]string{
|
runner := oscommands.NewFakeRunner(t).ExpectGitArgs([]string{
|
||||||
"log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--",
|
"log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--",
|
||||||
}, "", nil)
|
}, "", nil)
|
||||||
instance := NewBranchCommandsWithRunner(runner)
|
instance := buildBranchCommands(commonDeps{runner: runner})
|
||||||
_, err := instance.GetGraph("test")
|
_, err := instance.GetGraph("test")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
@ -163,7 +157,7 @@ func TestBranchGetAllBranchGraph(t *testing.T) {
|
|||||||
runner := oscommands.NewFakeRunner(t).ExpectGitArgs([]string{
|
runner := oscommands.NewFakeRunner(t).ExpectGitArgs([]string{
|
||||||
"log", "--graph", "--all", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium",
|
"log", "--graph", "--all", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium",
|
||||||
}, "", nil)
|
}, "", nil)
|
||||||
instance := NewBranchCommandsWithRunner(runner)
|
instance := buildBranchCommands(commonDeps{runner: runner})
|
||||||
err := instance.AllBranchesLogCmdObj().Run()
|
err := instance.AllBranchesLogCmdObj().Run()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
@ -223,7 +217,7 @@ func TestBranchCurrentBranchName(t *testing.T) {
|
|||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
s := s
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := buildBranchCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.CurrentBranchName())
|
s.test(instance.CurrentBranchName())
|
||||||
s.runner.CheckForMissingCalls()
|
s.runner.CheckForMissingCalls()
|
||||||
})
|
})
|
||||||
|
@ -5,22 +5,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CommitCommands struct {
|
type CommitCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommitCommands(
|
func NewCommitCommands(gitCommon *GitCommon) *CommitCommands {
|
||||||
common *common.Common,
|
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
) *CommitCommands {
|
|
||||||
return &CommitCommands{
|
return &CommitCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
pkg/commands/git_commands/common.go
Normal file
34
pkg/commands/git_commands/common.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package git_commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
gogit "github.com/jesseduffield/go-git/v5"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GitCommon struct {
|
||||||
|
*common.Common
|
||||||
|
cmd oscommands.ICmdObjBuilder
|
||||||
|
os *oscommands.OSCommand
|
||||||
|
dotGitDir string
|
||||||
|
repo *gogit.Repository
|
||||||
|
config *ConfigCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGitCommon(
|
||||||
|
cmn *common.Common,
|
||||||
|
cmd oscommands.ICmdObjBuilder,
|
||||||
|
osCommand *oscommands.OSCommand,
|
||||||
|
dotGitDir string,
|
||||||
|
repo *gogit.Repository,
|
||||||
|
config *ConfigCommands,
|
||||||
|
) *GitCommon {
|
||||||
|
return &GitCommon{
|
||||||
|
Common: cmn,
|
||||||
|
cmd: cmd,
|
||||||
|
os: osCommand,
|
||||||
|
dotGitDir: dotGitDir,
|
||||||
|
repo: repo,
|
||||||
|
config: config,
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +1,12 @@
|
|||||||
package git_commands
|
package git_commands
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CustomCommands struct {
|
type CustomCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCustomCommands(
|
func NewCustomCommands(gitCommon *GitCommon) *CustomCommands {
|
||||||
common *common.Common,
|
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
) *CustomCommands {
|
|
||||||
return &CustomCommands{
|
return &CustomCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,120 +22,123 @@ type commonDeps struct {
|
|||||||
cmd *oscommands.CmdObjBuilder
|
cmd *oscommands.CmdObjBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeDeps(deps commonDeps) commonDeps {
|
func buildGitCommon(deps commonDeps) *GitCommon {
|
||||||
if deps.runner == nil {
|
gitCommon := &GitCommon{}
|
||||||
deps.runner = oscommands.NewFakeRunner(nil)
|
|
||||||
|
gitCommon.Common = deps.common
|
||||||
|
if gitCommon.Common == nil {
|
||||||
|
gitCommon.Common = utils.NewDummyCommonWithUserConfig(deps.userConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.userConfig == nil {
|
runner := deps.runner
|
||||||
deps.userConfig = config.GetDefaultConfig()
|
if runner == nil {
|
||||||
|
runner = oscommands.NewFakeRunner(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.gitConfig == nil {
|
cmd := deps.cmd
|
||||||
deps.gitConfig = git_config.NewFakeGitConfig(nil)
|
// gotta check deps.cmd because it's not an interface type and an interface value of nil is not considered to be nil
|
||||||
|
if cmd == nil {
|
||||||
|
cmd = oscommands.NewDummyCmdObjBuilder(runner)
|
||||||
|
}
|
||||||
|
gitCommon.cmd = cmd
|
||||||
|
|
||||||
|
gitCommon.Common.UserConfig = deps.userConfig
|
||||||
|
if gitCommon.Common.UserConfig == nil {
|
||||||
|
gitCommon.Common.UserConfig = config.GetDefaultConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.getenv == nil {
|
gitConfig := deps.gitConfig
|
||||||
deps.getenv = func(string) string { return "" }
|
if gitConfig == nil {
|
||||||
|
gitConfig = git_config.NewFakeGitConfig(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.removeFile == nil {
|
gitCommon.repo = buildRepo()
|
||||||
deps.removeFile = func(string) error { return errors.New("unexpected call to removeFile") }
|
gitCommon.config = NewConfigCommands(gitCommon.Common, gitConfig, gitCommon.repo)
|
||||||
|
|
||||||
|
getenv := deps.getenv
|
||||||
|
if getenv == nil {
|
||||||
|
getenv = func(string) string { return "" }
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.dotGitDir == "" {
|
removeFile := deps.removeFile
|
||||||
deps.dotGitDir = ".git"
|
if removeFile == nil {
|
||||||
|
removeFile = func(string) error { return errors.New("unexpected call to removeFile") }
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.common == nil {
|
gitCommon.os = oscommands.NewDummyOSCommandWithDeps(oscommands.OSCommandDeps{
|
||||||
deps.common = utils.NewDummyCommonWithUserConfig(deps.userConfig)
|
Common: gitCommon.Common,
|
||||||
}
|
GetenvFn: getenv,
|
||||||
|
Cmd: cmd,
|
||||||
if deps.cmd == nil {
|
RemoveFileFn: removeFile,
|
||||||
deps.cmd = oscommands.NewDummyCmdObjBuilder(deps.runner)
|
|
||||||
}
|
|
||||||
|
|
||||||
return deps
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildConfigCommands(deps commonDeps) *ConfigCommands {
|
|
||||||
deps = completeDeps(deps)
|
|
||||||
common := utils.NewDummyCommonWithUserConfig(deps.userConfig)
|
|
||||||
|
|
||||||
// TODO: think of a way to actually mock this outnil
|
|
||||||
var repo *gogit.Repository = nil
|
|
||||||
|
|
||||||
return NewConfigCommands(common, deps.gitConfig, repo)
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildOSCommand(deps commonDeps) *oscommands.OSCommand {
|
|
||||||
deps = completeDeps(deps)
|
|
||||||
|
|
||||||
return oscommands.NewDummyOSCommandWithDeps(oscommands.OSCommandDeps{
|
|
||||||
Common: deps.common,
|
|
||||||
GetenvFn: deps.getenv,
|
|
||||||
Cmd: deps.cmd,
|
|
||||||
RemoveFileFn: deps.removeFile,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gitCommon.dotGitDir = deps.dotGitDir
|
||||||
|
if gitCommon.dotGitDir == "" {
|
||||||
|
gitCommon.dotGitDir = ".git"
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFileLoader(deps commonDeps) *loaders.FileLoader {
|
func buildRepo() *gogit.Repository {
|
||||||
deps = completeDeps(deps)
|
// TODO: think of a way to actually mock this out
|
||||||
|
var repo *gogit.Repository = nil
|
||||||
|
return repo
|
||||||
|
}
|
||||||
|
|
||||||
configCommands := buildConfigCommands(deps)
|
func buildFileLoader(gitCommon *GitCommon) *loaders.FileLoader {
|
||||||
|
return loaders.NewFileLoader(gitCommon.Common, gitCommon.cmd, gitCommon.config)
|
||||||
return loaders.NewFileLoader(deps.common, deps.cmd, configCommands)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSubmoduleCommands(deps commonDeps) *SubmoduleCommands {
|
func buildSubmoduleCommands(deps commonDeps) *SubmoduleCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
|
|
||||||
return NewSubmoduleCommands(deps.common, deps.cmd, deps.dotGitDir)
|
return NewSubmoduleCommands(gitCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildCommitCommands(deps commonDeps) *CommitCommands {
|
func buildCommitCommands(deps commonDeps) *CommitCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
return NewCommitCommands(deps.common, deps.cmd)
|
return NewCommitCommands(gitCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildWorkingTreeCommands(deps commonDeps) *WorkingTreeCommands {
|
func buildWorkingTreeCommands(deps commonDeps) *WorkingTreeCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
osCommand := buildOSCommand(deps)
|
|
||||||
submoduleCommands := buildSubmoduleCommands(deps)
|
submoduleCommands := buildSubmoduleCommands(deps)
|
||||||
fileLoader := buildFileLoader(deps)
|
fileLoader := buildFileLoader(gitCommon)
|
||||||
|
|
||||||
return NewWorkingTreeCommands(deps.common, deps.cmd, submoduleCommands, osCommand, fileLoader)
|
return NewWorkingTreeCommands(gitCommon, submoduleCommands, fileLoader)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildStashCommands(deps commonDeps) *StashCommands {
|
func buildStashCommands(deps commonDeps) *StashCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
osCommand := buildOSCommand(deps)
|
fileLoader := buildFileLoader(gitCommon)
|
||||||
fileLoader := buildFileLoader(deps)
|
|
||||||
workingTreeCommands := buildWorkingTreeCommands(deps)
|
workingTreeCommands := buildWorkingTreeCommands(deps)
|
||||||
|
|
||||||
return NewStashCommands(deps.common, deps.cmd, osCommand, fileLoader, workingTreeCommands)
|
return NewStashCommands(gitCommon, fileLoader, workingTreeCommands)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildRebaseCommands(deps commonDeps) *RebaseCommands {
|
func buildRebaseCommands(deps commonDeps) *RebaseCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
configCommands := buildConfigCommands(deps)
|
|
||||||
osCommand := buildOSCommand(deps)
|
|
||||||
workingTreeCommands := buildWorkingTreeCommands(deps)
|
workingTreeCommands := buildWorkingTreeCommands(deps)
|
||||||
commitCommands := buildCommitCommands(deps)
|
commitCommands := buildCommitCommands(deps)
|
||||||
|
|
||||||
return NewRebaseCommands(deps.common, deps.cmd, osCommand, commitCommands, workingTreeCommands, configCommands, deps.dotGitDir)
|
return NewRebaseCommands(gitCommon, commitCommands, workingTreeCommands)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSyncCommands(deps commonDeps) *SyncCommands {
|
func buildSyncCommands(deps commonDeps) *SyncCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
|
|
||||||
return NewSyncCommands(deps.common, deps.cmd)
|
return NewSyncCommands(gitCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFileCommands(deps commonDeps) *FileCommands {
|
func buildFileCommands(deps commonDeps) *FileCommands {
|
||||||
deps = completeDeps(deps)
|
gitCommon := buildGitCommon(deps)
|
||||||
configCommands := buildConfigCommands(deps)
|
|
||||||
osCommand := buildOSCommand(deps)
|
|
||||||
|
|
||||||
return NewFileCommands(deps.common, deps.cmd, configCommands, osCommand)
|
return NewFileCommands(gitCommon)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildBranchCommands(deps commonDeps) *BranchCommands {
|
||||||
|
gitCommon := buildGitCommon(deps)
|
||||||
|
|
||||||
|
return NewBranchCommands(gitCommon)
|
||||||
}
|
}
|
||||||
|
@ -5,34 +5,16 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileCommands struct {
|
type FileCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
config *ConfigCommands
|
|
||||||
os FileOSCommand
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileOSCommand interface {
|
func NewFileCommands(gitCommon *GitCommon) *FileCommands {
|
||||||
Getenv(string) string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFileCommands(
|
|
||||||
common *common.Common,
|
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
config *ConfigCommands,
|
|
||||||
osCommand FileOSCommand,
|
|
||||||
) *FileCommands {
|
|
||||||
return &FileCommands{
|
return &FileCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
config: config,
|
|
||||||
os: osCommand,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,25 +6,17 @@ import (
|
|||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type FlowCommands struct {
|
type FlowCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
config *ConfigCommands
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFlowCommands(
|
func NewFlowCommands(
|
||||||
common *common.Common,
|
gitCommon *GitCommon,
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
config *ConfigCommands,
|
|
||||||
) *FlowCommands {
|
) *FlowCommands {
|
||||||
return &FlowCommands{
|
return &FlowCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
config: config,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,40 +5,34 @@ 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/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PatchCommands struct {
|
type PatchCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
rebase *RebaseCommands
|
||||||
|
commit *CommitCommands
|
||||||
|
status *StatusCommands
|
||||||
|
stash *StashCommands
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
rebase *RebaseCommands
|
|
||||||
commit *CommitCommands
|
|
||||||
config *ConfigCommands
|
|
||||||
stash *StashCommands
|
|
||||||
status *StatusCommands
|
|
||||||
PatchManager *patch.PatchManager
|
PatchManager *patch.PatchManager
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPatchCommands(
|
func NewPatchCommands(
|
||||||
common *common.Common,
|
gitCommon *GitCommon,
|
||||||
cmd oscommands.ICmdObjBuilder,
|
rebase *RebaseCommands,
|
||||||
rebaseCommands *RebaseCommands,
|
commit *CommitCommands,
|
||||||
commitCommands *CommitCommands,
|
status *StatusCommands,
|
||||||
configCommands *ConfigCommands,
|
stash *StashCommands,
|
||||||
statusCommands *StatusCommands,
|
|
||||||
patchManager *patch.PatchManager,
|
patchManager *patch.PatchManager,
|
||||||
) *PatchCommands {
|
) *PatchCommands {
|
||||||
return &PatchCommands{
|
return &PatchCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
rebase: rebase,
|
||||||
rebase: rebaseCommands,
|
commit: commit,
|
||||||
commit: commitCommands,
|
status: status,
|
||||||
config: configCommands,
|
stash: stash,
|
||||||
status: statusCommands,
|
|
||||||
PatchManager: patchManager,
|
PatchManager: patchManager,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,39 +9,25 @@ 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/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RebaseCommands struct {
|
type RebaseCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
commit *CommitCommands
|
||||||
|
workingTree *WorkingTreeCommands
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
osCommand *oscommands.OSCommand
|
|
||||||
|
|
||||||
commit *CommitCommands
|
|
||||||
workingTree *WorkingTreeCommands
|
|
||||||
config *ConfigCommands
|
|
||||||
dotGitDir string
|
|
||||||
onSuccessfulContinue func() error
|
onSuccessfulContinue func() error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRebaseCommands(
|
func NewRebaseCommands(
|
||||||
common *common.Common,
|
gitCommon *GitCommon,
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
osCommand *oscommands.OSCommand,
|
|
||||||
commitCommands *CommitCommands,
|
commitCommands *CommitCommands,
|
||||||
workingTreeCommands *WorkingTreeCommands,
|
workingTreeCommands *WorkingTreeCommands,
|
||||||
configCommands *ConfigCommands,
|
|
||||||
dotGitDir string,
|
|
||||||
) *RebaseCommands {
|
) *RebaseCommands {
|
||||||
return &RebaseCommands{
|
return &RebaseCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
osCommand: osCommand,
|
|
||||||
commit: commitCommands,
|
commit: commitCommands,
|
||||||
workingTree: workingTreeCommands,
|
workingTree: workingTreeCommands,
|
||||||
config: configCommands,
|
|
||||||
dotGitDir: dotGitDir,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +105,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo
|
|||||||
if todo == "" {
|
if todo == "" {
|
||||||
gitSequenceEditor = "true"
|
gitSequenceEditor = "true"
|
||||||
} else {
|
} else {
|
||||||
self.osCommand.LogCommand(fmt.Sprintf("Creating TODO file for interactive rebase: \n\n%s", todo), false)
|
self.os.LogCommand(fmt.Sprintf("Creating TODO file for interactive rebase: \n\n%s", todo), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdObj.AddEnvVars(
|
cmdObj.AddEnvVars(
|
||||||
@ -328,7 +314,7 @@ func (self *RebaseCommands) DiscardOldFileChanges(commits []*models.Commit, comm
|
|||||||
|
|
||||||
// check if file exists in previous commit (this command returns an error if the file doesn't exist)
|
// check if file exists in previous commit (this command returns an error if the file doesn't exist)
|
||||||
if err := self.cmd.New("git cat-file -e HEAD^:" + self.cmd.Quote(fileName)).Run(); err != nil {
|
if err := self.cmd.New("git cat-file -e HEAD^:" + self.cmd.Quote(fileName)).Run(); err != nil {
|
||||||
if err := self.osCommand.Remove(fileName); err != nil {
|
if err := self.os.Remove(fileName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := self.workingTree.StageFile(fileName); err != nil {
|
if err := self.workingTree.StageFile(fileName); err != nil {
|
||||||
|
@ -2,24 +2,15 @@ package git_commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RemoteCommands struct {
|
type RemoteCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRemoteCommands(
|
func NewRemoteCommands(gitCommon *GitCommon) *RemoteCommands {
|
||||||
common *common.Common,
|
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
) *RemoteCommands {
|
|
||||||
return &RemoteCommands{
|
return &RemoteCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,30 +5,22 @@ import (
|
|||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
|
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StashCommands struct {
|
type StashCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
fileLoader *loaders.FileLoader
|
fileLoader *loaders.FileLoader
|
||||||
osCommand *oscommands.OSCommand
|
|
||||||
workingTree *WorkingTreeCommands
|
workingTree *WorkingTreeCommands
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStashCommands(
|
func NewStashCommands(
|
||||||
common *common.Common,
|
gitCommon *GitCommon,
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
osCommand *oscommands.OSCommand,
|
|
||||||
fileLoader *loaders.FileLoader,
|
fileLoader *loaders.FileLoader,
|
||||||
workingTree *WorkingTreeCommands,
|
workingTree *WorkingTreeCommands,
|
||||||
) *StashCommands {
|
) *StashCommands {
|
||||||
return &StashCommands{
|
return &StashCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
fileLoader: fileLoader,
|
fileLoader: fileLoader,
|
||||||
osCommand: osCommand,
|
|
||||||
workingTree: workingTree,
|
workingTree: workingTree,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,7 +65,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.osCommand.PipeCommands("git stash show -p", "git apply -R"); err != nil {
|
if err := self.os.PipeCommands("git stash show -p", "git apply -R"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,43 +4,32 @@ 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/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StatusCommands struct {
|
type StatusCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
osCommand *oscommands.OSCommand
|
|
||||||
repo *gogit.Repository
|
|
||||||
dotGitDir string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStatusCommands(
|
func NewStatusCommands(
|
||||||
common *common.Common,
|
gitCommon *GitCommon,
|
||||||
osCommand *oscommands.OSCommand,
|
|
||||||
repo *gogit.Repository,
|
|
||||||
dotGitDir string,
|
|
||||||
) *StatusCommands {
|
) *StatusCommands {
|
||||||
return &StatusCommands{
|
return &StatusCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
osCommand: osCommand,
|
|
||||||
repo: repo,
|
|
||||||
dotGitDir: dotGitDir,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 (self *StatusCommands) RebaseMode() (enums.RebaseMode, error) {
|
func (self *StatusCommands) RebaseMode() (enums.RebaseMode, error) {
|
||||||
exists, err := self.osCommand.FileExists(filepath.Join(self.dotGitDir, "rebase-apply"))
|
exists, err := self.os.FileExists(filepath.Join(self.dotGitDir, "rebase-apply"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return enums.REBASE_MODE_NONE, err
|
return enums.REBASE_MODE_NONE, err
|
||||||
}
|
}
|
||||||
if exists {
|
if exists {
|
||||||
return enums.REBASE_MODE_NORMAL, nil
|
return enums.REBASE_MODE_NORMAL, nil
|
||||||
}
|
}
|
||||||
exists, err = self.osCommand.FileExists(filepath.Join(self.dotGitDir, "rebase-merge"))
|
exists, err = self.os.FileExists(filepath.Join(self.dotGitDir, "rebase-merge"))
|
||||||
if exists {
|
if exists {
|
||||||
return enums.REBASE_MODE_INTERACTIVE, err
|
return enums.REBASE_MODE_INTERACTIVE, err
|
||||||
} else {
|
} else {
|
||||||
@ -62,7 +51,7 @@ func (self *StatusCommands) WorkingTreeState() enums.RebaseMode {
|
|||||||
|
|
||||||
// IsInMergeState states whether we are still mid-merge
|
// IsInMergeState states whether we are still mid-merge
|
||||||
func (self *StatusCommands) IsInMergeState() (bool, error) {
|
func (self *StatusCommands) IsInMergeState() (bool, error) {
|
||||||
return self.osCommand.FileExists(filepath.Join(self.dotGitDir, "MERGE_HEAD"))
|
return self.os.FileExists(filepath.Join(self.dotGitDir, "MERGE_HEAD"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StatusCommands) IsBareRepo() bool {
|
func (self *StatusCommands) IsBareRepo() bool {
|
||||||
|
@ -10,7 +10,6 @@ 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/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// .gitmodules looks like this:
|
// .gitmodules looks like this:
|
||||||
@ -19,17 +18,12 @@ import (
|
|||||||
// url = git@github.com:subbo.git
|
// url = git@github.com:subbo.git
|
||||||
|
|
||||||
type SubmoduleCommands struct {
|
type SubmoduleCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
dotGitDir string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSubmoduleCommands(common *common.Common, cmd oscommands.ICmdObjBuilder, dotGitDir string) *SubmoduleCommands {
|
func NewSubmoduleCommands(gitCommon *GitCommon) *SubmoduleCommands {
|
||||||
return &SubmoduleCommands{
|
return &SubmoduleCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
dotGitDir: dotGitDir,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,22 +5,15 @@ import (
|
|||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SyncCommands struct {
|
type SyncCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSyncCommands(
|
func NewSyncCommands(gitCommon *GitCommon) *SyncCommands {
|
||||||
common *common.Common,
|
|
||||||
cmd oscommands.ICmdObjBuilder,
|
|
||||||
) *SyncCommands {
|
|
||||||
return &SyncCommands{
|
return &SyncCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,21 +2,15 @@ package git_commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TagCommands struct {
|
type TagCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTagCommands(common *common.Common, cmd oscommands.ICmdObjBuilder) *TagCommands {
|
func NewTagCommands(gitCommon *GitCommon) *TagCommands {
|
||||||
return &TagCommands{
|
return &TagCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,38 +10,24 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
|
"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/common"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
"github.com/jesseduffield/lazygit/pkg/gui/filetree"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkingTreeCommands struct {
|
type WorkingTreeCommands struct {
|
||||||
*common.Common
|
*GitCommon
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
|
||||||
os WorkingTreeOSCommand
|
|
||||||
submodule *SubmoduleCommands
|
submodule *SubmoduleCommands
|
||||||
fileLoader *loaders.FileLoader
|
fileLoader *loaders.FileLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
type WorkingTreeOSCommand interface {
|
|
||||||
RemoveFile(string) error
|
|
||||||
CreateFileWithContent(string, string) error
|
|
||||||
AppendLineToFile(string, string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewWorkingTreeCommands(
|
func NewWorkingTreeCommands(
|
||||||
common *common.Common,
|
gitCommon *GitCommon,
|
||||||
cmd oscommands.ICmdObjBuilder,
|
submodule *SubmoduleCommands,
|
||||||
submoduleCommands *SubmoduleCommands,
|
|
||||||
osCommand WorkingTreeOSCommand,
|
|
||||||
fileLoader *loaders.FileLoader,
|
fileLoader *loaders.FileLoader,
|
||||||
) *WorkingTreeCommands {
|
) *WorkingTreeCommands {
|
||||||
return &WorkingTreeCommands{
|
return &WorkingTreeCommands{
|
||||||
Common: common,
|
GitCommon: gitCommon,
|
||||||
cmd: cmd,
|
submodule: submodule,
|
||||||
os: osCommand,
|
|
||||||
submodule: submoduleCommands,
|
|
||||||
fileLoader: fileLoader,
|
fileLoader: fileLoader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user