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-11-23 11:02:39 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-11-23 11:02:39 +0300
commit2450fb2cce4dbcc701805860cfb65c0be1b363d7 (patch)
tree71c6e04df80eb15820ced8449bcd952a1ec01eea
parent8d1295605b7d052ee279cc6492360ff6c401d2c5 (diff)
parenta184c638750fe61b5b32e8b02e7abcd8f54f1060 (diff)
Merge branch 'jt-check-objects-exist' into 'master'
commit: Allow path scoped revisions for `CheckObjectsExist` RPC See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6539 Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com> Approved-by: Emily Chui <echui@gitlab.com> Reviewed-by: Patrick Steinhardt <psteinhardt@gitlab.com> Reviewed-by: Justin Tobler <jtobler@gitlab.com> Co-authored-by: Justin Tobler <jtobler@gitlab.com>
-rw-r--r--internal/gitaly/service/commit/check_objects_exist.go2
-rw-r--r--internal/gitaly/service/commit/check_objects_exist_test.go51
2 files changed, 52 insertions, 1 deletions
diff --git a/internal/gitaly/service/commit/check_objects_exist.go b/internal/gitaly/service/commit/check_objects_exist.go
index 43b7d0ffb..4f28e8720 100644
--- a/internal/gitaly/service/commit/check_objects_exist.go
+++ b/internal/gitaly/service/commit/check_objects_exist.go
@@ -48,7 +48,7 @@ func (s *server) CheckObjectsExist(
// Note: we have already fetched the first request containing revisions further up,
// so we only fetch the next request at the end of this loop.
for _, revision := range request.GetRevisions() {
- if err := git.ValidateRevision(revision); err != nil {
+ if err := git.ValidateRevision(revision, git.AllowPathScopedRevision()); err != nil {
return structerr.NewInvalidArgument("invalid revision: %w", err).
WithMetadata("revision", string(revision))
}
diff --git a/internal/gitaly/service/commit/check_objects_exist_test.go b/internal/gitaly/service/commit/check_objects_exist_test.go
index c97f39de5..5380285dd 100644
--- a/internal/gitaly/service/commit/check_objects_exist_test.go
+++ b/internal/gitaly/service/commit/check_objects_exist_test.go
@@ -33,6 +33,15 @@ func TestCheckObjectsExist(t *testing.T) {
gittest.WithMessage("commit-3"), gittest.WithParents(commitID1),
)
+ blobID := gittest.WriteBlob(t, cfg, repoPath, []byte("foobar"))
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("foo"), gittest.WithTreeEntries(
+ gittest.TreeEntry{OID: blobID, Path: "bar", Mode: "100644"},
+ gittest.TreeEntry{OID: blobID, Path: "~bar", Mode: "100644"},
+ gittest.TreeEntry{OID: blobID, Path: "@bar", Mode: "100644"},
+ gittest.TreeEntry{OID: blobID, Path: "@", Mode: "100644"},
+ gittest.TreeEntry{OID: blobID, Path: "bar:none", Mode: "100644"},
+ ))
+
for _, tc := range []struct {
desc string
requests []*gitalypb.CheckObjectsExistRequest
@@ -194,6 +203,48 @@ func TestCheckObjectsExist(t *testing.T) {
structerr.NewInvalidArgument("invalid revision: revision can't start with '-'"),
"revision", "-not-a-rev"),
},
+ {
+ desc: "path scoped revisions",
+ requests: []*gitalypb.CheckObjectsExistRequest{
+ {
+ Repository: repo,
+ Revisions: [][]byte{
+ []byte("foo:bar"),
+ []byte("bar:foo"),
+ },
+ },
+ },
+ expectedResults: map[string]bool{
+ "foo:bar": true,
+ "bar:foo": false,
+ },
+ },
+ {
+ desc: "path scoped revisions",
+ requests: []*gitalypb.CheckObjectsExistRequest{
+ {
+ Repository: repo,
+ Revisions: [][]byte{
+ []byte("foo:bar"),
+ []byte("bar:foo"),
+ []byte("bar:foo\nfoo"),
+ []byte("foo:~bar"),
+ []byte("foo:@bar"),
+ []byte("foo:@"),
+ []byte("foo:bar:none"),
+ },
+ },
+ },
+ expectedResults: map[string]bool{
+ "foo:bar": true,
+ "bar:foo": false,
+ "bar:foo\nfoo": false,
+ "foo:~bar": true,
+ "foo:@bar": true,
+ "foo:@": true,
+ "foo:bar:none": true,
+ },
+ },
} {
t.Run(tc.desc, func(t *testing.T) {
client, err := client.CheckObjectsExist(ctx)