diff options
author | Chad Woolley <cwoolley@gitlab.com> | 2022-05-04 13:18:14 +0300 |
---|---|---|
committer | Chad Woolley <cwoolley@gitlab.com> | 2022-05-04 13:18:14 +0300 |
commit | 8a43f35526bbb1a75ea1e1b85addbc01791b6b78 (patch) | |
tree | fceaecd7e86dcb1d9ccacbdc88b9ba2006c783be | |
parent | fce08220a78826c50475b2422efbba8a3712c202 (diff) |
WIP - attempt to add modesjc-send-oid-in-list-files-response
-rw-r--r-- | internal/gitaly/service/commit/list_files.go | 1 | ||||
-rw-r--r-- | internal/gitaly/service/commit/list_files_test.go | 37 | ||||
-rw-r--r-- | proto/commit.proto | 1 | ||||
-rw-r--r-- | proto/go/gitalypb/commit.pb.go | 1 | ||||
-rw-r--r-- | ruby/proto/gitaly/commit_pb.rb | 1 |
5 files changed, 41 insertions, 0 deletions
diff --git a/internal/gitaly/service/commit/list_files.go b/internal/gitaly/service/commit/list_files.go index 960398a49..b143eb42c 100644 --- a/internal/gitaly/service/commit/list_files.go +++ b/internal/gitaly/service/commit/list_files.go @@ -97,6 +97,7 @@ func (s *server) listFiles(repo git.RepositoryExecutor, revision string, stream if err := sender.Send(&gitalypb.ListFilesResponse{ Paths: [][]byte{[]byte(entry.Path)}, Oids: []string{entry.ObjectID.String()}, + Modes: [][]byte{entry.Mode}, }); err != nil { return err } diff --git a/internal/gitaly/service/commit/list_files_test.go b/internal/gitaly/service/commit/list_files_test.go index d4f10ac03..95dc495e2 100644 --- a/internal/gitaly/service/commit/list_files_test.go +++ b/internal/gitaly/service/commit/list_files_test.go @@ -1,6 +1,7 @@ package commit import ( + "fmt" "io" "testing" @@ -63,6 +64,31 @@ var defaultOIDs = []string{ "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "8c3014aceae45386c3c026a7ea4a1f68660d51d6", } +var defaultModes = [][]byte{ + []byte(".gitattributes"), []byte(".gitignore"), []byte(".gitmodules"), + []byte("CHANGELOG"), []byte("CONTRIBUTING.md"), []byte("Gemfile.zip"), + []byte("LICENSE"), []byte("MAINTENANCE.md"), []byte("PROCESS.md"), + []byte("README"), []byte("README.md"), []byte("VERSION"), + []byte("bar/branch-test.txt"), []byte("custom-highlighting/test.gitlab-custom"), + []byte("encoding/feature-1.txt"), []byte("encoding/feature-2.txt"), + []byte("encoding/hotfix-1.txt"), []byte("encoding/hotfix-2.txt"), + []byte("encoding/iso8859.txt"), []byte("encoding/russian.rb"), + []byte("encoding/test.txt"), []byte("encoding/テスト.txt"), []byte("encoding/テスト.xls"), + []byte("files/html/500.html"), []byte("files/images/6049019_460s.jpg"), + []byte("files/images/logo-black.png"), []byte("files/images/logo-white.png"), + []byte("files/images/wm.svg"), []byte("files/js/application.js"), + []byte("files/js/commit.coffee"), []byte("files/lfs/lfs_object.iso"), + []byte("files/markdown/ruby-style-guide.md"), []byte("files/ruby/popen.rb"), + []byte("files/ruby/regex.rb"), []byte("files/ruby/version_info.rb"), + []byte("files/whitespace"), []byte("foo/bar/.gitkeep"), + []byte("gitaly/file-with-multiple-chunks"), []byte("gitaly/logo-white.png"), + []byte("gitaly/mode-file"), []byte("gitaly/mode-file-with-mods"), + []byte("gitaly/no-newline-at-the-end"), []byte("gitaly/renamed-file"), + []byte("gitaly/renamed-file-with-mods"), []byte("gitaly/symlink-to-be-regular"), + []byte("gitaly/tab\tnewline\n file"), []byte("gitaly/テスト.txt"), + []byte("with space/README.md"), +} + func TestListFiles_success(t *testing.T) { ctx := testhelper.Context(t) cfg, repo, repoPath, client := setupCommitServiceWithRepo(ctx, t, true) @@ -74,6 +100,7 @@ func TestListFiles_success(t *testing.T) { revision string files [][]byte oids []string + modes [][]byte }{ { desc: "valid object ID", @@ -128,42 +155,51 @@ func TestListFiles_success(t *testing.T) { "7d70e02340bac451f281cecf0a980907974bd8be", "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", }, + modes: [][]byte{ + []byte("100644"), + }, }, { desc: "valid branch", revision: "test-do-not-touch", files: defaultFiles, oids: defaultOIDs, + modes: defaultModes, }, { desc: "valid fully qualified branch", revision: "refs/heads/test-do-not-touch", files: defaultFiles, oids: defaultOIDs, + modes: defaultModes, }, { desc: "missing object ID uses default branch", revision: "", files: defaultFiles, oids: defaultOIDs, + modes: defaultModes, }, { desc: "invalid object ID", revision: "1234123412341234", files: [][]byte{}, oids: []string{}, + modes: [][]byte{}, }, { desc: "invalid branch", revision: "non/existing", files: [][]byte{}, oids: []string{}, + modes: [][]byte{}, }, { desc: "nonexisting fully qualified branch", revision: "refs/heads/foobar", files: [][]byte{}, oids: []string{}, + modes: [][]byte{}, }, } @@ -174,6 +210,7 @@ func TestListFiles_success(t *testing.T) { } c, err := client.ListFiles(ctx, &rpcRequest) + fmt.Printf("%#v", c) require.NoError(t, err) var files [][]byte diff --git a/proto/commit.proto b/proto/commit.proto index f99f54f31..72e24291e 100644 --- a/proto/commit.proto +++ b/proto/commit.proto @@ -358,6 +358,7 @@ message ListFilesResponse { // Remember to force encoding utf-8 on the client side repeated bytes paths = 1; repeated string oids = 2; + repeated bytes modes = 3; } message FindCommitRequest { diff --git a/proto/go/gitalypb/commit.pb.go b/proto/go/gitalypb/commit.pb.go index 8e0b6fd38..131cda546 100644 --- a/proto/go/gitalypb/commit.pb.go +++ b/proto/go/gitalypb/commit.pb.go @@ -1621,6 +1621,7 @@ type ListFilesResponse struct { // Remember to force encoding utf-8 on the client side Paths [][]byte `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"` Oids []string `protobuf:"bytes,2,rep,name=oids,proto3" json:"oids,omitempty"` + Modes [][]byte `protobuf:"bytes,3,rep,name=modes,proto3" json:"modes,omitempty"` } func (x *ListFilesResponse) Reset() { diff --git a/ruby/proto/gitaly/commit_pb.rb b/ruby/proto/gitaly/commit_pb.rb index 7a86cdb77..bc3343bb0 100644 --- a/ruby/proto/gitaly/commit_pb.rb +++ b/ruby/proto/gitaly/commit_pb.rb @@ -134,6 +134,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "gitaly.ListFilesResponse" do repeated :paths, :bytes, 1 repeated :oids, :string, 2 + repeated :modes, :bytes, 3 end add_message "gitaly.FindCommitRequest" do optional :repository, :message, 1, "gitaly.Repository" |