diff options
author | Toon Claes <toon@gitlab.com> | 2022-09-09 12:20:33 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2022-10-03 16:26:16 +0300 |
commit | a509dad104653e80d9b39b7e69b57d8e6d61e4fe (patch) | |
tree | 211e00e51fc0e6d081be3b3961c28b7bfa32e63a | |
parent | 19c093150080262b0ba794317083c476e3c14976 (diff) |
linguist: Remove linguist instantiation dependency
Now linguist no longer loads colors when it's created, there's no more
need to create an instance when Gitaly is started. So remove linguist as
a dependency.
-rw-r--r-- | cmd/gitaly/main.go | 7 | ||||
-rw-r--r-- | internal/git/remoterepo/repository_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/linguist/linguist.go | 7 | ||||
-rw-r--r-- | internal/gitaly/service/commit/languages.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/commit/server.go | 8 | ||||
-rw-r--r-- | internal/gitaly/service/commit/testhelper_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/conflicts/testhelper_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/dependencies.go | 7 | ||||
-rw-r--r-- | internal/gitaly/service/operations/testhelper_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/repository/testhelper_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/setup/register.go | 2 | ||||
-rw-r--r-- | internal/testhelper/testserver/gitaly.go | 9 |
12 files changed, 14 insertions, 38 deletions
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go index e3f359ffa..805ac336a 100644 --- a/cmd/gitaly/main.go +++ b/cmd/gitaly/main.go @@ -29,7 +29,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config/sentry" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/hook" - "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/linguist" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/maintenance" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/rubyserver" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/server" @@ -287,11 +286,6 @@ func run(cfg config.Cfg) error { ) defer gitalyServerFactory.Stop() - ling, err := linguist.New(cfg) - if err != nil { - return fmt.Errorf("linguist instance creation: %w", err) - } - git2goExecutor := git2go.NewExecutor(cfg, gitCmdFactory, locator) updaterWithHooks := updateref.NewUpdaterWithHooks(cfg, locator, hookManager, gitCmdFactory, catfileCache) @@ -337,7 +331,6 @@ func run(cfg config.Cfg) error { StorageLocator: locator, ClientPool: conns, GitCmdFactory: gitCmdFactory, - Linguist: ling, CatfileCache: catfileCache, DiskCache: diskCache, PackObjectsCache: streamCache, diff --git a/internal/git/remoterepo/repository_test.go b/internal/git/remoterepo/repository_test.go index f7b3f5345..5a8081d2c 100644 --- a/internal/git/remoterepo/repository_test.go +++ b/internal/git/remoterepo/repository_test.go @@ -39,9 +39,9 @@ func TestRepository(t *testing.T) { deps.GetHousekeepingManager(), )) gitalypb.RegisterCommitServiceServer(srv, commit.NewServer( + deps.GetCfg(), deps.GetLocator(), deps.GetGitCmdFactory(), - deps.GetLinguist(), deps.GetCatfileCache(), )) gitalypb.RegisterRefServiceServer(srv, ref.NewServer( diff --git a/internal/gitaly/linguist/linguist.go b/internal/gitaly/linguist/linguist.go index e22b583ab..28a1c8826 100644 --- a/internal/gitaly/linguist/linguist.go +++ b/internal/gitaly/linguist/linguist.go @@ -29,12 +29,11 @@ type Instance struct { cfg config.Cfg } -// New loads the name->color map from the Linguist gem and returns initialized -// instance to use back to the caller or an error. -func New(cfg config.Cfg) (*Instance, error) { +// New creates a new instance that can be used to calculate language stats. +func New(cfg config.Cfg) *Instance { return &Instance{ cfg: cfg, - }, nil + } } // Stats returns the repository's language stats as reported by 'git-linguist'. diff --git a/internal/gitaly/service/commit/languages.go b/internal/gitaly/service/commit/languages.go index 8fef28db8..8eba5a3f8 100644 --- a/internal/gitaly/service/commit/languages.go +++ b/internal/gitaly/service/commit/languages.go @@ -39,7 +39,7 @@ func (s *server) CommitLanguages(ctx context.Context, req *gitalypb.CommitLangua return nil, helper.ErrInternalf("looking up revision: %w", err) } - stats, err := s.linguist.Stats(ctx, repo, commitID, s.catfileCache) + stats, err := linguist.New(s.cfg).Stats(ctx, repo, commitID, s.catfileCache) if err != nil { return nil, helper.ErrInternalf("language stats: %w", err) } diff --git a/internal/gitaly/service/commit/server.go b/internal/gitaly/service/commit/server.go index 3965b1dac..47ceee2c8 100644 --- a/internal/gitaly/service/commit/server.go +++ b/internal/gitaly/service/commit/server.go @@ -5,7 +5,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/v15/internal/git/repository" - "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/linguist" + "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" ) @@ -14,22 +14,22 @@ type server struct { gitalypb.UnimplementedCommitServiceServer locator storage.Locator gitCmdFactory git.CommandFactory - linguist *linguist.Instance catfileCache catfile.Cache + cfg config.Cfg } // NewServer creates a new instance of a grpc CommitServiceServer func NewServer( + cfg config.Cfg, locator storage.Locator, gitCmdFactory git.CommandFactory, - ling *linguist.Instance, catfileCache catfile.Cache, ) gitalypb.CommitServiceServer { return &server{ locator: locator, gitCmdFactory: gitCmdFactory, - linguist: ling, catfileCache: catfileCache, + cfg: cfg, } } diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go index e3bf2327c..d19934928 100644 --- a/internal/gitaly/service/commit/testhelper_test.go +++ b/internal/gitaly/service/commit/testhelper_test.go @@ -66,9 +66,9 @@ func startTestServices(tb testing.TB, cfg config.Cfg) string { tb.Helper() return testserver.RunGitalyServer(tb, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) { gitalypb.RegisterCommitServiceServer(srv, NewServer( + deps.GetCfg(), deps.GetLocator(), deps.GetGitCmdFactory(), - deps.GetLinguist(), deps.GetCatfileCache(), )) gitalypb.RegisterRepositoryServiceServer(srv, repository.NewServer( diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go index b399e2f69..d7add6e0b 100644 --- a/internal/gitaly/service/conflicts/testhelper_test.go +++ b/internal/gitaly/service/conflicts/testhelper_test.go @@ -73,9 +73,9 @@ func runConflictsServer(tb testing.TB, cfg config.Cfg, hookManager hook.Manager) )) gitalypb.RegisterHookServiceServer(srv, hookservice.NewServer(deps.GetHookManager(), deps.GetGitCmdFactory(), deps.GetPackObjectsCache(), deps.GetPackObjectsConcurrencyTracker())) gitalypb.RegisterCommitServiceServer(srv, commit.NewServer( + deps.GetCfg(), deps.GetLocator(), deps.GetGitCmdFactory(), - deps.GetLinguist(), deps.GetCatfileCache(), )) }, testserver.WithHookManager(hookManager)) diff --git a/internal/gitaly/service/dependencies.go b/internal/gitaly/service/dependencies.go index d6c89e6b8..15448ac2b 100644 --- a/internal/gitaly/service/dependencies.go +++ b/internal/gitaly/service/dependencies.go @@ -11,7 +11,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/internal/git2go" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config" gitalyhook "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/hook" - "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/linguist" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/rubyserver" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/transaction" @@ -29,7 +28,6 @@ type Dependencies struct { StorageLocator storage.Locator ClientPool *client.Pool GitCmdFactory git.CommandFactory - Linguist *linguist.Instance BackchannelRegistry *backchannel.Registry GitlabClient gitlab.Client CatfileCache catfile.Cache @@ -77,11 +75,6 @@ func (dc *Dependencies) GetGitCmdFactory() git.CommandFactory { return dc.GitCmdFactory } -// GetLinguist returns linguist. -func (dc *Dependencies) GetLinguist() *linguist.Instance { - return dc.Linguist -} - // GetBackchannelRegistry returns a registry of the backchannels. func (dc *Dependencies) GetBackchannelRegistry() *backchannel.Registry { return dc.BackchannelRegistry diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go index 09908e809..13639d586 100644 --- a/internal/gitaly/service/operations/testhelper_test.go +++ b/internal/gitaly/service/operations/testhelper_test.go @@ -123,9 +123,9 @@ func runOperationServiceServer(tb testing.TB, cfg config.Cfg, options ...testser deps.GetCatfileCache(), )) gitalypb.RegisterCommitServiceServer(srv, commit.NewServer( + deps.GetCfg(), deps.GetLocator(), deps.GetGitCmdFactory(), - nil, deps.GetCatfileCache(), )) gitalypb.RegisterSSHServiceServer(srv, ssh.NewServer( diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go index c7b1d4be7..566ee73a7 100644 --- a/internal/gitaly/service/repository/testhelper_test.go +++ b/internal/gitaly/service/repository/testhelper_test.go @@ -146,9 +146,9 @@ func runRepositoryService(tb testing.TB, cfg config.Cfg, rubySrv *rubyserver.Ser deps.GetCatfileCache(), )) gitalypb.RegisterCommitServiceServer(srv, commit.NewServer( + deps.GetCfg(), deps.GetLocator(), deps.GetGitCmdFactory(), - nil, deps.GetCatfileCache(), )) gitalypb.RegisterObjectPoolServiceServer(srv, objectpool.NewServer( diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go index a3ddffb02..69dc03c8c 100644 --- a/internal/gitaly/service/setup/register.go +++ b/internal/gitaly/service/setup/register.go @@ -64,9 +64,9 @@ func RegisterAll(srv *grpc.Server, deps *service.Dependencies) { deps.GetCatfileCache(), )) gitalypb.RegisterCommitServiceServer(srv, commit.NewServer( + deps.GetCfg(), deps.GetLocator(), deps.GetGitCmdFactory(), - deps.GetLinguist(), deps.GetCatfileCache(), )) gitalypb.RegisterDiffServiceServer(srv, diff.NewServer( diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go index e59080917..39fa17097 100644 --- a/internal/testhelper/testserver/gitaly.go +++ b/internal/testhelper/testserver/gitaly.go @@ -24,7 +24,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config/auth" gitalylog "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config/log" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/hook" - "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/linguist" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/rubyserver" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/server" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service" @@ -240,7 +239,6 @@ type gitalyServerDeps struct { hookMgr hook.Manager gitlabClient gitlab.Client gitCmdFactory git.CommandFactory - linguist *linguist.Instance backchannelReg *backchannel.Registry catfileCache catfile.Cache diskCache cache.Cache @@ -287,12 +285,6 @@ func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg, r gsd.hookMgr = hook.NewManager(cfg, gsd.locator, gsd.gitCmdFactory, gsd.txMgr, gsd.gitlabClient) } - if gsd.linguist == nil { - var err error - gsd.linguist, err = linguist.New(cfg) - require.NoError(tb, err) - } - if gsd.catfileCache == nil { cache := catfile.NewCache(cfg) gsd.catfileCache = cache @@ -336,7 +328,6 @@ func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg, r TransactionManager: gsd.txMgr, GitalyHookManager: gsd.hookMgr, GitCmdFactory: gsd.gitCmdFactory, - Linguist: gsd.linguist, BackchannelRegistry: gsd.backchannelReg, GitlabClient: gsd.gitlabClient, CatfileCache: gsd.catfileCache, |