diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d991cfa0c8d8b44111d953949502cfc23b17f60..1a188c746d4f4f3cc8dd3479a46771a2f31d97c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ default: .versions: debian: "bookworm" git_default: "default" - git_minimum: "v2.46.0" + git_minimum: "v2.47.0" go_default: "1.22" go_supported: ["1.22", "1.23"] macos: "macos-14-xcode-15" @@ -301,8 +301,6 @@ test:reftable: <<: *test_definition variables: <<: *test_variables - GITALY_TEST_ENABLE_SYMREF_UPDATE: "true" - GIT_VERSION: "v2.46.0" TEST_TARGET: test-with-reftable test:nightly: diff --git a/Makefile b/Makefile index 1aacac7a1846b6aaaa6c36880bde3856255f40c7..a55274bebe72c1cfeb4a4793e3818347464b0ac7 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,6 @@ GIT_VERSION ?= # GIT_VERSION_x_xx defines versions for each instance of bundled Git we ship. When a new # major version is added, be sure to update GIT_PACKED_EXECUTABLES, the *-bundled-git targets, # and add new targets under the "# These targets build specific releases of Git." section. -GIT_VERSION_2_46 ?= v2.46.2 GIT_VERSION_2_47 ?= v2.47.0 # # OVERRIDE_GIT_VERSION allows you to specify a custom semver value to be reported by the @@ -148,7 +147,7 @@ OVERRIDE_GIT_VERSION ?= ${GIT_VERSION} ifeq (${GIT_VERSION:default=},) # GIT_VERSION should be overridden to the default version of bundled Git. This is only # necessary until https://gitlab.com/gitlab-org/gitaly/-/issues/6195 is complete. - override GIT_VERSION := ${GIT_VERSION_2_46} + override GIT_VERSION := ${GIT_VERSION_2_47} # When GIT_VERSION is not explicitly set, we default to bundled Git. export WITH_BUNDLED_GIT = YesPlease else @@ -216,8 +215,7 @@ BUILD_GEM_OPTIONS ?= BUILD_GEM_NAME ?= gitaly # Git binaries that are eventually embedded into the Gitaly binary. -GIT_PACKED_EXECUTABLES = $(addprefix ${BUILD_DIR}/bin/gitaly-, $(addsuffix -v2.46, ${GIT_EXECUTABLES})) \ - $(addprefix ${BUILD_DIR}/bin/gitaly-, $(addsuffix -v2.47, ${GIT_EXECUTABLES})) +GIT_PACKED_EXECUTABLES = $(addprefix ${BUILD_DIR}/bin/gitaly-, $(addsuffix -v2.47, ${GIT_EXECUTABLES})) # All executables provided by Gitaly. GITALY_EXECUTABLES = $(addprefix ${BUILD_DIR}/bin/,$(notdir $(shell find ${SOURCE_DIR}/cmd -mindepth 1 -maxdepth 1 -type d -print))) @@ -306,15 +304,13 @@ install: build .PHONY: build-bundled-git ## Build bundled Git binaries. -build-bundled-git: build-bundled-git-v2.46 build-bundled-git-v2.47 -build-bundled-git-v2.46: $(patsubst %,${BUILD_DIR}/bin/gitaly-%-v2.46,${GIT_EXECUTABLES}) +build-bundled-git: build-bundled-git-v2.47 build-bundled-git-v2.47: $(patsubst %,${BUILD_DIR}/bin/gitaly-%-v2.47,${GIT_EXECUTABLES}) .PHONY: install-bundled-git ## Install bundled Git binaries. The target directory can be modified by ## setting PREFIX and DESTDIR. -install-bundled-git: install-bundled-git-v2.46 install-bundled-git-v2.47 -install-bundled-git-v2.46: $(patsubst %,${INSTALL_DEST_DIR}/gitaly-%-v2.46,${GIT_EXECUTABLES}) +install-bundled-git: install-bundled-git-v2.47 install-bundled-git-v2.47: $(patsubst %,${INSTALL_DEST_DIR}/gitaly-%-v2.47,${GIT_EXECUTABLES}) ifdef WITH_BUNDLED_GIT @@ -574,10 +570,6 @@ ${DEPENDENCY_DIR}/git-distribution/git: ${DEPENDENCY_DIR}/git-distribution/Makef ${Q}touch $@ # These targets build specific releases of Git. -${BUILD_DIR}/bin/gitaly-%-v2.46: override GIT_VERSION = ${GIT_VERSION_2_46} -${BUILD_DIR}/bin/gitaly-%-v2.46: ${DEPENDENCY_DIR}/git-v2.46/% | ${BUILD_DIR}/bin - ${Q}install $< $@ - ${BUILD_DIR}/bin/gitaly-%-v2.47: override GIT_VERSION = ${GIT_VERSION_2_47} ${BUILD_DIR}/bin/gitaly-%-v2.47: ${DEPENDENCY_DIR}/git-v2.47/% | ${BUILD_DIR}/bin ${Q}install $< $@ diff --git a/README.md b/README.md index 8b1b1f50a7d354d6e4b264e3d7714591a918f819..2665e70689ad611e513029adc8fed372461e3e37 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Most users won't install Gitaly on its own. It is already included in [your GitL Gitaly requires Go 1.22. Run `make` to compile the executables required by Gitaly. -Gitaly uses `git`. Versions `2.46.0` and newer are supported. +Gitaly uses `git`. Versions `2.47.0` and newer are supported. ## Configuration diff --git a/internal/featureflag/ff_git_v247.go b/internal/featureflag/ff_git_v247.go deleted file mode 100644 index d8d9760669ae55e143dcb676795d3ace54b351b1..0000000000000000000000000000000000000000 --- a/internal/featureflag/ff_git_v247.go +++ /dev/null @@ -1,9 +0,0 @@ -package featureflag - -// GitV247 enables the use Git v2.47. -var GitV247 = NewFeatureFlag( - "git_v247", - "v17.5.0", - "https://gitlab.com/gitlab-org/gitaly/-/issues/6419", - false, -) diff --git a/internal/featureflag/ff_symref_updates.go b/internal/featureflag/ff_symref_updates.go deleted file mode 100644 index 89eeadd2dcc5ef9704147034a19059e86d83a89d..0000000000000000000000000000000000000000 --- a/internal/featureflag/ff_symref_updates.go +++ /dev/null @@ -1,16 +0,0 @@ -package featureflag - -// SymrefUpdate is used to handle the rollout of using symref-update -// subcommands. This is required because the new command uses a different -// voting hash and to stay backward compatible we need to ensure that -// all nodes are on the same version before enabling this. -// -// Note that the command itself will be released in Git 2.46.0, and hence -// can only be enabled once that Git version is set to be the minimum (or -// if the patches are backported). -var SymrefUpdate = NewFeatureFlag( - "symref_update", - "v17.2.0", - "https://gitlab.com/gitlab-org/gitaly/-/issues/6153", - false, -) diff --git a/internal/git/gitcmd/execution_environment.go b/internal/git/gitcmd/execution_environment.go index ef3521487c112455657a9f7de63e2622f268c2bc..75a2e7b4d04fd93183a086d323e74f687e0e05d3 100644 --- a/internal/git/gitcmd/execution_environment.go +++ b/internal/git/gitcmd/execution_environment.go @@ -23,12 +23,6 @@ var ( BundledGitConstructors = []BundledGitEnvironmentConstructor{ { Suffix: "-v2.47", - FeatureFlags: []featureflag.FeatureFlag{ - featureflag.GitV247, - }, - }, - { - Suffix: "-v2.46", }, } diff --git a/internal/git/gittest/version.go b/internal/git/gittest/version.go index fc956b4810348db44777fe2978fb25e8a6853130..d0bb99e89a1f5874a6f091e2b9c019eb631de0af 100644 --- a/internal/git/gittest/version.go +++ b/internal/git/gittest/version.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" "gitlab.com/gitlab-org/gitaly/v16/internal/git" "gitlab.com/gitlab-org/gitaly/v16/internal/git/gitcmd" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" @@ -40,12 +39,3 @@ func SkipIfGitVersion(tb testing.TB, ctx context.Context, cfg config.Cfg, expect tb.Skipf("Unsupported Git version %q, expected %q: %q", actual, expected, reason) } } - -// IfSymrefUpdateSupported returns the appropriate value based on if symref updates are enabled. -func IfSymrefUpdateSupported[T any](tb testing.TB, ctx context.Context, cfg config.Cfg, yes, no T) T { - if featureflag.SymrefUpdate.IsEnabled(ctx) { - return yes - } - - return no -} diff --git a/internal/git/localrepo/refs.go b/internal/git/localrepo/refs.go index 244d8656bc06bc6f0d49eeba3c600b0ca5eb55b6..39e224d9cbb41744eaabae4986c5a8cc8a11a708 100644 --- a/internal/git/localrepo/refs.go +++ b/internal/git/localrepo/refs.go @@ -7,17 +7,13 @@ import ( "errors" "fmt" "io" - "path/filepath" "strings" "gitlab.com/gitlab-org/gitaly/v16/internal/command" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" "gitlab.com/gitlab-org/gitaly/v16/internal/git" "gitlab.com/gitlab-org/gitaly/v16/internal/git/gitcmd" "gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref" - "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/safe" ) // ErrMismatchingState is similar to updateref.MismatchingStateError. It's declared separately to avoid @@ -162,14 +158,7 @@ func (repo *Repo) SetDefaultBranch(ctx context.Context, txManager transaction.Ma return fmt.Errorf("%q is a malformed refname", reference) } - // To ensure we stay backward compatible, we should only use the new mechanism - // once all nodes have been updated to contain the code for symref updates. - // This is the reason we use a feature flag to propagate this change. - if featureflag.SymrefUpdate.IsEnabled(ctx) { - return repo.setDefaultBranchWithUpdateRef(ctx, reference, version) - } - - return repo.setDefaultBranchManually(ctx, txManager, reference) + return repo.setDefaultBranchWithUpdateRef(ctx, reference, version) } // setDefaultBranchWithUpdateRef uses 'symref-update' command to update HEAD. @@ -204,43 +193,6 @@ func (repo *Repo) setDefaultBranchWithUpdateRef( return nil } -// setDefaultBranchWithTransaction sets the repository's HEAD to point to the given reference -// using a safe locking file writer and commits the transaction if one exists in the context -func (repo *Repo) setDefaultBranchManually(ctx context.Context, txManager transaction.Manager, reference git.ReferenceName) error { - newHeadContent := []byte(fmt.Sprintf("ref: %s\n", reference.String())) - - repoPath, err := repo.Path(ctx) - if err != nil { - return fmt.Errorf("getting repository path: %w", err) - } - - headPath := filepath.Join(repoPath, "HEAD") - - lockingFileWriter, err := safe.NewLockingFileWriter(headPath) - if err != nil { - return fmt.Errorf("getting file writer: %w", err) - } - defer func() { - if err := lockingFileWriter.Close(); err != nil { - repo.logger.WithError(err).ErrorContext(ctx, "closing locked HEAD failed") - } - }() - - if _, err := lockingFileWriter.Write(newHeadContent); err != nil { - return fmt.Errorf("writing temporary HEAD: %w", err) - } - - if err := transaction.CommitLockedFile(ctx, txManager, lockingFileWriter); err != nil { - return fmt.Errorf("committing temporary HEAD: %w", err) - } - - if tx := storage.ExtractTransaction(ctx); tx != nil { - tx.MarkDefaultBranchUpdated() - } - - return nil -} - type getRemoteReferenceConfig struct { patterns []string config []gitcmd.ConfigPair diff --git a/internal/git/localrepo/refs_external_test.go b/internal/git/localrepo/refs_external_test.go index 01698c233990e4b318214ba3db0758e5390132a8..2bfee949034665088469c3a67351bba4c725493b 100644 --- a/internal/git/localrepo/refs_external_test.go +++ b/internal/git/localrepo/refs_external_test.go @@ -5,14 +5,11 @@ import ( "context" "errors" "fmt" - "os" - "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/v16/internal/command" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" "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/gitcmd" @@ -22,9 +19,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service/hook" - "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage/mode" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction" - "gitlab.com/gitlab-org/gitaly/v16/internal/safe" "gitlab.com/gitlab-org/gitaly/v16/internal/structerr" "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg" @@ -123,10 +118,7 @@ func TestRepo_SetDefaultBranch(t *testing.T) { require.Len(t, txManager.Votes(), 2) h := voting.NewVoteHash() - _, err = fmt.Fprint(h, gittest.IfSymrefUpdateSupported(t, ctx, cfg, - fmt.Sprintf("%s ref:%s %s\n", gittest.DefaultObjectHash.ZeroOID, tc.ref.String(), "HEAD"), - fmt.Sprintf("ref: %s\n", tc.ref.String()), - )) + _, err = fmt.Fprintf(h, "%s ref:%s %s\n", gittest.DefaultObjectHash.ZeroOID, tc.ref.String(), "HEAD") require.NoError(t, err) vote, err := h.Vote() @@ -162,7 +154,7 @@ func TestRepo_SetDefaultBranch_errors(t *testing.T) { t.Parallel() cfg := testcfg.Build(t) - repoPath, repo := setupRepoWithHooksServer(t, ctx, cfg) + _, repo := setupRepoWithHooksServer(t, ctx, cfg) ref, err := repo.HeadReference(ctx) require.NoError(t, err) @@ -173,20 +165,16 @@ func TestRepo_SetDefaultBranch_errors(t *testing.T) { updater, err := updateref.New(ctx, repo) require.NoError(t, err) - if featureflag.SymrefUpdate.IsEnabled(ctx) { - require.NoError(t, updater.Start()) - require.NoError(t, updater.UpdateSymbolicReference(version, "HEAD", "refs/heads/temp")) - require.NoError(t, updater.Prepare()) - t.Cleanup(func() { require.NoError(t, updater.Close()) }) - } else { - require.NoError(t, os.WriteFile(filepath.Join(repoPath, "HEAD.lock"), []byte(""), mode.File)) - } + require.NoError(t, updater.Start()) + require.NoError(t, updater.UpdateSymbolicReference(version, "HEAD", "refs/heads/temp")) + require.NoError(t, updater.Prepare()) + t.Cleanup(func() { require.NoError(t, updater.Close()) }) err = repo.SetDefaultBranch(ctx, &transaction.MockManager{}, "refs/heads/branch") - require.ErrorIs(t, err, gittest.IfSymrefUpdateSupported(t, ctx, cfg, gittest.FilesOrReftables[error]( + require.ErrorIs(t, err, gittest.FilesOrReftables[error]( updateref.AlreadyLockedError{ReferenceName: "HEAD"}, updateref.AlreadyLockedError{}, - ), safe.ErrFileAlreadyLocked)) + )) refAfter, err := repo.HeadReference(ctx) require.NoError(t, err) @@ -258,19 +246,14 @@ func TestRepo_SetDefaultBranch_errors(t *testing.T) { }, } - repoPath, repo := setupRepoWithHooksServer(t, ctx, cfg, testserver.WithTransactionManager(failingTxManager)) + _, repo := setupRepoWithHooksServer(t, ctx, cfg, testserver.WithTransactionManager(failingTxManager)) err = repo.SetDefaultBranch(ctx, failingTxManager, "refs/heads/branch") require.Error(t, err) - if featureflag.SymrefUpdate.IsEnabled(ctx) { - var sErr structerr.Error - require.ErrorAs(t, err, &sErr) - require.Equal(t, "error executing git hook\nfatal: ref updates aborted by hook\n", sErr.Metadata()["stderr"]) - } else { - require.Equal(t, "committing temporary HEAD: voting on locked file: preimage vote: injected error", err.Error()) - require.NoFileExists(t, filepath.Join(repoPath, "HEAD.lock")) - } + var sErr structerr.Error + require.ErrorAs(t, err, &sErr) + require.Equal(t, "error executing git hook\nfatal: ref updates aborted by hook\n", sErr.Metadata()["stderr"]) }) } diff --git a/internal/git/version.go b/internal/git/version.go index 55a6f8166910ad0ff16ee12c73288385acd57e49..2fe5323b4ab0d608e649f839cc29168ed1ca4cbe 100644 --- a/internal/git/version.go +++ b/internal/git/version.go @@ -14,9 +14,9 @@ import ( // - https://docs.gitlab.com/ee/install/installation.html#software-requirements // - https://docs.gitlab.com/ee/update/ (see e.g. https://docs.gitlab.com/ee/update/#1440) var minimumVersion = Version{ - versionString: "2.46.0", + versionString: "2.47.0", major: 2, - minor: 46, + minor: 47, patch: 0, rc: false, diff --git a/internal/git/version_test.go b/internal/git/version_test.go index 173de8b601a27ab5f757bc74db95272c7beb92ed..1ad60e760f602493d93c23301e6136037a88670b 100644 --- a/internal/git/version_test.go +++ b/internal/git/version_test.go @@ -197,9 +197,9 @@ func TestVersion_IsSupported(t *testing.T) { {"2.24.0", false}, {"2.43.0", false}, {"2.44.0", false}, - {"2.45.0-rc0", false}, - {"2.45.0", false}, - {"2.46.0", true}, + {"2.46.0-rc0", false}, + {"2.46.0", false}, + {"2.47.0", true}, {"3.0.0", true}, {"3.0.0.gl5", true}, } { diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go index 6566b2fa769c16ac87965e3ad8799244f27ea07f..ead5daa3a558990dde7cae9b858d69af5f95d646 100644 --- a/internal/gitaly/service/repository/replicate_test.go +++ b/internal/gitaly/service/repository/replicate_test.go @@ -649,9 +649,8 @@ func TestFetchInternalRemote_successful(t *testing.T) { }, ) - // When using 'symref-updates' we use the reference-transaction - // hook for the default branch updates. - require.Equal(t, gittest.IfSymrefUpdateSupported(t, ctx, remoteCfg, 4, 2), referenceTransactionHookCalled) + // We use the reference-transaction hook for the default branch updates. + require.Equal(t, 4, referenceTransactionHookCalled) } func TestFetchInternalRemote_failure(t *testing.T) { diff --git a/internal/gitaly/service/repository/write_ref_test.go b/internal/gitaly/service/repository/write_ref_test.go index 8331e96f96b108fbc5395350e83c6d4d734ca04c..08c5f417687314d3f408931775ae7f4a7906168d 100644 --- a/internal/gitaly/service/repository/write_ref_test.go +++ b/internal/gitaly/service/repository/write_ref_test.go @@ -266,20 +266,14 @@ func TestWriteRef(t *testing.T) { git.NewReference(git.DefaultRef, defaultCommit), git.NewReference("refs/heads/new-default", newCommit), }, - expectedVotes: gittest.IfSymrefUpdateSupported(t, ctx, cfg, - []transaction.PhasedVote{ - {Phase: voting.Prepared, Vote: voting.VoteFromData([]byte( - fmt.Sprintf("%s ref:refs/heads/new-default HEAD\n", gittest.DefaultObjectHash.ZeroOID), - ))}, - {Phase: voting.Committed, Vote: voting.VoteFromData([]byte( - fmt.Sprintf("%s ref:refs/heads/new-default HEAD\n", gittest.DefaultObjectHash.ZeroOID), - ))}, - }, - []transaction.PhasedVote{ - {Phase: voting.Prepared, Vote: voting.VoteFromData([]byte("ref: refs/heads/new-default\n"))}, - {Phase: voting.Committed, Vote: voting.VoteFromData([]byte("ref: refs/heads/new-default\n"))}, - }, - ), + expectedVotes: []transaction.PhasedVote{ + {Phase: voting.Prepared, Vote: voting.VoteFromData([]byte( + fmt.Sprintf("%s ref:refs/heads/new-default HEAD\n", gittest.DefaultObjectHash.ZeroOID), + ))}, + {Phase: voting.Committed, Vote: voting.VoteFromData([]byte( + fmt.Sprintf("%s ref:refs/heads/new-default HEAD\n", gittest.DefaultObjectHash.ZeroOID), + ))}, + }, } }, }, diff --git a/internal/gitaly/storage/storagemgr/partition/testhelper_test.go b/internal/gitaly/storage/storagemgr/partition/testhelper_test.go index f30e2e62ab951a343209eb4b83dc17988623e701..8762216dad84b2299bc6678715413ffae52876d4 100644 --- a/internal/gitaly/storage/storagemgr/partition/testhelper_test.go +++ b/internal/gitaly/storage/storagemgr/partition/testhelper_test.go @@ -18,7 +18,6 @@ import ( io_prometheus_client "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" "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/gitcmd" @@ -1239,11 +1238,9 @@ func runTransactionTest(t *testing.T, ctx context.Context, tc transactionTestCas if step.DefaultBranchUpdate != nil { transaction.MarkDefaultBranchUpdated() - if featureflag.SymrefUpdate.IsEnabled(ctx) { - transaction.UpdateReferences(map[git.ReferenceName]git.ReferenceUpdate{ - "HEAD": {NewTarget: step.DefaultBranchUpdate.Reference}, - }) - } + transaction.UpdateReferences(map[git.ReferenceName]git.ReferenceUpdate{ + "HEAD": {NewTarget: step.DefaultBranchUpdate.Reference}, + }) require.NoError(t, rewrittenRepo.SetDefaultBranch(storage.ContextWithTransaction(ctx, transaction), nil, step.DefaultBranchUpdate.Reference)) } diff --git a/internal/gitaly/storage/storagemgr/partition/transaction_manager_default_branch_test.go b/internal/gitaly/storage/storagemgr/partition/transaction_manager_default_branch_test.go index 3f85e34d0374ba6f29bfec224545f959e7ba526d..5bfd1c5fc969996e08a368dd90627742d1df717d 100644 --- a/internal/gitaly/storage/storagemgr/partition/transaction_manager_default_branch_test.go +++ b/internal/gitaly/storage/storagemgr/partition/transaction_manager_default_branch_test.go @@ -247,16 +247,6 @@ func generateDefaultBranchTests(t *testing.T, setup testTransactionSetup) []tran }, { MinIndex: 2, - MaxIndex: 2, - References: []git.Reference{ - { - Name: "refs/heads/main", - Target: setup.Commits.First.OID.String(), - }, - }, - }, - { - MinIndex: 3, MaxIndex: 3, References: []git.Reference{ { @@ -264,6 +254,10 @@ func generateDefaultBranchTests(t *testing.T, setup testTransactionSetup) []tran Target: "refs/heads/non-existent", IsSymbolic: true, }, + { + Name: "refs/heads/main", + Target: setup.Commits.First.OID.String(), + }, }, }, }, @@ -348,16 +342,6 @@ func generateDefaultBranchTests(t *testing.T, setup testTransactionSetup) []tran }, { MinIndex: 3, - MaxIndex: 3, - References: []git.Reference{ - { - Name: "refs/heads/branch2", - Target: setup.ObjectHash.ZeroOID.String(), - }, - }, - }, - { - MinIndex: 4, MaxIndex: 4, References: []git.Reference{ { @@ -365,6 +349,10 @@ func generateDefaultBranchTests(t *testing.T, setup testTransactionSetup) []tran Target: "refs/heads/branch2", IsSymbolic: true, }, + { + Name: "refs/heads/branch2", + Target: setup.ObjectHash.ZeroOID.String(), + }, }, }, }, @@ -450,16 +438,6 @@ func generateDefaultBranchTests(t *testing.T, setup testTransactionSetup) []tran }, { MinIndex: 3, - MaxIndex: 3, - References: []git.Reference{ - { - Name: "refs/heads/main", - Target: setup.Commits.Second.OID.String(), - }, - }, - }, - { - MinIndex: 4, MaxIndex: 4, References: []git.Reference{ { @@ -467,6 +445,10 @@ func generateDefaultBranchTests(t *testing.T, setup testTransactionSetup) []tran Target: "refs/heads/branch2", IsSymbolic: true, }, + { + Name: "refs/heads/main", + Target: setup.Commits.Second.OID.String(), + }, }, }, }, diff --git a/internal/gitaly/storage/storagemgr/partition/transaction_manager_housekeeping_test.go b/internal/gitaly/storage/storagemgr/partition/transaction_manager_housekeeping_test.go index 635d7919a3d0690b2ac5514138e81b5b6271728e..f0e36bd571e21bcb5063f35960618e12387fbf51 100644 --- a/internal/gitaly/storage/storagemgr/partition/transaction_manager_housekeeping_test.go +++ b/internal/gitaly/storage/storagemgr/partition/transaction_manager_housekeeping_test.go @@ -4650,16 +4650,6 @@ func generateHousekeepingRepackingConcurrentTests(t *testing.T, ctx context.Cont }, { MinIndex: 3, - MaxIndex: 3, - References: []git.Reference{ - { - Name: "refs/heads/branch-2", - Target: setup.Commits.Diverging.OID.String(), - }, - }, - }, - { - MinIndex: 4, MaxIndex: 4, References: []git.Reference{ { diff --git a/internal/gitaly/storage/storagemgr/partition/transaction_manager_refs_test.go b/internal/gitaly/storage/storagemgr/partition/transaction_manager_refs_test.go index f3362806e5fcb6d1c74b64be12484bd1aab08342..d46394eed77d835408436da404223382e6fc1f58 100644 --- a/internal/gitaly/storage/storagemgr/partition/transaction_manager_refs_test.go +++ b/internal/gitaly/storage/storagemgr/partition/transaction_manager_refs_test.go @@ -481,19 +481,12 @@ func generateModifyReferencesTests(t *testing.T, setup testTransactionSetup) []t }, { MinIndex: 3, - MaxIndex: 3, + MaxIndex: 4, References: []git.Reference{ { Name: "refs/heads/parent", Target: setup.ObjectHash.ZeroOID.String(), }, - }, - }, - - { - MinIndex: 4, - MaxIndex: 4, - References: []git.Reference{ { Name: "refs/heads/parent/child", Target: setup.Commits.First.OID.String(), @@ -2084,16 +2077,6 @@ func generateModifyReferencesTests(t *testing.T, setup testTransactionSetup) []t }, { MinIndex: 2, - MaxIndex: 2, - References: []git.Reference{ - { - Name: "refs/heads/main", - Target: setup.Commits.First.OID.String(), - }, - }, - }, - { - MinIndex: 3, MaxIndex: 3, References: []git.Reference{ { diff --git a/internal/gitaly/storage/storagemgr/partition/transaction_manager_repo_test.go b/internal/gitaly/storage/storagemgr/partition/transaction_manager_repo_test.go index 0c203538113b8baa62c0c18ebbbeb842d6100ae9..785204ee3381a73025bcade13af8416aab579165 100644 --- a/internal/gitaly/storage/storagemgr/partition/transaction_manager_repo_test.go +++ b/internal/gitaly/storage/storagemgr/partition/transaction_manager_repo_test.go @@ -1155,16 +1155,6 @@ func generateDeleteRepositoryTests(t *testing.T, setup testTransactionSetup) []t }, { MinIndex: 2, - MaxIndex: 2, - References: []git.Reference{ - { - Name: "refs/heads/main", - Target: setup.Commits.First.OID.String(), - }, - }, - }, - { - MinIndex: 3, MaxIndex: 3, References: []git.Reference{ { @@ -1172,6 +1162,10 @@ func generateDeleteRepositoryTests(t *testing.T, setup testTransactionSetup) []t Target: "refs/heads/new-head", IsSymbolic: true, }, + { + Name: "refs/heads/main", + Target: setup.Commits.First.OID.String(), + }, }, }, }, diff --git a/internal/gitaly/storage/storagemgr/partition/transaction_manager_test.go b/internal/gitaly/storage/storagemgr/partition/transaction_manager_test.go index d51dc214166090a8240d674cc0f240b0fd12e503..3bcf86be915227aea2c1a87c19a00c9caff87da7 100644 --- a/internal/gitaly/storage/storagemgr/partition/transaction_manager_test.go +++ b/internal/gitaly/storage/storagemgr/partition/transaction_manager_test.go @@ -20,7 +20,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" "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/gittest" @@ -326,15 +325,8 @@ func setupTest(t *testing.T, ctx context.Context, testPartitionID storage.Partit func TestTransactionManager(t *testing.T) { t.Parallel() - testhelper.NewFeatureSets(featureflag.SymrefUpdate).Run(t, testTransactionManager) -} - -func testTransactionManager(t *testing.T, ctx context.Context) { - t.Parallel() - if featureflag.SymrefUpdate.IsDisabled(ctx) { - testhelper.SkipWithReftable(t, "reftable tests can only be run with symref-updates feature") - } + ctx := testhelper.Context(t) // testPartitionID is the partition ID used in the tests for the TransactionManager. const testPartitionID storage.PartitionID = 1 @@ -1608,16 +1600,6 @@ func generateCommonTests(t *testing.T, ctx context.Context, setup testTransactio }, { MinIndex: 2, - MaxIndex: 2, - References: []git.Reference{ - { - Name: "refs/heads/main", - Target: setup.Commits.First.OID.String(), - }, - }, - }, - { - MinIndex: 3, MaxIndex: 3, References: []git.Reference{ { @@ -1625,6 +1607,10 @@ func generateCommonTests(t *testing.T, ctx context.Context, setup testTransactio Target: "refs/heads/new-head", IsSymbolic: true, }, + { + Name: "refs/heads/main", + Target: setup.Commits.First.OID.String(), + }, }, }, }, @@ -1684,16 +1670,6 @@ func generateCommonTests(t *testing.T, ctx context.Context, setup testTransactio }, { MinIndex: 2, - MaxIndex: 2, - References: []git.Reference{ - { - Name: "refs/heads/main", - Target: setup.Commits.First.OID.String(), - }, - }, - }, - { - MinIndex: 3, MaxIndex: 3, References: []git.Reference{ { @@ -1701,6 +1677,10 @@ func generateCommonTests(t *testing.T, ctx context.Context, setup testTransactio Target: "refs/heads/new-head", IsSymbolic: true, }, + { + Name: "refs/heads/main", + Target: setup.Commits.First.OID.String(), + }, }, }, }, diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index e86c4767ae57181587b7a625fe8cb06b590c5b48..15e2cce72a91daa3eb7f118d6f1e776f136f9ec2 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -292,18 +292,12 @@ func ContextWithoutCancel(opts ...ContextOpt) context.Context { ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.MailmapOptions, rnd.Int()%2 == 0) // Disable LogGitTraces ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.LogGitTraces, false) - // Enable SymrefUpdates - symrefUpdateEnabled, _ := env.GetBool("GITALY_TEST_ENABLE_SYMREF_UPDATE", false) - ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.SymrefUpdate, symrefUpdateEnabled) // Enable reftable backend, if env variable set newRepoReftableEnabled := env.GetString("GIT_DEFAULT_REF_FORMAT", "files") ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.NewRepoReftableBackend, newRepoReftableEnabled == "reftable") ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.RemoveCatfileCacheSessionID, rnd.Int()%2 == 0) - // Randomly enable either Git version 2.46 or 2.47. - ctx = featureflag.ContextWithFeatureFlag(ctx, featureflag.GitV247, rnd.Int()%2 == 0) - for _, opt := range opts { ctx = opt(ctx) }