Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-06-01 14:14:44 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-06-02 15:05:41 +0300
commit83be32a7dc83976e7638d7bd6f25e0364847a13e (patch)
treea49f53f018426a317b23ffd4c484d83687b37528
parentf60b4ce67aae4bedfbec3a53e0a0d4770ea74fa2 (diff)
repository: Move GitRepo interface into storage package
The `repository.GitRepo` interface provides a set of functions that allow us to locate a repository in our storage. It lives in a separate package outside of the `internal/git` module in order to avoid a set of cyclic dependencies. The current location is kind of weird though, as this interface is inherently tied to our storage details instead of being a generic Git thing. Move the definition of the interface into `internal/gitaly/storage` so that it is defined close to where it is used. This should also be a relatively safe location as any package that depends on the interface should implicitly already depend on the storage package given that it will typically be passed down into any kind of storage locator. While at it, rename it to `storage.Repository`.
-rw-r--r--internal/cli/gitaly/serve.go3
-rw-r--r--internal/git/catfile/cache.go6
-rw-r--r--internal/git/catfile/cache_test.go6
-rw-r--r--internal/git/catfile/commit.go6
-rw-r--r--internal/git/catfile/request_queue_test.go4
-rw-r--r--internal/git/catfile/testhelper_test.go10
-rw-r--r--internal/git/command_factory.go7
-rw-r--r--internal/git/gittest/counting_command_factory.go4
-rw-r--r--internal/git/gittest/intercepting_command_factory.go4
-rw-r--r--internal/git/gittest/repo.go6
-rw-r--r--internal/git/hooks_options.go6
-rw-r--r--internal/git/housekeeping/objects.go4
-rw-r--r--internal/git/housekeeping/optimize_repository_test.go8
-rw-r--r--internal/git/localrepo/factory_test.go12
-rw-r--r--internal/git/localrepo/repo.go13
-rw-r--r--internal/git/log/last_commit.go6
-rw-r--r--internal/git/object_id.go4
-rw-r--r--internal/git/repository.go4
-rw-r--r--internal/git/repository/repository.go9
-rw-r--r--internal/git/stats/object_pool.go6
-rw-r--r--internal/git/updateref/update_with_hooks.go3
-rw-r--r--internal/git2go/apply.go4
-rw-r--r--internal/git2go/cherry_pick.go4
-rw-r--r--internal/git2go/commit.go4
-rw-r--r--internal/git2go/conflicts.go4
-rw-r--r--internal/git2go/executor.go5
-rw-r--r--internal/git2go/featureflags_test.go4
-rw-r--r--internal/git2go/merge.go4
-rw-r--r--internal/git2go/rebase.go4
-rw-r--r--internal/git2go/resolve_conflicts.go4
-rw-r--r--internal/git2go/revert.go4
-rw-r--r--internal/git2go/submodule.go4
-rw-r--r--internal/gitaly/config/locator.go5
-rw-r--r--internal/gitaly/maintenance/optimize.go7
-rw-r--r--internal/gitaly/maintenance/optimize_test.go6
-rw-r--r--internal/gitaly/partition_manager.go3
-rw-r--r--internal/gitaly/partition_manager_test.go6
-rw-r--r--internal/gitaly/repoutil/create.go3
-rw-r--r--internal/gitaly/repoutil/custom_hooks.go5
-rw-r--r--internal/gitaly/repoutil/lock.go3
-rw-r--r--internal/gitaly/repoutil/remove.go5
-rw-r--r--internal/gitaly/service/blob/server.go3
-rw-r--r--internal/gitaly/service/cleanup/server.go3
-rw-r--r--internal/gitaly/service/commit/server.go3
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts.go4
-rw-r--r--internal/gitaly/service/conflicts/server.go3
-rw-r--r--internal/gitaly/service/diff/server.go3
-rw-r--r--internal/gitaly/service/objectpool/server.go3
-rw-r--r--internal/gitaly/service/operations/server.go3
-rw-r--r--internal/gitaly/service/ref/server.go3
-rw-r--r--internal/gitaly/service/remote/server.go3
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror_test.go10
-rw-r--r--internal/gitaly/service/repository/server.go3
-rw-r--r--internal/gitaly/storage/locator.go16
-rw-r--r--internal/helper/repo.go6
-rw-r--r--internal/praefect/praefectutil/replica_path.go4
56 files changed, 131 insertions, 158 deletions
diff --git a/internal/cli/gitaly/serve.go b/internal/cli/gitaly/serve.go
index aec987c81..78aa7d56c 100644
--- a/internal/cli/gitaly/serve.go
+++ b/internal/cli/gitaly/serve.go
@@ -22,7 +22,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
@@ -394,7 +393,7 @@ func run(cfg config.Cfg) error {
shutdownWorkers, err := maintenance.StartWorkers(
ctx,
glog.Default(),
- maintenance.DailyOptimizationWorker(cfg, maintenance.OptimizerFunc(func(ctx context.Context, repo repository.GitRepo) error {
+ maintenance.DailyOptimizationWorker(cfg, maintenance.OptimizerFunc(func(ctx context.Context, repo storage.Repository) error {
return housekeepingManager.OptimizeRepository(ctx, localrepo.New(locator, gitCmdFactory, catfileCache, repo))
})),
)
diff --git a/internal/git/catfile/cache.go b/internal/git/catfile/cache.go
index 69bebbec1..bf8d27d2f 100644
--- a/internal/git/catfile/cache.go
+++ b/internal/git/catfile/cache.go
@@ -9,8 +9,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/metadata"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
"gitlab.com/gitlab-org/gitaly/v16/internal/tracing"
@@ -205,7 +205,7 @@ func (c *ProcessCache) ObjectInfoReader(ctx context.Context, repo git.Repository
func (c *ProcessCache) getOrCreateProcess(
ctx context.Context,
- repo repository.GitRepo,
+ repo storage.Repository,
processes *processes,
create func(context.Context) (cacheable, error),
spanName string,
@@ -343,7 +343,7 @@ type key struct {
repoAltDir string
}
-func newCacheKey(sessionID string, repo repository.GitRepo) (key, bool) {
+func newCacheKey(sessionID string, repo storage.Repository) (key, bool) {
if sessionID == "" {
return key{}, false
}
diff --git a/internal/git/catfile/cache_test.go b/internal/git/catfile/cache_test.go
index 958a8ed9a..afe8df4a8 100644
--- a/internal/git/catfile/cache_test.go
+++ b/internal/git/catfile/cache_test.go
@@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
@@ -386,7 +386,7 @@ func requireProcessesValid(t *testing.T, p *processes) {
}
}
-func mustCreateCacheable(t *testing.T, cfg config.Cfg, repo repository.GitRepo) (cacheable, func()) {
+func mustCreateCacheable(t *testing.T, cfg config.Cfg, repo storage.Repository) (cacheable, func()) {
t.Helper()
ctx, cancel := context.WithCancel(testhelper.Context(t))
@@ -397,7 +397,7 @@ func mustCreateCacheable(t *testing.T, cfg config.Cfg, repo repository.GitRepo)
return batch, cancel
}
-func mustCreateKey(t *testing.T, sessionID string, repo repository.GitRepo) key {
+func mustCreateKey(t *testing.T, sessionID string, repo storage.Repository) key {
t.Helper()
key, cacheable := newCacheKey(sessionID, repo)
diff --git a/internal/git/catfile/commit.go b/internal/git/catfile/commit.go
index 963d20d2f..256aa8b69 100644
--- a/internal/git/catfile/commit.go
+++ b/internal/git/catfile/commit.go
@@ -8,8 +8,8 @@ import (
"io"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/trailerparser"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -28,7 +28,7 @@ func GetCommit(ctx context.Context, objectReader ObjectContentReader, revision g
func GetCommitWithTrailers(
ctx context.Context,
gitCmdFactory git.CommandFactory,
- repo repository.GitRepo,
+ repo storage.Repository,
objectReader ObjectContentReader,
revision git.Revision,
) (*gitalypb.GitCommit, error) {
@@ -67,7 +67,7 @@ func GetCommitWithTrailers(
}
// GetCommitMessage looks up a commit message and returns it in its entirety.
-func GetCommitMessage(ctx context.Context, objectReader ObjectContentReader, repo repository.GitRepo, revision git.Revision) ([]byte, error) {
+func GetCommitMessage(ctx context.Context, objectReader ObjectContentReader, repo storage.Repository, revision git.Revision) ([]byte, error) {
obj, err := objectReader.Object(ctx, revision+"^{commit}")
if err != nil {
return nil, err
diff --git a/internal/git/catfile/request_queue_test.go b/internal/git/catfile/request_queue_test.go
index 5dafbf509..0cd99adfe 100644
--- a/internal/git/catfile/request_queue_test.go
+++ b/internal/git/catfile/request_queue_test.go
@@ -454,7 +454,7 @@ func newInterceptedObjectQueue(t *testing.T, ctx context.Context, script string)
return script
})
repoExecutor := repoExecutor{
- GitRepo: repo,
+ Repository: repo,
gitCmdFactory: commandFactory,
}
@@ -479,7 +479,7 @@ func newInterceptedInfoQueue(t *testing.T, ctx context.Context, script string) (
return script
})
repoExecutor := repoExecutor{
- GitRepo: repo,
+ Repository: repo,
gitCmdFactory: commandFactory,
}
diff --git a/internal/git/catfile/testhelper_test.go b/internal/git/catfile/testhelper_test.go
index b893c82c9..f568501da 100644
--- a/internal/git/catfile/testhelper_test.go
+++ b/internal/git/catfile/testhelper_test.go
@@ -11,8 +11,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
@@ -24,19 +24,19 @@ func TestMain(m *testing.M) {
}
type repoExecutor struct {
- repository.GitRepo
+ storage.Repository
gitCmdFactory git.CommandFactory
}
-func newRepoExecutor(t *testing.T, cfg config.Cfg, repo repository.GitRepo) git.RepositoryExecutor {
+func newRepoExecutor(t *testing.T, cfg config.Cfg, repo storage.Repository) git.RepositoryExecutor {
return &repoExecutor{
- GitRepo: repo,
+ Repository: repo,
gitCmdFactory: gittest.NewCommandFactory(t, cfg),
}
}
func (e *repoExecutor) Exec(ctx context.Context, cmd git.Command, opts ...git.CmdOpt) (*command.Command, error) {
- return e.gitCmdFactory.New(ctx, e.GitRepo, cmd, opts...)
+ return e.gitCmdFactory.New(ctx, e.Repository, cmd, opts...)
}
func (e *repoExecutor) ExecAndWait(ctx context.Context, cmd git.Command, opts ...git.CmdOpt) error {
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index 11f7f4eba..729cea715 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -15,7 +15,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/cgroups"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/alternates"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/trace2"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/trace2hooks"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
@@ -28,7 +27,7 @@ import (
// CommandFactory is designed to create and run git commands in a protected and fully managed manner.
type CommandFactory interface {
// New creates a new command for the repo repository.
- New(ctx context.Context, repo repository.GitRepo, sc Command, opts ...CmdOpt) (*command.Command, error)
+ New(ctx context.Context, repo storage.Repository, sc Command, opts ...CmdOpt) (*command.Command, error)
// NewWithoutRepo creates a command without a target repository.
NewWithoutRepo(ctx context.Context, sc Command, opts ...CmdOpt) (*command.Command, error)
// GetExecutionEnvironment returns parameters required to execute Git commands.
@@ -270,7 +269,7 @@ func (cf *ExecCommandFactory) Collect(metrics chan<- prometheus.Metric) {
}
// New creates a new command for the repo repository.
-func (cf *ExecCommandFactory) New(ctx context.Context, repo repository.GitRepo, sc Command, opts ...CmdOpt) (*command.Command, error) {
+func (cf *ExecCommandFactory) New(ctx context.Context, repo storage.Repository, sc Command, opts ...CmdOpt) (*command.Command, error) {
return cf.newCommand(ctx, repo, sc, opts...)
}
@@ -411,7 +410,7 @@ func (cf *ExecCommandFactory) GitVersion(ctx context.Context) (Version, error) {
// command will be run in the context of that repository. Note that this sets up arguments and
// environment variables for git, but doesn't run in the directory itself. If a directory
// is given, then the command will be run in that directory.
-func (cf *ExecCommandFactory) newCommand(ctx context.Context, repo repository.GitRepo, sc Command, opts ...CmdOpt) (*command.Command, error) {
+func (cf *ExecCommandFactory) newCommand(ctx context.Context, repo storage.Repository, sc Command, opts ...CmdOpt) (*command.Command, error) {
config, err := cf.combineOpts(ctx, sc, opts)
if err != nil {
return nil, err
diff --git a/internal/git/gittest/counting_command_factory.go b/internal/git/gittest/counting_command_factory.go
index a5943079a..ca680f4fd 100644
--- a/internal/git/gittest/counting_command_factory.go
+++ b/internal/git/gittest/counting_command_factory.go
@@ -7,8 +7,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
var _ git.CommandFactory = &CountingCommandFactory{}
@@ -49,7 +49,7 @@ func (f *CountingCommandFactory) ResetCount() {
}
// New creates a new git command and increments the command counter
-func (f *CountingCommandFactory) New(ctx context.Context, repo repository.GitRepo, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
+func (f *CountingCommandFactory) New(ctx context.Context, repo storage.Repository, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
f.m.Lock()
defer f.m.Unlock()
f.counts[sc.Name]++
diff --git a/internal/git/gittest/intercepting_command_factory.go b/internal/git/gittest/intercepting_command_factory.go
index 9dcdb055e..7b8ab26b8 100644
--- a/internal/git/gittest/intercepting_command_factory.go
+++ b/internal/git/gittest/intercepting_command_factory.go
@@ -8,8 +8,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
)
@@ -106,7 +106,7 @@ func NewInterceptingCommandFactory(
}
// New creates a new Git command for the given repository using the intercepting script.
-func (f *InterceptingCommandFactory) New(ctx context.Context, repo repository.GitRepo, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
+func (f *InterceptingCommandFactory) New(ctx context.Context, repo storage.Repository, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
return f.interceptingCommandFactory.New(ctx, repo, sc, append(
opts, git.WithEnv(f.realCommandFactory.GetExecutionEnvironment(ctx).EnvironmentVariables...),
)...)
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go
index 457f26bea..7da034ff1 100644
--- a/internal/git/gittest/repo.go
+++ b/internal/git/gittest/repo.go
@@ -14,8 +14,8 @@ import (
gitalyauth "gitlab.com/gitlab-org/gitaly/v16/auth"
"gitlab.com/gitlab-org/gitaly/v16/client"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
internalclient "gitlab.com/gitlab-org/gitaly/v16/internal/grpc/client"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
@@ -238,7 +238,7 @@ type GetReplicaPathConfig struct {
// run with Praefect in front of it. This is necessary if the test creates a repository
// through Praefect and peeks into the filesystem afterwards. Conn should be pointing to
// Praefect.
-func GetReplicaPath(tb testing.TB, ctx context.Context, cfg config.Cfg, repo repository.GitRepo, opts ...GetReplicaPathConfig) string {
+func GetReplicaPath(tb testing.TB, ctx context.Context, cfg config.Cfg, repo storage.Repository, opts ...GetReplicaPathConfig) string {
require.Less(tb, len(opts), 2, "you must either pass no or exactly one option")
var opt GetReplicaPathConfig
@@ -255,7 +255,7 @@ func GetReplicaPath(tb testing.TB, ctx context.Context, cfg config.Cfg, repo rep
return getReplicaPath(tb, ctx, conn, repo)
}
-func getReplicaPath(tb testing.TB, ctx context.Context, conn *grpc.ClientConn, repo repository.GitRepo) string {
+func getReplicaPath(tb testing.TB, ctx context.Context, conn *grpc.ClientConn, repo storage.Repository) string {
metadata, err := gitalypb.NewPraefectInfoServiceClient(conn).GetRepositoryMetadata(
ctx, &gitalypb.GetRepositoryMetadataRequest{
Query: &gitalypb.GetRepositoryMetadataRequest_Path_{
diff --git a/internal/git/hooks_options.go b/internal/git/hooks_options.go
index 41002bede..43991e765 100644
--- a/internal/git/hooks_options.go
+++ b/internal/git/hooks_options.go
@@ -6,8 +6,8 @@ import (
"fmt"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/metadata"
"gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/txinfo"
@@ -31,7 +31,7 @@ func WithDisabledHooks() CmdOpt {
// WithRefTxHook returns an option that populates the safe command with the
// environment variables necessary to properly execute a reference hook for
// repository changes that may possibly update references
-func WithRefTxHook(repo repository.GitRepo) CmdOpt {
+func WithRefTxHook(repo storage.Repository) CmdOpt {
return func(ctx context.Context, cfg config.Cfg, gitCmdFactory CommandFactory, cc *cmdCfg) error {
if repo == nil {
return fmt.Errorf("missing repo: %w", ErrInvalidArg)
@@ -40,7 +40,7 @@ func WithRefTxHook(repo repository.GitRepo) CmdOpt {
// The reference-transaction hook does not need any project-specific information
// about the repository. So in order to make the hook usable by sites which do not
// have a project repository available (e.g. object pools), this function accepts a
- // `repository.GitRepo` and just creates an ad-hoc proto repo.
+ // `storage.Repository` and just creates an ad-hoc proto repo.
if err := cc.configureHooks(ctx, &gitalypb.Repository{
StorageName: repo.GetStorageName(),
GitAlternateObjectDirectories: repo.GetGitAlternateObjectDirectories(),
diff --git a/internal/git/housekeeping/objects.go b/internal/git/housekeeping/objects.go
index 36f29a5ea..f8a2334fc 100644
--- a/internal/git/housekeeping/objects.go
+++ b/internal/git/housekeeping/objects.go
@@ -12,8 +12,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/stats"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
)
@@ -304,7 +304,7 @@ func performRepack(ctx context.Context, repo *localrepo.Repo, cfg RepackObjectsC
}
// GetRepackGitConfig returns configuration suitable for Git commands which write new packfiles.
-func GetRepackGitConfig(ctx context.Context, repo repository.GitRepo, bitmap bool) []git.ConfigPair {
+func GetRepackGitConfig(ctx context.Context, repo storage.Repository, bitmap bool) []git.ConfigPair {
config := []git.ConfigPair{
{Key: "repack.useDeltaIslands", Value: "true"},
{Key: "repack.writeBitmaps", Value: strconv.FormatBool(bitmap)},
diff --git a/internal/git/housekeeping/optimize_repository_test.go b/internal/git/housekeeping/optimize_repository_test.go
index 419e039ba..a2d875aa3 100644
--- a/internal/git/housekeeping/optimize_repository_test.go
+++ b/internal/git/housekeeping/optimize_repository_test.go
@@ -19,10 +19,10 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
gitalycfgprom "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config/prometheus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/backchannel"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
@@ -37,7 +37,7 @@ type errorInjectingCommandFactory struct {
func (f errorInjectingCommandFactory) New(
ctx context.Context,
- repo repository.GitRepo,
+ repo storage.Repository,
cmd git.Command,
opts ...git.CmdOpt,
) (*command.Command, error) {
@@ -55,7 +55,7 @@ type blockingCommandFactory struct {
func (f *blockingCommandFactory) New(
ctx context.Context,
- repo repository.GitRepo,
+ repo storage.Repository,
cmd git.Command,
opts ...git.CmdOpt,
) (*command.Command, error) {
@@ -1211,7 +1211,7 @@ func TestOptimizeRepository_ConcurrencyLimit(t *testing.T) {
manager.optimizeFunc = func(_ context.Context, _ *RepositoryManager, repo *localrepo.Repo, _ OptimizationStrategy) error {
reposOptimized[repo.GetRelativePath()] = struct{}{}
- if repo.GitRepo.GetRelativePath() == repoFirst.GetRelativePath() {
+ if repo.GetRelativePath() == repoFirst.GetRelativePath() {
reqReceivedCh <- struct{}{}
ch <- struct{}{}
}
diff --git a/internal/git/localrepo/factory_test.go b/internal/git/localrepo/factory_test.go
index 056f3bef1..56826bd27 100644
--- a/internal/git/localrepo/factory_test.go
+++ b/internal/git/localrepo/factory_test.go
@@ -31,8 +31,8 @@ func TestFactory(t *testing.T) {
RelativePath: "relative-path-1",
})
- require.Equal(t, "non-existent", repo.GitRepo.GetStorageName())
- require.Equal(t, "relative-path-1", repo.GitRepo.GetRelativePath())
+ require.Equal(t, "non-existent", repo.GetStorageName())
+ require.Equal(t, "relative-path-1", repo.GetRelativePath())
})
})
@@ -48,15 +48,15 @@ func TestFactory(t *testing.T) {
require.NoError(t, err)
repo1 := scopedFactory1.Build("relative-path-1")
- require.Equal(t, "storage-1", repo1.GitRepo.GetStorageName())
- require.Equal(t, "relative-path-1", repo1.GitRepo.GetRelativePath())
+ require.Equal(t, "storage-1", repo1.GetStorageName())
+ require.Equal(t, "relative-path-1", repo1.GetRelativePath())
scopedFactory2, err := factory.ScopeByStorage("storage-2")
require.NoError(t, err)
repo2 := scopedFactory2.Build("relative-path-2")
- require.Equal(t, "storage-2", repo2.GitRepo.GetStorageName())
- require.Equal(t, "relative-path-2", repo2.GitRepo.GetRelativePath())
+ require.Equal(t, "storage-2", repo2.GetStorageName())
+ require.Equal(t, "relative-path-2", repo2.GetRelativePath())
})
})
}
diff --git a/internal/git/localrepo/repo.go b/internal/git/localrepo/repo.go
index 121bb2bbb..588af6cf5 100644
--- a/internal/git/localrepo/repo.go
+++ b/internal/git/localrepo/repo.go
@@ -13,7 +13,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
@@ -24,7 +23,7 @@ import (
// Repo represents a local Git repository.
type Repo struct {
- repository.GitRepo
+ storage.Repository
locator storage.Locator
gitCmdFactory git.CommandFactory
catfileCache catfile.Cache
@@ -35,9 +34,9 @@ type Repo struct {
}
// New creates a new Repo from its protobuf representation.
-func New(locator storage.Locator, gitCmdFactory git.CommandFactory, catfileCache catfile.Cache, repo repository.GitRepo) *Repo {
+func New(locator storage.Locator, gitCmdFactory git.CommandFactory, catfileCache catfile.Cache, repo storage.Repository) *Repo {
return &Repo{
- GitRepo: repo,
+ Repository: repo,
locator: locator,
gitCmdFactory: gitCmdFactory,
catfileCache: catfileCache,
@@ -47,9 +46,9 @@ func New(locator storage.Locator, gitCmdFactory git.CommandFactory, catfileCache
// Quarantine return the repository quarantined. The quarantine directory becomes the repository's
// main object directory and the original object directory is configured as an alternate.
func (repo *Repo) Quarantine(quarantineDirectory string) (*Repo, error) {
- pbRepo, ok := repo.GitRepo.(*gitalypb.Repository)
+ pbRepo, ok := repo.Repository.(*gitalypb.Repository)
if !ok {
- return nil, fmt.Errorf("unexpected repository type %t", repo.GitRepo)
+ return nil, fmt.Errorf("unexpected repository type %t", repo.Repository)
}
repoPath, err := repo.Path()
@@ -72,7 +71,7 @@ func (repo *Repo) Quarantine(quarantineDirectory string) (*Repo, error) {
// NewTestRepo constructs a Repo. It is intended as a helper function for tests which assembles
// dependencies ad-hoc from the given config.
-func NewTestRepo(tb testing.TB, cfg config.Cfg, repo repository.GitRepo, factoryOpts ...git.ExecCommandFactoryOption) *Repo {
+func NewTestRepo(tb testing.TB, cfg config.Cfg, repo storage.Repository, factoryOpts ...git.ExecCommandFactoryOption) *Repo {
tb.Helper()
if cfg.SocketPath != testcfg.UnconfiguredSocketPath {
diff --git a/internal/git/log/last_commit.go b/internal/git/log/last_commit.go
index 251e050e4..888172941 100644
--- a/internal/git/log/last_commit.go
+++ b/internal/git/log/last_commit.go
@@ -7,7 +7,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -17,7 +17,7 @@ func LastCommitForPath(
ctx context.Context,
gitCmdFactory git.CommandFactory,
objectReader catfile.ObjectContentReader,
- repo repository.GitRepo,
+ repo storage.Repository,
revision git.Revision,
path string,
options *gitalypb.GlobalOptions,
@@ -41,7 +41,7 @@ func LastCommitForPath(
}
// GitLogCommand returns a Command that executes git log with the given the arguments
-func GitLogCommand(ctx context.Context, gitCmdFactory git.CommandFactory, repo repository.GitRepo, revisions []git.Revision, paths []string, options *gitalypb.GlobalOptions, extraArgs ...git.Option) (*command.Command, error) {
+func GitLogCommand(ctx context.Context, gitCmdFactory git.CommandFactory, repo storage.Repository, revisions []git.Revision, paths []string, options *gitalypb.GlobalOptions, extraArgs ...git.Option) (*command.Command, error) {
args := make([]string, len(revisions))
for i, revision := range revisions {
args[i] = revision.String()
diff --git a/internal/git/object_id.go b/internal/git/object_id.go
index 09d9c57a3..dd4b367be 100644
--- a/internal/git/object_id.go
+++ b/internal/git/object_id.go
@@ -9,7 +9,7 @@ import (
"fmt"
"hash"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -98,7 +98,7 @@ func ObjectHashByProto(format gitalypb.ObjectFormat) (ObjectHash, error) {
}
// DetectObjectHash detects the object-hash used by the given repository.
-func DetectObjectHash(ctx context.Context, gitCmdFactory CommandFactory, repository repository.GitRepo) (ObjectHash, error) {
+func DetectObjectHash(ctx context.Context, gitCmdFactory CommandFactory, repository storage.Repository) (ObjectHash, error) {
var stdout, stderr bytes.Buffer
revParseCmd, err := gitCmdFactory.New(ctx, repository, Command{
diff --git a/internal/git/repository.go b/internal/git/repository.go
index a26bb8221..b3cf9725f 100644
--- a/internal/git/repository.go
+++ b/internal/git/repository.go
@@ -5,7 +5,7 @@ import (
"errors"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// DefaultBranch is the default reference written to HEAD when a repository is created
@@ -54,7 +54,7 @@ type Repository interface {
// RepositoryExecutor is an interface which allows execution of Git commands in a specific
// repository.
type RepositoryExecutor interface {
- repository.GitRepo
+ storage.Repository
Exec(ctx context.Context, cmd Command, opts ...CmdOpt) (*command.Command, error)
ExecAndWait(ctx context.Context, cmd Command, opts ...CmdOpt) error
GitVersion(ctx context.Context) (Version, error)
diff --git a/internal/git/repository/repository.go b/internal/git/repository/repository.go
deleted file mode 100644
index 3a200d7a8..000000000
--- a/internal/git/repository/repository.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package repository
-
-// GitRepo supplies an interface for executing `git.Command`s
-type GitRepo interface {
- GetStorageName() string
- GetRelativePath() string
- GetGitObjectDirectory() string
- GetGitAlternateObjectDirectories() []string
-}
diff --git a/internal/git/stats/object_pool.go b/internal/git/stats/object_pool.go
index 95b9b8a22..54d6b4c9c 100644
--- a/internal/git/stats/object_pool.go
+++ b/internal/git/stats/object_pool.go
@@ -4,7 +4,7 @@ import (
"regexp"
"strings"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/praefectutil"
)
@@ -12,7 +12,7 @@ import (
var railsPoolDirRegexp = regexp.MustCompile(`^@pools/([0-9a-f]{2})/([0-9a-f]{2})/([0-9a-f]{64})\.git$`)
// IsRailsPoolRepository returns whether the repository is a pool repository generated by Rails.
-func IsRailsPoolRepository(repo repository.GitRepo) bool {
+func IsRailsPoolRepository(repo storage.Repository) bool {
matches := railsPoolDirRegexp.FindStringSubmatch(repo.GetRelativePath())
if matches == nil || !strings.HasPrefix(matches[3], matches[1]+matches[2]) {
return false
@@ -22,6 +22,6 @@ func IsRailsPoolRepository(repo repository.GitRepo) bool {
}
// IsPoolRepository returns whether the repository is an object pool.
-func IsPoolRepository(repo repository.GitRepo) bool {
+func IsPoolRepository(repo storage.Repository) bool {
return IsRailsPoolRepository(repo) || praefectutil.IsPoolRepository(repo)
}
diff --git a/internal/git/updateref/update_with_hooks.go b/internal/git/updateref/update_with_hooks.go
index 8acbb9065..bb8599ff8 100644
--- a/internal/git/updateref/update_with_hooks.go
+++ b/internal/git/updateref/update_with_hooks.go
@@ -13,7 +13,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
@@ -303,6 +302,6 @@ func (u *UpdaterWithHooks) UpdateReference(
return nil
}
-func (u *UpdaterWithHooks) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (u *UpdaterWithHooks) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(u.locator, u.gitCmdFactory, u.catfileCache, repo)
}
diff --git a/internal/git2go/apply.go b/internal/git2go/apply.go
index b1689a95d..b61351eba 100644
--- a/internal/git2go/apply.go
+++ b/internal/git2go/apply.go
@@ -7,7 +7,7 @@ import (
"io"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// ErrMergeConflict is returned when there is a merge conflict.
@@ -73,7 +73,7 @@ func (iter *slicePatchIterator) Err() error { return nil }
// Apply applies the provided patches and returns the OID of the commit with the patches
// applied.
-func (b *Executor) Apply(ctx context.Context, repo repository.GitRepo, params ApplyParams) (git.ObjectID, error) {
+func (b *Executor) Apply(ctx context.Context, repo storage.Repository, params ApplyParams) (git.ObjectID, error) {
reader, writer := io.Pipe()
defer writer.Close()
diff --git a/internal/git2go/cherry_pick.go b/internal/git2go/cherry_pick.go
index dabcd48a1..435d85cbf 100644
--- a/internal/git2go/cherry_pick.go
+++ b/internal/git2go/cherry_pick.go
@@ -5,7 +5,7 @@ import (
"time"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// CherryPickCommand contains parameters to perform a cherry-pick.
@@ -31,7 +31,7 @@ type CherryPickCommand struct {
}
// CherryPick performs a cherry-pick via gitaly-git2go.
-func (b *Executor) CherryPick(ctx context.Context, repo repository.GitRepo, m CherryPickCommand) (git.ObjectID, error) {
+func (b *Executor) CherryPick(ctx context.Context, repo storage.Repository, m CherryPickCommand) (git.ObjectID, error) {
m.SigningKey = b.signingKey
return b.runWithGob(ctx, repo, "cherry-pick", m)
diff --git a/internal/git2go/commit.go b/internal/git2go/commit.go
index 8dda50164..2fb7232ea 100644
--- a/internal/git2go/commit.go
+++ b/internal/git2go/commit.go
@@ -6,7 +6,7 @@ import (
"fmt"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -125,7 +125,7 @@ type CommitCommand struct {
// Commit builds a commit from the actions, writes it to the object database and
// returns its object id.
-func (b *Executor) Commit(ctx context.Context, repo repository.GitRepo, c CommitCommand) (git.ObjectID, error) {
+func (b *Executor) Commit(ctx context.Context, repo storage.Repository, c CommitCommand) (git.ObjectID, error) {
c.SigningKey = b.signingKey
return b.runWithGob(ctx, repo, "commit", c)
diff --git a/internal/git2go/conflicts.go b/internal/git2go/conflicts.go
index b7018f0ee..7aa16e905 100644
--- a/internal/git2go/conflicts.go
+++ b/internal/git2go/conflicts.go
@@ -7,7 +7,7 @@ import (
"errors"
"fmt"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -67,7 +67,7 @@ type ConflictsResult struct {
}
// Conflicts performs a merge via gitaly-git2go and returns all resulting conflicts.
-func (b *Executor) Conflicts(ctx context.Context, repo repository.GitRepo, c ConflictsCommand) (ConflictsResult, error) {
+func (b *Executor) Conflicts(ctx context.Context, repo storage.Repository, c ConflictsCommand) (ConflictsResult, error) {
if err := c.verify(); err != nil {
return ConflictsResult{}, fmt.Errorf("conflicts: %w: %s", ErrInvalidArgument, err.Error())
}
diff --git a/internal/git2go/executor.go b/internal/git2go/executor.go
index 5ea382faf..c59000020 100644
--- a/internal/git2go/executor.go
+++ b/internal/git2go/executor.go
@@ -13,7 +13,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/alternates"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
glog "gitlab.com/gitlab-org/gitaly/v16/internal/log"
@@ -50,7 +49,7 @@ func NewExecutor(cfg config.Cfg, gitCmdFactory git.CommandFactory, locator stora
}
}
-func (b *Executor) run(ctx context.Context, repo repository.GitRepo, stdin io.Reader, subcmd string, args ...string) (*bytes.Buffer, error) {
+func (b *Executor) run(ctx context.Context, repo storage.Repository, stdin io.Reader, subcmd string, args ...string) (*bytes.Buffer, error) {
repoPath, err := b.locator.GetRepoPath(repo)
if err != nil {
return nil, fmt.Errorf("gitaly-git2go: %w", err)
@@ -105,7 +104,7 @@ func (b *Executor) run(ctx context.Context, repo repository.GitRepo, stdin io.Re
// runWithGob runs the specified gitaly-git2go cmd with the request gob-encoded
// as input and returns the commit ID as string or an error.
-func (b *Executor) runWithGob(ctx context.Context, repo repository.GitRepo, cmd string, request interface{}) (git.ObjectID, error) {
+func (b *Executor) runWithGob(ctx context.Context, repo storage.Repository, cmd string, request interface{}) (git.ObjectID, error) {
input := &bytes.Buffer{}
if err := gob.NewEncoder(input).Encode(request); err != nil {
return "", fmt.Errorf("%s: %w", cmd, err)
diff --git a/internal/git2go/featureflags_test.go b/internal/git2go/featureflags_test.go
index f5c2b7b8f..86d021f12 100644
--- a/internal/git2go/featureflags_test.go
+++ b/internal/git2go/featureflags_test.go
@@ -11,13 +11,13 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
)
-func (b *Executor) FeatureFlags(ctx context.Context, repo repository.GitRepo) ([]FeatureFlag, error) {
+func (b *Executor) FeatureFlags(ctx context.Context, repo storage.Repository) ([]FeatureFlag, error) {
output, err := b.run(ctx, repo, nil, "feature-flags")
if err != nil {
return nil, err
diff --git a/internal/git2go/merge.go b/internal/git2go/merge.go
index 01061eeec..d205edc1a 100644
--- a/internal/git2go/merge.go
+++ b/internal/git2go/merge.go
@@ -6,7 +6,7 @@ import (
"fmt"
"time"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
const (
@@ -58,7 +58,7 @@ type MergeResult struct {
}
// Merge performs a merge via gitaly-git2go.
-func (b *Executor) Merge(ctx context.Context, repo repository.GitRepo, m MergeCommand) (MergeResult, error) {
+func (b *Executor) Merge(ctx context.Context, repo storage.Repository, m MergeCommand) (MergeResult, error) {
if err := m.verify(); err != nil {
return MergeResult{}, fmt.Errorf("merge: %w: %s", ErrInvalidArgument, err.Error())
}
diff --git a/internal/git2go/rebase.go b/internal/git2go/rebase.go
index a07657473..3bdc0e9e6 100644
--- a/internal/git2go/rebase.go
+++ b/internal/git2go/rebase.go
@@ -4,7 +4,7 @@ import (
"context"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// RebaseCommand contains parameters to rebase a branch.
@@ -35,7 +35,7 @@ type RebaseCommand struct {
}
// Rebase performs the rebase via gitaly-git2go
-func (b *Executor) Rebase(ctx context.Context, repo repository.GitRepo, r RebaseCommand) (git.ObjectID, error) {
+func (b *Executor) Rebase(ctx context.Context, repo storage.Repository, r RebaseCommand) (git.ObjectID, error) {
r.SigningKey = b.signingKey
return b.runWithGob(ctx, repo, "rebase", r)
diff --git a/internal/git2go/resolve_conflicts.go b/internal/git2go/resolve_conflicts.go
index 1ba19fc81..57089ed79 100644
--- a/internal/git2go/resolve_conflicts.go
+++ b/internal/git2go/resolve_conflicts.go
@@ -7,7 +7,7 @@ import (
"fmt"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/conflict"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// ResolveCommand contains arguments to perform a merge commit and resolve any
@@ -27,7 +27,7 @@ type ResolveResult struct {
}
// Resolve will attempt merging and resolving conflicts for the provided request
-func (b *Executor) Resolve(ctx context.Context, repo repository.GitRepo, r ResolveCommand) (ResolveResult, error) {
+func (b *Executor) Resolve(ctx context.Context, repo storage.Repository, r ResolveCommand) (ResolveResult, error) {
r.SigningKey = b.signingKey
if err := r.verify(); err != nil {
diff --git a/internal/git2go/revert.go b/internal/git2go/revert.go
index d3a545729..b3210f730 100644
--- a/internal/git2go/revert.go
+++ b/internal/git2go/revert.go
@@ -5,7 +5,7 @@ import (
"time"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// RevertCommand contains parameters required to execute a revert via gitaly-git2go.
@@ -31,7 +31,7 @@ type RevertCommand struct {
}
// Revert reverts a commit via gitaly-git2go.
-func (b *Executor) Revert(ctx context.Context, repo repository.GitRepo, r RevertCommand) (git.ObjectID, error) {
+func (b *Executor) Revert(ctx context.Context, repo storage.Repository, r RevertCommand) (git.ObjectID, error) {
r.SigningKey = b.signingKey
return b.runWithGob(ctx, repo, "revert", r)
diff --git a/internal/git2go/submodule.go b/internal/git2go/submodule.go
index f0fb54e90..a25335d99 100644
--- a/internal/git2go/submodule.go
+++ b/internal/git2go/submodule.go
@@ -7,7 +7,7 @@ import (
"fmt"
"time"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// Error strings present in the legacy Ruby implementation
@@ -49,7 +49,7 @@ type SubmoduleResult struct {
}
// Submodule attempts to commit the request submodule change
-func (b *Executor) Submodule(ctx context.Context, repo repository.GitRepo, s SubmoduleCommand) (SubmoduleResult, error) {
+func (b *Executor) Submodule(ctx context.Context, repo storage.Repository, s SubmoduleCommand) (SubmoduleResult, error) {
s.SigningKey = b.signingKey
if err := s.verify(); err != nil {
diff --git a/internal/gitaly/config/locator.go b/internal/gitaly/config/locator.go
index 0fc0c6dd3..a69d947c8 100644
--- a/internal/gitaly/config/locator.go
+++ b/internal/gitaly/config/locator.go
@@ -4,7 +4,6 @@ import (
"os"
"path/filepath"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
)
@@ -39,7 +38,7 @@ type configLocator struct {
// the `GetRepoPathOption` produced by `WithRepositoryVerificationSkipped()`, this validation
// will be skipped. The errors returned are gRPC errors with relevant error codes and should be
// passed back to gRPC without further decoration.
-func (l *configLocator) GetRepoPath(repo repository.GitRepo, opts ...storage.GetRepoPathOption) (string, error) {
+func (l *configLocator) GetRepoPath(repo storage.Repository, opts ...storage.GetRepoPathOption) (string, error) {
var cfg storage.GetRepoPathConfig
for _, opt := range opts {
opt(&cfg)
@@ -60,7 +59,7 @@ func (l *configLocator) GetRepoPath(repo repository.GitRepo, opts ...storage.Get
// GetPath returns the path of the repo passed as first argument. An error is
// returned when either the storage can't be found or the path includes
// constructs trying to perform directory traversal.
-func (l *configLocator) GetPath(repo repository.GitRepo) (string, error) {
+func (l *configLocator) GetPath(repo storage.Repository) (string, error) {
storagePath, err := l.GetStorageByName(repo.GetStorageName())
if err != nil {
return "", err
diff --git a/internal/gitaly/maintenance/optimize.go b/internal/gitaly/maintenance/optimize.go
index 181e0ab21..fdd9bd1e8 100644
--- a/internal/gitaly/maintenance/optimize.go
+++ b/internal/gitaly/maintenance/optimize.go
@@ -11,7 +11,6 @@ import (
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
@@ -69,14 +68,14 @@ func shuffledStoragesCopy(randSrc *rand.Rand, storages []config.Storage) []confi
// Optimizer knows how to optimize a repository
type Optimizer interface {
- OptimizeRepository(context.Context, repository.GitRepo) error
+ OptimizeRepository(context.Context, storage.Repository) error
}
// OptimizerFunc is an adapter to allow the use of an ordinary function as an Optimizer
-type OptimizerFunc func(context.Context, repository.GitRepo) error
+type OptimizerFunc func(context.Context, storage.Repository) error
// OptimizeRepository calls o(ctx, repo)
-func (o OptimizerFunc) OptimizeRepository(ctx context.Context, repo repository.GitRepo) error {
+func (o OptimizerFunc) OptimizeRepository(ctx context.Context, repo storage.Repository) error {
return o(ctx, repo)
}
diff --git a/internal/gitaly/maintenance/optimize_test.go b/internal/gitaly/maintenance/optimize_test.go
index cdb48f727..9a469f71a 100644
--- a/internal/gitaly/maintenance/optimize_test.go
+++ b/internal/gitaly/maintenance/optimize_test.go
@@ -10,8 +10,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- repo "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/backchannel"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
@@ -22,11 +22,11 @@ import (
type mockOptimizer struct {
t testing.TB
- actual []repo.GitRepo
+ actual []storage.Repository
cfg config.Cfg
}
-func (mo *mockOptimizer) OptimizeRepository(ctx context.Context, repository repo.GitRepo) error {
+func (mo *mockOptimizer) OptimizeRepository(ctx context.Context, repository storage.Repository) error {
mo.actual = append(mo.actual, repository)
l := config.NewLocator(mo.cfg)
gitCmdFactory := gittest.NewCommandFactory(mo.t, mo.cfg)
diff --git a/internal/gitaly/partition_manager.go b/internal/gitaly/partition_manager.go
index f258fc0fd..abef2ad53 100644
--- a/internal/gitaly/partition_manager.go
+++ b/internal/gitaly/partition_manager.go
@@ -14,7 +14,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- repo "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
@@ -173,7 +172,7 @@ func stagingDirectoryPath(storagePath string) string {
// Begin gets the TransactionManager for the specified repository and starts a Transaction. If a
// TransactionManager is not already running, a new one is created and used. The partition tracks
// the number of pending transactions and this counter gets incremented when Begin is invoked.
-func (pm *PartitionManager) Begin(ctx context.Context, repo repo.GitRepo) (*Transaction, error) {
+func (pm *PartitionManager) Begin(ctx context.Context, repo storage.Repository) (*Transaction, error) {
storageMgr, ok := pm.storages[repo.GetStorageName()]
if !ok {
return nil, structerr.NewNotFound("unknown storage: %q", repo.GetStorageName())
diff --git a/internal/gitaly/partition_manager_test.go b/internal/gitaly/partition_manager_test.go
index 623a34b14..6ca9ecec6 100644
--- a/internal/gitaly/partition_manager_test.go
+++ b/internal/gitaly/partition_manager_test.go
@@ -14,8 +14,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- repo "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/backchannel"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
@@ -44,7 +44,7 @@ func TestPartitionManager(t *testing.T) {
// ctx is the context used when `Begin()` gets invoked.
ctx context.Context
// repo is the repository that the transaction belongs to.
- repo repo.GitRepo
+ repo storage.Repository
// expectedState contains the partitions by their storages and their pending transaction count at
// the end of the step.
expectedState map[string]map[string]uint
@@ -137,7 +137,7 @@ func TestPartitionManager(t *testing.T) {
require.Equal(t, expectedState, actualState)
}
- setupRepository := func(t *testing.T, cfg config.Cfg, storage config.Storage) repo.GitRepo {
+ setupRepository := func(t *testing.T, cfg config.Cfg, storage config.Storage) storage.Repository {
t.Helper()
repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
diff --git a/internal/gitaly/repoutil/create.go b/internal/gitaly/repoutil/create.go
index 07dedc61a..d070dc855 100644
--- a/internal/gitaly/repoutil/create.go
+++ b/internal/gitaly/repoutil/create.go
@@ -11,7 +11,6 @@ import (
"time"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
@@ -66,7 +65,7 @@ func Create(
locator storage.Locator,
gitCmdFactory git.CommandFactory,
txManager transaction.Manager,
- repository repository.GitRepo,
+ repository storage.Repository,
seedRepository func(repository *gitalypb.Repository) error,
options ...CreateOption,
) error {
diff --git a/internal/gitaly/repoutil/custom_hooks.go b/internal/gitaly/repoutil/custom_hooks.go
index 4a60fc79b..ebf60d585 100644
--- a/internal/gitaly/repoutil/custom_hooks.go
+++ b/internal/gitaly/repoutil/custom_hooks.go
@@ -15,7 +15,6 @@ import (
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/archive"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
@@ -37,7 +36,7 @@ func GetCustomHooks(
ctx context.Context,
locator storage.Locator,
writer io.Writer,
- repo repository.GitRepo,
+ repo storage.Repository,
) error {
repoPath, err := locator.GetRepoPath(repo)
if err != nil {
@@ -108,7 +107,7 @@ func SetCustomHooks(
locator storage.Locator,
txManager transaction.Manager,
reader io.Reader,
- repo repository.GitRepo,
+ repo storage.Repository,
) error {
repoPath, err := locator.GetRepoPath(repo)
if err != nil {
diff --git a/internal/gitaly/repoutil/lock.go b/internal/gitaly/repoutil/lock.go
index a3235ce18..6d902b830 100644
--- a/internal/gitaly/repoutil/lock.go
+++ b/internal/gitaly/repoutil/lock.go
@@ -6,7 +6,6 @@ import (
"path/filepath"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
@@ -20,7 +19,7 @@ import (
//
// Returns the error safe.ErrFileAlreadyLocked if the repository is already
// locked.
-func Lock(ctx context.Context, locator storage.Locator, repository repository.GitRepo) (func(), error) {
+func Lock(ctx context.Context, locator storage.Locator, repository storage.Repository) (func(), error) {
path, err := locator.GetPath(repository)
if err != nil {
return nil, err
diff --git a/internal/gitaly/repoutil/remove.go b/internal/gitaly/repoutil/remove.go
index 817876504..924135946 100644
--- a/internal/gitaly/repoutil/remove.go
+++ b/internal/gitaly/repoutil/remove.go
@@ -7,7 +7,6 @@ import (
"os"
"path/filepath"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
@@ -22,7 +21,7 @@ func Remove(
ctx context.Context,
locator storage.Locator,
txManager transaction.Manager,
- repository repository.GitRepo,
+ repository storage.Repository,
) error {
path, err := locator.GetPath(repository)
if err != nil {
@@ -99,7 +98,7 @@ func Remove(
func voteOnAction(
ctx context.Context,
txManager transaction.Manager,
- repo repository.GitRepo,
+ repo storage.Repository,
phase voting.Phase,
) error {
return transaction.RunOnContext(ctx, func(tx txinfo.Transaction) error {
diff --git a/internal/gitaly/service/blob/server.go b/internal/gitaly/service/blob/server.go
index 7b9447d37..8e31fdbb6 100644
--- a/internal/gitaly/service/blob/server.go
+++ b/internal/gitaly/service/blob/server.go
@@ -4,7 +4,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -25,6 +24,6 @@ func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory, catfil
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/cleanup/server.go b/internal/gitaly/service/cleanup/server.go
index f3f2c09c4..0d4758cef 100644
--- a/internal/gitaly/service/cleanup/server.go
+++ b/internal/gitaly/service/cleanup/server.go
@@ -4,7 +4,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -25,6 +24,6 @@ func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory, catfil
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/commit/server.go b/internal/gitaly/service/commit/server.go
index fe7b8a66f..4d1a70268 100644
--- a/internal/gitaly/service/commit/server.go
+++ b/internal/gitaly/service/commit/server.go
@@ -4,7 +4,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -33,6 +32,6 @@ func NewServer(
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts.go b/internal/gitaly/service/conflicts/resolve_conflicts.go
index 3ff55ecbc..72d8cb01f 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts.go
@@ -17,9 +17,9 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/remoterepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -211,7 +211,7 @@ func (s *server) resolveConflicts(header *gitalypb.ResolveConflictsRequestHeader
return nil
}
-func sameRepo(left, right repository.GitRepo) bool {
+func sameRepo(left, right storage.Repository) bool {
lgaod := left.GetGitAlternateObjectDirectories()
rgaod := right.GetGitAlternateObjectDirectories()
if len(lgaod) != len(rgaod) {
diff --git a/internal/gitaly/service/conflicts/server.go b/internal/gitaly/service/conflicts/server.go
index 6e540a216..403795bad 100644
--- a/internal/gitaly/service/conflicts/server.go
+++ b/internal/gitaly/service/conflicts/server.go
@@ -5,7 +5,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook"
@@ -45,6 +44,6 @@ func NewServer(
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/diff/server.go b/internal/gitaly/service/diff/server.go
index 862b7ab57..c54640cf2 100644
--- a/internal/gitaly/service/diff/server.go
+++ b/internal/gitaly/service/diff/server.go
@@ -4,7 +4,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -29,6 +28,6 @@ func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory, catfil
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/objectpool/server.go b/internal/gitaly/service/objectpool/server.go
index 8f7ff0e16..fa8c0e1a9 100644
--- a/internal/gitaly/service/objectpool/server.go
+++ b/internal/gitaly/service/objectpool/server.go
@@ -5,7 +5,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -37,6 +36,6 @@ func NewServer(
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/operations/server.go b/internal/gitaly/service/operations/server.go
index 865975f7d..08c6c8e41 100644
--- a/internal/gitaly/service/operations/server.go
+++ b/internal/gitaly/service/operations/server.go
@@ -8,7 +8,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook"
@@ -54,7 +53,7 @@ func NewServer(
}
}
-func (s *Server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *Server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/ref/server.go b/internal/gitaly/service/ref/server.go
index 58a223a04..552ddfefb 100644
--- a/internal/gitaly/service/ref/server.go
+++ b/internal/gitaly/service/ref/server.go
@@ -4,7 +4,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -33,6 +32,6 @@ func NewServer(
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/remote/server.go b/internal/gitaly/service/remote/server.go
index 1b649be16..1448cc106 100644
--- a/internal/gitaly/service/remote/server.go
+++ b/internal/gitaly/service/remote/server.go
@@ -5,7 +5,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -38,6 +37,6 @@ func NewServer(
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go
index 897f53985..857391c28 100644
--- a/internal/gitaly/service/remote/update_remote_mirror_test.go
+++ b/internal/gitaly/service/remote/update_remote_mirror_test.go
@@ -12,10 +12,10 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service"
repositorysvc "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
@@ -28,10 +28,10 @@ import (
type commandFactoryWrapper struct {
git.CommandFactory
- newFunc func(context.Context, repository.GitRepo, git.Command, ...git.CmdOpt) (*command.Command, error)
+ newFunc func(context.Context, storage.Repository, git.Command, ...git.CmdOpt) (*command.Command, error)
}
-func (w commandFactoryWrapper) New(ctx context.Context, repo repository.GitRepo, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
+func (w commandFactoryWrapper) New(ctx context.Context, repo storage.Repository, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
return w.newFunc(ctx, repo, sc, opts...)
}
@@ -365,7 +365,7 @@ func TestUpdateRemoteMirror(t *testing.T) {
wrapCommandFactory: func(tb testing.TB, original git.CommandFactory) git.CommandFactory {
return commandFactoryWrapper{
CommandFactory: original,
- newFunc: func(ctx context.Context, repo repository.GitRepo, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
+ newFunc: func(ctx context.Context, repo storage.Repository, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
if sc.Name == "push" {
// This is really hacky: we extract the
// remote name from the subcommands
@@ -467,7 +467,7 @@ func TestUpdateRemoteMirror(t *testing.T) {
firstPush := true
return commandFactoryWrapper{
CommandFactory: original,
- newFunc: func(ctx context.Context, repo repository.GitRepo, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
+ newFunc: func(ctx context.Context, repo storage.Repository, sc git.Command, opts ...git.CmdOpt) (*command.Command, error) {
if sc.Name == "push" && firstPush {
firstPush = false
args, err := sc.CommandArgs()
diff --git a/internal/gitaly/service/repository/server.go b/internal/gitaly/service/repository/server.go
index 6b3f8821d..efaa0e929 100644
--- a/internal/gitaly/service/repository/server.go
+++ b/internal/gitaly/service/repository/server.go
@@ -9,7 +9,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
@@ -60,7 +59,7 @@ func NewServer(
}
}
-func (s *server) localrepo(repo repository.GitRepo) *localrepo.Repo {
+func (s *server) localrepo(repo storage.Repository) *localrepo.Repo {
return localrepo.New(s.locator, s.gitCmdFactory, s.catfileCache, repo)
}
diff --git a/internal/gitaly/storage/locator.go b/internal/gitaly/storage/locator.go
index 924936af4..47d5866d1 100644
--- a/internal/gitaly/storage/locator.go
+++ b/internal/gitaly/storage/locator.go
@@ -7,10 +7,16 @@ import (
"os"
"path/filepath"
"strings"
-
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
)
+// Repository represents a storage-scoped repository.
+type Repository interface {
+ GetStorageName() string
+ GetRelativePath() string
+ GetGitObjectDirectory() string
+ GetGitAlternateObjectDirectories() []string
+}
+
// Locator allows to get info about location of the repository or storage at the local file system.
type Locator interface {
// GetRepoPath returns the full path of the repository referenced by an RPC Repository message.
@@ -18,11 +24,11 @@ type Locator interface {
// the `GetRepoPathOption` produced by `WithRepositoryVerificationSkipped()`, this validation
// will be skipped. The errors returned are gRPC errors with relevant error codes and should be
// passed back to gRPC without further decoration.
- GetRepoPath(repo repository.GitRepo, opts ...GetRepoPathOption) (string, error)
+ GetRepoPath(repo Repository, opts ...GetRepoPathOption) (string, error)
// GetPath returns the path of the repo passed as first argument. An error is
// returned when either the storage can't be found or the path includes
// constructs trying to perform directory traversal.
- GetPath(repo repository.GitRepo) (string, error)
+ GetPath(repo Repository) (string, error)
// GetStorageByName will return the path for the storage, which is fetched by
// its key. An error is return if it cannot be found.
GetStorageByName(storageName string) (string, error)
@@ -99,7 +105,7 @@ func IsGitDirectory(dir string) bool {
// us to verify that a given quarantine object directory indeed belongs to the repository at hand.
// Ideally, this function would directly be located in the quarantine module, but this is not
// possible due to cyclic dependencies.
-func QuarantineDirectoryPrefix(repo repository.GitRepo) string {
+func QuarantineDirectoryPrefix(repo Repository) string {
hash := [20]byte{}
if repo != nil {
hash = sha1.Sum([]byte(repo.GetRelativePath()))
diff --git a/internal/helper/repo.go b/internal/helper/repo.go
index 4ab23baa3..810cefffe 100644
--- a/internal/helper/repo.go
+++ b/internal/helper/repo.go
@@ -1,11 +1,9 @@
package helper
-import (
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
-)
+import "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
// RepoPathEqual compares if two repositories are in the same location
-func RepoPathEqual(a, b repository.GitRepo) bool {
+func RepoPathEqual(a, b storage.Repository) bool {
return a.GetStorageName() == b.GetStorageName() &&
a.GetRelativePath() == b.GetRelativePath()
}
diff --git a/internal/praefect/praefectutil/replica_path.go b/internal/praefect/praefectutil/replica_path.go
index ecc31f277..a4380764d 100644
--- a/internal/praefect/praefectutil/replica_path.go
+++ b/internal/praefect/praefectutil/replica_path.go
@@ -7,14 +7,14 @@ import (
"strconv"
"strings"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
)
// poolPathPrefix is the prefix directory where Praefect places object pools.
const poolPathPrefix = "@cluster/pools/"
// IsPoolRepository returns whether the repository is a Praefect generated object pool repository.
-func IsPoolRepository(repo repository.GitRepo) bool {
+func IsPoolRepository(repo storage.Repository) bool {
return strings.HasPrefix(repo.GetRelativePath(), poolPathPrefix)
}