diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-02 10:34:33 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-09 14:09:53 +1100 |
commit | f503ff1ecbfda00dfa4e68e38d41aceaf9b4400c (patch) | |
tree | e113663684406ca893ebb9c223d1fddbc65abea9 /pkg/commands/loaders | |
parent | 4a1d23dc27f61e936fb3b582f02e2bba473c3b19 (diff) |
start breaking up git struct
Diffstat (limited to 'pkg/commands/loaders')
-rw-r--r-- | pkg/commands/loaders/branches.go | 12 | ||||
-rw-r--r-- | pkg/commands/loaders/commits.go | 20 | ||||
-rw-r--r-- | pkg/commands/loaders/files.go | 11 |
3 files changed, 20 insertions, 23 deletions
diff --git a/pkg/commands/loaders/branches.go b/pkg/commands/loaders/branches.go index f0e2e43b5..877b228f2 100644 --- a/pkg/commands/loaders/branches.go +++ b/pkg/commands/loaders/branches.go @@ -27,19 +27,15 @@ type BranchLoader struct { getCurrentBranchName func() (string, string, error) } -type BranchLoaderGitCommand interface { - GetRawBranches() (string, error) - CurrentBranchName() (string, string, error) -} - func NewBranchLoader( cmn *common.Common, - gitCommand BranchLoaderGitCommand, + getRawBranches func() (string, error), + getCurrentBranchName func() (string, string, error), ) *BranchLoader { return &BranchLoader{ Common: cmn, - getRawBranches: gitCommand.GetRawBranches, - getCurrentBranchName: gitCommand.CurrentBranchName, + getRawBranches: getRawBranches, + getCurrentBranchName: getCurrentBranchName, } } diff --git a/pkg/commands/loaders/commits.go b/pkg/commands/loaders/commits.go index 28bcbb3a7..cc2442c96 100644 --- a/pkg/commands/loaders/commits.go +++ b/pkg/commands/loaders/commits.go @@ -36,26 +36,22 @@ type CommitLoader struct { dotGitDir string } -type CommitLoaderGitCommand interface { - CurrentBranchName() (string, string, error) - RebaseMode() (enums.RebaseMode, error) - GetCmd() oscommands.ICmdObjBuilder - GetDotGitDir() string -} - // making our dependencies explicit for the sake of easier testing func NewCommitLoader( cmn *common.Common, - gitCommand CommitLoaderGitCommand, + cmd oscommands.ICmdObjBuilder, + dotGitDir string, + getCurrentBranchName func() (string, string, error), + getRebaseMode func() (enums.RebaseMode, error), ) *CommitLoader { return &CommitLoader{ Common: cmn, - cmd: gitCommand.GetCmd(), - getCurrentBranchName: gitCommand.CurrentBranchName, - getRebaseMode: gitCommand.RebaseMode, + cmd: cmd, + getCurrentBranchName: getCurrentBranchName, + getRebaseMode: getRebaseMode, readFile: ioutil.ReadFile, walkFiles: filepath.Walk, - dotGitDir: gitCommand.GetDotGitDir(), + dotGitDir: dotGitDir, } } diff --git a/pkg/commands/loaders/files.go b/pkg/commands/loaders/files.go index 8f6eb32f4..3baa84c7c 100644 --- a/pkg/commands/loaders/files.go +++ b/pkg/commands/loaders/files.go @@ -11,19 +11,24 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) +type FileLoaderConfig interface { + GetShowUntrackedFiles() string +} + type FileLoader struct { *common.Common cmd oscommands.ICmdObjBuilder + config FileLoaderConfig gitConfig git_config.IGitConfig getFileType func(string) string } -func NewFileLoader(cmn *common.Common, cmd oscommands.ICmdObjBuilder, gitConfig git_config.IGitConfig) *FileLoader { +func NewFileLoader(cmn *common.Common, cmd oscommands.ICmdObjBuilder, config FileLoaderConfig) *FileLoader { return &FileLoader{ Common: cmn, cmd: cmd, - gitConfig: gitConfig, getFileType: oscommands.FileType, + config: config, } } @@ -33,7 +38,7 @@ type GetStatusFileOptions struct { func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File { // check if config wants us ignoring untracked files - untrackedFilesSetting := self.gitConfig.Get("status.showUntrackedFiles") + untrackedFilesSetting := self.config.GetShowUntrackedFiles() if untrackedFilesSetting == "" { untrackedFilesSetting = "all" |