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-08-22 13:36:13 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-08-23 08:08:33 +0300
commitb69a1b7cd595a81dca5054db7423a4a67b22c613 (patch)
treec132618641ea87e0754eed417829fdb4ae6478df
parentdbf4ad6f9804cc8a3ddb241a1a5ff1e21b2400d9 (diff)
gittest: Move object-hash related functions
Move object-hash related functions into "object_hash.go" such that conceptually similar functionality is grouped together.
-rw-r--r--internal/git/gittest/object_hash.go15
-rw-r--r--internal/git/gittest/objects.go14
2 files changed, 15 insertions, 14 deletions
diff --git a/internal/git/gittest/object_hash.go b/internal/git/gittest/object_hash.go
index ed61c3df9..8ab59d5f8 100644
--- a/internal/git/gittest/object_hash.go
+++ b/internal/git/gittest/object_hash.go
@@ -4,6 +4,7 @@ import (
"os"
"testing"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
)
@@ -22,3 +23,17 @@ func SkipWithSHA256(tb testing.TB) {
tb.Skip("test is not compatible with SHA256")
}
}
+
+// ObjectHashIsSHA256 returns if the current default object hash is SHA256.
+func ObjectHashIsSHA256() bool {
+ return DefaultObjectHash.EmptyTreeOID == git.ObjectHashSHA256.EmptyTreeOID
+}
+
+// ObjectHashDependent returns the value from the given map that is associated with the default
+// object hash (e.g. "sha1", "sha256"). Fails in case the map doesn't contain the current object
+// hash.
+func ObjectHashDependent[T any](tb testing.TB, valuesByObjectHash map[string]T) T {
+ tb.Helper()
+ require.Contains(tb, valuesByObjectHash, DefaultObjectHash.Format)
+ return valuesByObjectHash[DefaultObjectHash.Format]
+}
diff --git a/internal/git/gittest/objects.go b/internal/git/gittest/objects.go
index 821f58b04..a365dd1e8 100644
--- a/internal/git/gittest/objects.go
+++ b/internal/git/gittest/objects.go
@@ -15,20 +15,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
)
-// ObjectHashIsSHA256 returns if the current default object hash is SHA256.
-func ObjectHashIsSHA256() bool {
- return DefaultObjectHash.EmptyTreeOID == git.ObjectHashSHA256.EmptyTreeOID
-}
-
-// ObjectHashDependent returns the value from the given map that is associated with the default
-// object hash (e.g. "sha1", "sha256"). Fails in case the map doesn't contain the current object
-// hash.
-func ObjectHashDependent[T any](tb testing.TB, valuesByObjectHash map[string]T) T {
- tb.Helper()
- require.Contains(tb, valuesByObjectHash, DefaultObjectHash.Format)
- return valuesByObjectHash[DefaultObjectHash.Format]
-}
-
// ListObjects returns a list of all object IDs in the repository.
func ListObjects(tb testing.TB, cfg config.Cfg, repoPath string) []git.ObjectID {
tb.Helper()