From a930f74397a8841b7ec1bf36828a89f9a1f73718 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 26 Mar 2026 09:30:21 +0100 Subject: [PATCH] Remove go-git repo from GitCommon It is no longer used now. --- pkg/commands/git.go | 17 +---------------- pkg/commands/git_commands/common.go | 4 ---- pkg/commands/git_commands/deps_test.go | 8 -------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index ab0e8d354..bcb6440dc 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -2,11 +2,9 @@ package commands import ( "os" - "strings" "github.com/go-errors/errors" - gogit "github.com/jesseduffield/go-git/v5" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" @@ -72,24 +70,12 @@ func NewGitCommand( return nil, utils.WrapError(err) } - repository, err := gogit.PlainOpenWithOptions( - repoPaths.WorktreeGitDirPath(), - &gogit.PlainOpenOptions{DetectDotGit: false, EnableDotGitCommonDir: true}, - ) - if err != nil { - if strings.Contains(err.Error(), `unquoted '\' must be followed by new line`) { - return nil, errors.New(cmn.Tr.GitconfigParseErr) - } - return nil, err - } - return NewGitCommandAux( cmn, version, osCommand, gitConfig, repoPaths, - repository, pagerConfig, ), nil } @@ -100,7 +86,6 @@ func NewGitCommandAux( osCommand *oscommands.OSCommand, gitConfig git_config.IGitConfig, repoPaths *git_commands.RepoPaths, - repo *gogit.Repository, pagerConfig *config.PagerConfig, ) *GitCommand { cmd := NewGitCmdObjBuilder(cmn.Log, osCommand.Cmd) @@ -112,7 +97,7 @@ func NewGitCommandAux( // common ones are: cmn, osCommand, dotGitDir, configCommands configCommands := git_commands.NewConfigCommands(cmn, gitConfig) - gitCommon := git_commands.NewGitCommon(cmn, version, cmd, osCommand, repoPaths, repo, configCommands, pagerConfig) + gitCommon := git_commands.NewGitCommon(cmn, version, cmd, osCommand, repoPaths, configCommands, pagerConfig) fileLoader := git_commands.NewFileLoader(gitCommon, cmd, configCommands) statusCommands := git_commands.NewStatusCommands(gitCommon) diff --git a/pkg/commands/git_commands/common.go b/pkg/commands/git_commands/common.go index 28dd78e8b..ba3b64d7f 100644 --- a/pkg/commands/git_commands/common.go +++ b/pkg/commands/git_commands/common.go @@ -1,7 +1,6 @@ package git_commands import ( - gogit "github.com/jesseduffield/go-git/v5" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" @@ -13,7 +12,6 @@ type GitCommon struct { cmd oscommands.ICmdObjBuilder os *oscommands.OSCommand repoPaths *RepoPaths - repo *gogit.Repository config *ConfigCommands pagerConfig *config.PagerConfig } @@ -24,7 +22,6 @@ func NewGitCommon( cmd oscommands.ICmdObjBuilder, osCommand *oscommands.OSCommand, repoPaths *RepoPaths, - repo *gogit.Repository, config *ConfigCommands, pagerConfig *config.PagerConfig, ) *GitCommon { @@ -34,7 +31,6 @@ func NewGitCommon( cmd: cmd, os: osCommand, repoPaths: repoPaths, - repo: repo, config: config, pagerConfig: pagerConfig, } diff --git a/pkg/commands/git_commands/deps_test.go b/pkg/commands/git_commands/deps_test.go index 9af509004..87deefde7 100644 --- a/pkg/commands/git_commands/deps_test.go +++ b/pkg/commands/git_commands/deps_test.go @@ -4,7 +4,6 @@ import ( "os" "github.com/go-errors/errors" - gogit "github.com/jesseduffield/go-git/v5" "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" @@ -75,7 +74,6 @@ func buildGitCommon(deps commonDeps) *GitCommon { gitConfig = git_config.NewFakeGitConfig(nil) } - gitCommon.repo = buildRepo() gitCommon.config = NewConfigCommands(gitCommon.Common, gitConfig) getenv := deps.getenv @@ -99,12 +97,6 @@ func buildGitCommon(deps commonDeps) *GitCommon { return gitCommon } -func buildRepo() *gogit.Repository { - // TODO: think of a way to actually mock this out - var repo *gogit.Repository - return repo -} - func buildFileLoader(gitCommon *GitCommon) *FileLoader { return NewFileLoader(gitCommon, gitCommon.cmd, gitCommon.config) }