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:
authorSami Hiltunen <shiltunen@gitlab.com>2023-04-25 21:03:39 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2023-05-10 17:40:37 +0300
commitd32eed5c922ab49a11faa465a081a8791db8bd0e (patch)
tree4e93c2b7d28b44e02b87a12f9f9f4c052bf0075f /internal/gitaly/transaction_manager_hook_test.go
parent574e4120aaa8cf2d58a61a7d3f651d7c53c6749b (diff)
Inject a factory for localrepo.Repos instead of a Repo
TransactionManager is currently taking in a localrepo.Repo as a parameter. This works fine enough if the repository exists. We'll soon be handling repository creations and deletions as well. For those operations the same localrepo.Repo instance may not work: 1. If the repository is being created, we'll still need a git repo to stage the transaction in. Certain command like 'rev-list' and 'pack-objects' require a repository. We are also using Git to verify the references which we can't do without a repository. Repository creations will use a temporary staging repository to run these commands. The factory being injected here will be used to construct its localrepo.Repo instance. 2. localrepo.Repo is caching the object hash information. If a repository is deleted and recreated, the repository may be recreated with a different object format, in which case the cached format would be wrong. This likely never happens in context of GitLab Rails, but since the API allows for it, it needs to be handled. With the factory we can recreate the localrepo.Repo, and thus check the object format again after the recreation. This commit thus plugs in a localrepo.Repo factory instead of a particular instance to lay the ground for addressing both of the points.
Diffstat (limited to 'internal/gitaly/transaction_manager_hook_test.go')
-rw-r--r--internal/gitaly/transaction_manager_hook_test.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/internal/gitaly/transaction_manager_hook_test.go b/internal/gitaly/transaction_manager_hook_test.go
index c47785ec0..3ecee4e14 100644
--- a/internal/gitaly/transaction_manager_hook_test.go
+++ b/internal/gitaly/transaction_manager_hook_test.go
@@ -10,7 +10,6 @@ import (
"github.com/dgraph-io/badger/v3"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
)
// hookFunc is a function that is executed at a specific point. It gets a hookContext that allows it to
@@ -43,7 +42,7 @@ type hooks struct {
}
// installHooks installs the configured hooks into the transactionManager.
-func installHooks(tb testing.TB, transactionManager *TransactionManager, database *badger.DB, repository *localrepo.Repo, hooks hooks) {
+func installHooks(tb testing.TB, transactionManager *TransactionManager, database *badger.DB, hooks hooks) {
hookContext := hookContext{stopManager: transactionManager.stop, database: database, tb: &testingHook{TB: tb}}
transactionManager.stop = func() {
@@ -69,7 +68,7 @@ func installHooks(tb testing.TB, transactionManager *TransactionManager, databas
}
transactionManager.repository = repositoryHook{
- repository: repository,
+ repository: transactionManager.repository,
hookContext: hookContext,
hooks: hooks,
}