From be3b68e577662521ee08f31db39ab6b710f9f53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ga=C4=87e=C5=A1a?= Date: Tue, 25 Apr 2023 17:38:48 +0200 Subject: [PATCH] make merge base SHA not nullable --- gitrpc/commit.go | 27 ++ gitrpc/diff.go | 5 +- gitrpc/enum/hunk_headers.go | 20 + gitrpc/interface.go | 1 + gitrpc/internal/gitea/commit.go | 90 +++-- gitrpc/internal/parser/diff_headers.go | 40 +- gitrpc/internal/parser/diff_headers_test.go | 33 +- gitrpc/internal/service/commit.go | 16 + gitrpc/internal/service/diff.go | 4 +- gitrpc/internal/service/interface.go | 2 + gitrpc/internal/service/mapping.go | 1 + gitrpc/internal/types/types.go | 1 + gitrpc/mapping.go | 5 +- gitrpc/proto/diff.proto | 1 + gitrpc/proto/repo.proto | 13 +- gitrpc/rpc/diff.pb.go | 236 ++++++------ gitrpc/rpc/http.pb.go | 1 + gitrpc/rpc/operations.pb.go | 2 + gitrpc/rpc/repo.pb.go | 363 +++++++++++++----- gitrpc/rpc/repo_grpc.pb.go | 36 ++ gitrpc/rpc/shared.pb.go | 1 + .../api/controller/pullreq/comment_create.go | 2 +- internal/api/controller/pullreq/merge.go | 2 +- internal/api/controller/pullreq/pr_commits.go | 10 +- internal/api/controller/pullreq/pr_create.go | 17 +- internal/api/controller/pullreq/pr_diff.go | 10 +- internal/api/controller/pullreq/pr_find.go | 10 +- internal/events/pullreq/events_branch.go | 8 +- internal/services/codecomments/migrator.go | 13 +- internal/services/pullreq/handlers_branch.go | 37 +- .../pullreq/handlers_code_comments.go | 57 +-- .../services/pullreq/handlers_mergeable.go | 18 +- internal/store/database/code_comment.go | 4 + ...r_pullreq_merge_base_not_nullable.down.sql | 4 + ...ter_pullreq_merge_base_not_nullable.up.sql | 4 + ...r_pullreq_merge_base_not_nullable.down.sql | 4 + ...ter_pullreq_merge_base_not_nullable.up.sql | 4 + internal/store/database/pullreq.go | 6 +- types/pullreq.go | 2 +- 39 files changed, 768 insertions(+), 342 deletions(-) create mode 100644 gitrpc/enum/hunk_headers.go create mode 100644 internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.down.sql create mode 100644 internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.up.sql create mode 100644 internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.down.sql create mode 100644 internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.up.sql diff --git a/gitrpc/commit.go b/gitrpc/commit.go index 97cd77abb..8010f505c 100644 --- a/gitrpc/commit.go +++ b/gitrpc/commit.go @@ -197,3 +197,30 @@ func (c *Client) GetCommitDivergences(ctx context.Context, return output, nil } + +type MergeBaseParams struct { + ReadParams + Ref1 string + Ref2 string +} + +type MergeBaseOutput struct { + MergeBaseSHA string +} + +func (c *Client) MergeBase(ctx context.Context, + params MergeBaseParams, +) (MergeBaseOutput, error) { + result, err := c.repoService.MergeBase(ctx, &rpc.MergeBaseRequest{ + Base: mapToRPCReadRequest(params.ReadParams), + Ref1: params.Ref1, + Ref2: params.Ref2, + }) + if err != nil { + return MergeBaseOutput{}, fmt.Errorf("failed to get merge base commit: %w", err) + } + + return MergeBaseOutput{ + MergeBaseSHA: result.MergeBaseSha, + }, nil +} diff --git a/gitrpc/diff.go b/gitrpc/diff.go index 1805519d0..f88cdac77 100644 --- a/gitrpc/diff.go +++ b/gitrpc/diff.go @@ -162,8 +162,9 @@ type GetDiffHunkHeadersParams struct { } type DiffFileHeader struct { - OldName string - NewName string + OldName string + NewName string + Extensions map[string]string } type HunkHeader struct { diff --git a/gitrpc/enum/hunk_headers.go b/gitrpc/enum/hunk_headers.go new file mode 100644 index 000000000..40bd99ef8 --- /dev/null +++ b/gitrpc/enum/hunk_headers.go @@ -0,0 +1,20 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + +package enum + +// Diff file header extensions. From: https://git-scm.com/docs/git-diff#generate_patch_text_with_p +const ( + DiffExtHeaderOldMode = "old mode" // old mode + DiffExtHeaderNewMode = "new mode" // new mode + DiffExtHeaderDeletedFileMode = "deleted file mode" // deleted file mode + DiffExtHeaderNewFileMode = "new file mode" // new file mode + DiffExtHeaderCopyFrom = "copy from" // copy from + DiffExtHeaderCopyTo = "copy to" // copy to + DiffExtHeaderRenameFrom = "rename from" // rename from + DiffExtHeaderRenameTo = "rename to" // rename to + DiffExtHeaderSimilarity = "similarity index" // similarity index + DiffExtHeaderDissimilarity = "dissimilarity index" // dissimilarity index + DiffExtHeaderIndex = "index" // index .. +) diff --git a/gitrpc/interface.go b/gitrpc/interface.go index 608b31d8d..e0f995716 100644 --- a/gitrpc/interface.go +++ b/gitrpc/interface.go @@ -36,6 +36,7 @@ type Interface interface { ListCommitTags(ctx context.Context, params *ListCommitTagsParams) (*ListCommitTagsOutput, error) GetCommitDivergences(ctx context.Context, params *GetCommitDivergencesParams) (*GetCommitDivergencesOutput, error) CommitFiles(ctx context.Context, params *CommitFilesParams) (CommitFilesResponse, error) + MergeBase(ctx context.Context, params MergeBaseParams) (MergeBaseOutput, error) /* * Git Cli Service diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index 4149cd6ca..4b620c1d1 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -41,7 +41,7 @@ func (g Adapter) GetLatestCommit(ctx context.Context, repoPath string, return mapGiteaCommit(giteaCommit) } -// giteaGetCommitByPath is a copy of gitea code - required as we want latest commit per specific branch. +// giteaGetCommitByPath returns the latest commit per specific branch. func giteaGetCommitByPath(giteaRepo *gitea.Repository, ref string, treePath string) (*gitea.Commit, error) { if treePath == "" { treePath = "." @@ -54,7 +54,9 @@ func giteaGetCommitByPath(giteaRepo *gitea.Repository, ref string, treePath stri return nil, fmt.Errorf("failed to trigger log command: %w", runErr) } - giteaCommits, err := giteaParsePrettyFormatLogToList(giteaRepo, stdout) + lines := parseLinesToSlice(stdout) + + giteaCommits, err := getGiteaCommits(giteaRepo, lines) if err != nil { return nil, err } @@ -62,19 +64,16 @@ func giteaGetCommitByPath(giteaRepo *gitea.Repository, ref string, treePath stri return giteaCommits[0], nil } -// giteaParsePrettyFormatLogToList is an exact copy of gitea code. -func giteaParsePrettyFormatLogToList(giteaRepo *gitea.Repository, logs []byte) ([]*gitea.Commit, error) { +func getGiteaCommits(giteaRepo *gitea.Repository, commitIDs []string) ([]*gitea.Commit, error) { var giteaCommits []*gitea.Commit - if len(logs) == 0 { + if len(commitIDs) == 0 { return giteaCommits, nil } - parts := bytes.Split(logs, []byte{'\n'}) - - for _, commitID := range parts { - commit, err := giteaRepo.GetCommit(string(commitID)) + for _, commitID := range commitIDs { + commit, err := giteaRepo.GetCommit(commitID) if err != nil { - return nil, fmt.Errorf("failed to get commit '%s': %w", string(commitID), err) + return nil, fmt.Errorf("failed to get commit '%s': %w", commitID, err) } giteaCommits = append(giteaCommits, commit) } @@ -82,17 +81,10 @@ func giteaParsePrettyFormatLogToList(giteaRepo *gitea.Repository, logs []byte) ( return giteaCommits, nil } -// ListCommits lists the commits reachable from ref. -// Note: ref & afterRef can be Branch / Tag / CommitSHA. -// Note: commits returned are [ref->...->afterRef). -func (g Adapter) ListCommits(ctx context.Context, repoPath string, - ref string, afterRef string, page int, limit int) ([]types.Commit, error) { - giteaRepo, err := gitea.OpenRepository(ctx, repoPath) - if err != nil { - return nil, err - } - defer giteaRepo.Close() - +func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, + ref string, afterRef string, + page int, limit int, +) ([]string, error) { args := []string{"rev-list"} // add pagination if requested @@ -120,7 +112,46 @@ func (g Adapter) ListCommits(ctx context.Context, repoPath string, return nil, processGiteaErrorf(runErr, "failed to trigger rev-list command") } - giteaCommits, err := giteaParsePrettyFormatLogToList(giteaRepo, bytes.TrimSpace(stdout)) + return parseLinesToSlice(stdout), nil +} + +// ListCommitSHAs lists the commits reachable from ref. +// Note: ref & afterRef can be Branch / Tag / CommitSHA. +// Note: commits returned are [ref->...->afterRef). +func (g Adapter) ListCommitSHAs(ctx context.Context, + repoPath string, + ref string, afterRef string, + page int, limit int, +) ([]string, error) { + giteaRepo, err := gitea.OpenRepository(ctx, repoPath) + if err != nil { + return nil, err + } + defer giteaRepo.Close() + + return g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit) +} + +// ListCommits lists the commits reachable from ref. +// Note: ref & afterRef can be Branch / Tag / CommitSHA. +// Note: commits returned are [ref->...->afterRef). +func (g Adapter) ListCommits(ctx context.Context, + repoPath string, + ref string, afterRef string, + page int, limit int, +) ([]types.Commit, error) { + giteaRepo, err := gitea.OpenRepository(ctx, repoPath) + if err != nil { + return nil, err + } + defer giteaRepo.Close() + + commitSHAs, err := g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit) + if err != nil { + return nil, err + } + + giteaCommits, err := getGiteaCommits(giteaRepo, commitSHAs) if err != nil { return nil, err } @@ -264,3 +295,18 @@ func (g Adapter) getCommitDivergence(ctx context.Context, repoPath string, Behind: int32(right), }, nil } + +func parseLinesToSlice(output []byte) []string { + if len(output) == 0 { + return nil + } + + lines := bytes.Split(bytes.TrimSpace(output), []byte{'\n'}) + + slice := make([]string, len(lines)) + for i, line := range lines { + slice[i] = string(line) + } + + return slice +} diff --git a/gitrpc/internal/parser/diff_headers.go b/gitrpc/internal/parser/diff_headers.go index 41e29508a..8e3f9c193 100644 --- a/gitrpc/internal/parser/diff_headers.go +++ b/gitrpc/internal/parser/diff_headers.go @@ -9,6 +9,7 @@ import ( "io" "regexp" + "github.com/harness/gitness/gitrpc/enum" "github.com/harness/gitness/gitrpc/internal/types" ) @@ -23,9 +24,34 @@ func ParseDiffFileHeader(line string) (types.DiffFileHeader, bool) { return types.DiffFileHeader{ OldFileName: groups[1], NewFileName: groups[2], + Extensions: map[string]string{}, }, true } +var regExpDiffExtHeader = regexp.MustCompile( + "^(" + + enum.DiffExtHeaderOldMode + "|" + + enum.DiffExtHeaderNewMode + "|" + + enum.DiffExtHeaderDeletedFileMode + "|" + + enum.DiffExtHeaderNewFileMode + "|" + + enum.DiffExtHeaderCopyFrom + "|" + + enum.DiffExtHeaderCopyTo + "|" + + enum.DiffExtHeaderRenameFrom + "|" + + enum.DiffExtHeaderRenameTo + "|" + + enum.DiffExtHeaderSimilarity + "|" + + enum.DiffExtHeaderDissimilarity + "|" + + enum.DiffExtHeaderIndex + + ") (.+)$") + +func ParseDiffFileExtendedHeader(line string) (string, string) { + groups := regExpDiffExtHeader.FindStringSubmatch(line) + if groups == nil { + return "", "" + } + + return groups[1], groups[2] +} + // GetHunkHeaders parses git diff output and returns all diff headers for all files. // See for documentation: https://git-scm.com/docs/git-diff#generate_patch_text_with_p func GetHunkHeaders(r io.Reader) ([]*types.DiffFileHunkHeaders, error) { @@ -49,14 +75,20 @@ func GetHunkHeaders(r io.Reader) ([]*types.DiffFileHunkHeaders, error) { continue } + if currentFile == nil { + // should not happen: we reached the hunk header without first finding the file header. + return nil, types.ErrHunkNotFound + } + if h, ok := ParseDiffHunkHeader(line); ok { - if currentFile == nil { - // should not happen: we reached the hunk header without first finding the file header. - return nil, types.ErrHunkNotFound - } currentFile.HunksHeaders = append(currentFile.HunksHeaders, h) continue } + + if headerKey, headerValue := ParseDiffFileExtendedHeader(line); headerKey != "" { + currentFile.FileHeader.Extensions[headerKey] = headerValue + continue + } } if err := scanner.Err(); err != nil { diff --git a/gitrpc/internal/parser/diff_headers_test.go b/gitrpc/internal/parser/diff_headers_test.go index 7caf57d21..92be3e0df 100644 --- a/gitrpc/internal/parser/diff_headers_test.go +++ b/gitrpc/internal/parser/diff_headers_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/harness/gitness/gitrpc/enum" "github.com/harness/gitness/gitrpc/internal/types" "github.com/google/go-cmp/cmp" @@ -20,9 +21,9 @@ index 0000000..fb0c863 --- /dev/null +++ b/new_file.txt @@ -0,0 +1,3 @@ -This is a new file -created for this -unit test. ++This is a new file ++created for this ++unit test. diff --git a/old_file_name.txt b/changed_file.txt index f043b93..e9449b5 100644 --- a/changed_file.txt @@ -56,18 +57,38 @@ index f043b93..0000000 want := []*types.DiffFileHunkHeaders{ { - FileHeader: types.DiffFileHeader{OldFileName: "new_file.txt", NewFileName: "new_file.txt"}, + FileHeader: types.DiffFileHeader{ + OldFileName: "new_file.txt", + NewFileName: "new_file.txt", + Extensions: map[string]string{ + enum.DiffExtHeaderNewFileMode: "100644", + enum.DiffExtHeaderIndex: "0000000..fb0c863", + }, + }, HunksHeaders: []types.HunkHeader{{OldLine: 0, OldSpan: 0, NewLine: 1, NewSpan: 3}}, }, { - FileHeader: types.DiffFileHeader{OldFileName: "old_file_name.txt", NewFileName: "changed_file.txt"}, + FileHeader: types.DiffFileHeader{ + OldFileName: "old_file_name.txt", + NewFileName: "changed_file.txt", + Extensions: map[string]string{ + enum.DiffExtHeaderIndex: "f043b93..e9449b5 100644", + }, + }, HunksHeaders: []types.HunkHeader{ {OldLine: 7, OldSpan: 3, NewLine: 7, NewSpan: 4}, {OldLine: 27, OldSpan: 2, NewLine: 28, NewSpan: 3}, }, }, { - FileHeader: types.DiffFileHeader{OldFileName: "deleted_file.txt", NewFileName: "deleted_file.txt"}, + FileHeader: types.DiffFileHeader{ + OldFileName: "deleted_file.txt", + NewFileName: "deleted_file.txt", + Extensions: map[string]string{ + enum.DiffExtHeaderDeletedFileMode: "100644", + enum.DiffExtHeaderIndex: "f043b93..0000000", + }, + }, HunksHeaders: []types.HunkHeader{{OldLine: 1, OldSpan: 3, NewLine: 0, NewSpan: 0}}, }, } diff --git a/gitrpc/internal/service/commit.go b/gitrpc/internal/service/commit.go index d735e63fe..2aa03ac22 100644 --- a/gitrpc/internal/service/commit.go +++ b/gitrpc/internal/service/commit.go @@ -134,3 +134,19 @@ func (s RepositoryService) GetCommitDivergences(ctx context.Context, return response, nil } + +func (s RepositoryService) MergeBase(ctx context.Context, + r *rpc.MergeBaseRequest, +) (*rpc.MergeBaseResponse, error) { + base := r.GetBase() + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) + + mergeBase, _, err := s.adapter.GetMergeBase(ctx, repoPath, "", r.Ref1, r.Ref2) + if err != nil { + return nil, processGitErrorf(err, "failed to find merge base") + } + + return &rpc.MergeBaseResponse{ + MergeBaseSha: mergeBase, + }, nil +} diff --git a/gitrpc/internal/service/diff.go b/gitrpc/internal/service/diff.go index a03a8039c..d175b339a 100644 --- a/gitrpc/internal/service/diff.go +++ b/gitrpc/internal/service/diff.go @@ -124,7 +124,7 @@ func (s DiffService) DiffCut( return nil, processGitErrorf(err, "failed to find merge base") } - sourceCommits, err := s.adapter.ListCommits(ctx, repoPath, r.SourceBranch, r.TargetBranch, 0, 1) + sourceCommits, err := s.adapter.ListCommitSHAs(ctx, repoPath, r.SourceBranch, r.TargetBranch, 0, 1) if err != nil || len(sourceCommits) == 0 { return nil, processGitErrorf(err, "failed to get list of source branch commits") } @@ -146,6 +146,6 @@ func (s DiffService) DiffCut( HunkHeader: mapHunkHeader(hunk.HunkHeader), Lines: hunk.Lines, MergeBaseSha: mergeBase, - LatestSourceSha: sourceCommits[0].SHA, + LatestSourceSha: sourceCommits[0], }, nil } diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index 15caacee6..b47a13195 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -33,6 +33,8 @@ type GitAdapter interface { GetCommits(ctx context.Context, repoPath string, refs []string) ([]types.Commit, error) ListCommits(ctx context.Context, repoPath string, ref string, afterRef string, page int, limit int) ([]types.Commit, error) + ListCommitSHAs(ctx context.Context, repoPath string, + ref string, afterRef string, page int, limit int) ([]string, error) GetLatestCommit(ctx context.Context, repoPath string, ref string, treePath string) (*types.Commit, error) GetFullCommitID(ctx context.Context, repoPath, shortID string) (string, error) GetAnnotatedTag(ctx context.Context, repoPath string, sha string) (*types.Tag, error) diff --git a/gitrpc/internal/service/mapping.go b/gitrpc/internal/service/mapping.go index f2423337f..91ff42f53 100644 --- a/gitrpc/internal/service/mapping.go +++ b/gitrpc/internal/service/mapping.go @@ -122,6 +122,7 @@ func mapDiffFileHeader(h types.DiffFileHeader) *rpc.DiffFileHeader { return &rpc.DiffFileHeader{ OldFileName: h.OldFileName, NewFileName: h.NewFileName, + Extensions: h.Extensions, } } diff --git a/gitrpc/internal/types/types.go b/gitrpc/internal/types/types.go index 1eeccea52..8bd45e8d2 100644 --- a/gitrpc/internal/types/types.go +++ b/gitrpc/internal/types/types.go @@ -260,6 +260,7 @@ type DiffShortStat struct { type DiffFileHeader struct { OldFileName string NewFileName string + Extensions map[string]string } type DiffFileHunkHeaders struct { diff --git a/gitrpc/mapping.go b/gitrpc/mapping.go index 331026c65..de03677ef 100644 --- a/gitrpc/mapping.go +++ b/gitrpc/mapping.go @@ -238,7 +238,8 @@ func mapHunkHeader(h *rpc.HunkHeader) HunkHeader { func mapDiffFileHeader(h *rpc.DiffFileHeader) DiffFileHeader { return DiffFileHeader{ - OldName: h.OldFileName, - NewName: h.NewFileName, + OldName: h.OldFileName, + NewName: h.NewFileName, + Extensions: h.Extensions, } } diff --git a/gitrpc/proto/diff.proto b/gitrpc/proto/diff.proto index 5e2e7d3bb..74f1fd3a3 100644 --- a/gitrpc/proto/diff.proto +++ b/gitrpc/proto/diff.proto @@ -46,6 +46,7 @@ message HunkHeader { message DiffFileHeader { string old_file_name = 1; string new_file_name = 2; + map extensions = 3; } message DiffFileHunkHeaders { diff --git a/gitrpc/proto/repo.proto b/gitrpc/proto/repo.proto index e662762f6..ffc61f8c9 100644 --- a/gitrpc/proto/repo.proto +++ b/gitrpc/proto/repo.proto @@ -16,6 +16,7 @@ service RepositoryService { rpc GetCommit(GetCommitRequest) returns (GetCommitResponse); rpc GetCommitDivergences(GetCommitDivergencesRequest) returns (GetCommitDivergencesResponse); rpc DeleteRepository(DeleteRepositoryRequest) returns (DeleteRepositoryResponse); + rpc MergeBase(MergeBaseRequest) returns (MergeBaseResponse); } message CreateRepositoryRequest { @@ -163,4 +164,14 @@ message DeleteRepositoryRequest { } message DeleteRepositoryResponse { -} \ No newline at end of file +} + +message MergeBaseRequest { + ReadRequest base = 1; + string ref1 = 2; + string ref2 = 3; +} + +message MergeBaseResponse { + string merge_base_sha = 1; +} diff --git a/gitrpc/rpc/diff.pb.go b/gitrpc/rpc/diff.pb.go index 82bb7952a..e767f49d3 100644 --- a/gitrpc/rpc/diff.pb.go +++ b/gitrpc/rpc/diff.pb.go @@ -289,8 +289,9 @@ type DiffFileHeader struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OldFileName string `protobuf:"bytes,1,opt,name=old_file_name,json=oldFileName,proto3" json:"old_file_name,omitempty"` - NewFileName string `protobuf:"bytes,2,opt,name=new_file_name,json=newFileName,proto3" json:"new_file_name,omitempty"` + OldFileName string `protobuf:"bytes,1,opt,name=old_file_name,json=oldFileName,proto3" json:"old_file_name,omitempty"` + NewFileName string `protobuf:"bytes,2,opt,name=new_file_name,json=newFileName,proto3" json:"new_file_name,omitempty"` + Extensions map[string]string `protobuf:"bytes,3,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *DiffFileHeader) Reset() { @@ -339,6 +340,13 @@ func (x *DiffFileHeader) GetNewFileName() string { return "" } +func (x *DiffFileHeader) GetExtensions() map[string]string { + if x != nil { + return x.Extensions + } + return nil +} + type DiffFileHunkHeaders struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -725,90 +733,98 @@ var file_diff_proto_rawDesc = []byte{ 0x01, 0x28, 0x05, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x58, 0x0a, 0x0e, 0x44, - 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x22, 0x0a, - 0x0d, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x6c, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x65, 0x77, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x77, 0x46, 0x69, 0x6c, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x7f, 0x0a, 0x13, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, - 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x34, 0x0a, 0x0b, - 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x12, 0x32, 0x0a, 0x0c, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, - 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0b, 0x68, 0x75, 0x6e, 0x6b, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0x99, 0x01, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x44, 0x69, - 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, - 0x68, 0x61, 0x22, 0x4c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, - 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x2e, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x75, - 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, - 0x22, 0xee, 0x02, 0x0a, 0x0e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x70, - 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, - 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x24, - 0x0a, 0x0e, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x6e, 0x65, 0x77, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, - 0x74, 0x4e, 0x65, 0x77, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x45, 0x6e, 0x64, 0x12, - 0x20, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x77, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x45, 0x6e, 0x64, 0x4e, 0x65, - 0x77, 0x22, 0xab, 0x01, 0x0a, 0x0f, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x68, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x68, 0x75, 0x6e, - 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x12, 0x24, 0x0a, - 0x0e, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, - 0x53, 0x68, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, - 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x68, 0x61, 0x32, - 0x96, 0x02, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x35, 0x0a, 0x07, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x3f, 0x0a, 0x0d, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, - 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, - 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x69, - 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x1e, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x36, 0x0a, 0x07, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x12, 0x13, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, - 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, - 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xdc, 0x01, 0x0a, 0x0e, + 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x22, + 0x0a, 0x0d, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x6c, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x65, 0x77, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x77, 0x46, 0x69, + 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, + 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x7f, 0x0a, 0x13, 0x44, 0x69, + 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x12, 0x34, 0x0a, 0x0b, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, + 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x66, 0x69, 0x6c, + 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x0c, 0x68, 0x75, 0x6e, 0x6b, 0x5f, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0b, + 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0x99, 0x01, 0x0a, 0x19, + 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, + 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, + 0x2a, 0x0a, 0x11, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x5f, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x22, 0x4c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x44, 0x69, + 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, + 0x69, 0x6c, 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x05, + 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0xee, 0x02, 0x0a, 0x0e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x2a, + 0x0a, 0x11, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, + 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, + 0x2a, 0x0a, 0x11, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, + 0x61, 0x72, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x5f, 0x6e, 0x65, 0x77, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6c, 0x69, 0x6e, + 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x65, 0x77, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, + 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x69, 0x6e, + 0x65, 0x45, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64, + 0x5f, 0x6e, 0x65, 0x77, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65, + 0x45, 0x6e, 0x64, 0x4e, 0x65, 0x77, 0x22, 0xab, 0x01, 0x0a, 0x0f, 0x44, 0x69, 0x66, 0x66, 0x43, + 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x68, 0x75, + 0x6e, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x52, 0x0a, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, + 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, + 0x5f, 0x73, 0x68, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, + 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x53, 0x68, 0x61, 0x32, 0x96, 0x02, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x35, 0x0a, 0x07, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x12, + 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x3f, 0x0a, 0x0d, 0x44, + 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x12, 0x10, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x12, + 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x73, 0x12, 0x1e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, + 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, + 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, + 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, + 0x43, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x27, 0x5a, + 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, + 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -823,7 +839,7 @@ func file_diff_proto_rawDescGZIP() []byte { return file_diff_proto_rawDescData } -var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_diff_proto_goTypes = []interface{}{ (*DiffRequest)(nil), // 0: rpc.DiffRequest (*RawDiffResponse)(nil), // 1: rpc.RawDiffResponse @@ -835,29 +851,31 @@ var file_diff_proto_goTypes = []interface{}{ (*GetDiffHunkHeadersResponse)(nil), // 7: rpc.GetDiffHunkHeadersResponse (*DiffCutRequest)(nil), // 8: rpc.DiffCutRequest (*DiffCutResponse)(nil), // 9: rpc.DiffCutResponse - (*ReadRequest)(nil), // 10: rpc.ReadRequest + nil, // 10: rpc.DiffFileHeader.ExtensionsEntry + (*ReadRequest)(nil), // 11: rpc.ReadRequest } var file_diff_proto_depIdxs = []int32{ - 10, // 0: rpc.DiffRequest.base:type_name -> rpc.ReadRequest - 4, // 1: rpc.DiffFileHunkHeaders.file_header:type_name -> rpc.DiffFileHeader - 3, // 2: rpc.DiffFileHunkHeaders.hunk_headers:type_name -> rpc.HunkHeader - 10, // 3: rpc.GetDiffHunkHeadersRequest.base:type_name -> rpc.ReadRequest - 5, // 4: rpc.GetDiffHunkHeadersResponse.files:type_name -> rpc.DiffFileHunkHeaders - 10, // 5: rpc.DiffCutRequest.base:type_name -> rpc.ReadRequest - 3, // 6: rpc.DiffCutResponse.hunk_header:type_name -> rpc.HunkHeader - 0, // 7: rpc.DiffService.RawDiff:input_type -> rpc.DiffRequest - 0, // 8: rpc.DiffService.DiffShortStat:input_type -> rpc.DiffRequest - 6, // 9: rpc.DiffService.GetDiffHunkHeaders:input_type -> rpc.GetDiffHunkHeadersRequest - 8, // 10: rpc.DiffService.DiffCut:input_type -> rpc.DiffCutRequest - 1, // 11: rpc.DiffService.RawDiff:output_type -> rpc.RawDiffResponse - 2, // 12: rpc.DiffService.DiffShortStat:output_type -> rpc.DiffShortStatResponse - 7, // 13: rpc.DiffService.GetDiffHunkHeaders:output_type -> rpc.GetDiffHunkHeadersResponse - 9, // 14: rpc.DiffService.DiffCut:output_type -> rpc.DiffCutResponse - 11, // [11:15] is the sub-list for method output_type - 7, // [7:11] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 11, // 0: rpc.DiffRequest.base:type_name -> rpc.ReadRequest + 10, // 1: rpc.DiffFileHeader.extensions:type_name -> rpc.DiffFileHeader.ExtensionsEntry + 4, // 2: rpc.DiffFileHunkHeaders.file_header:type_name -> rpc.DiffFileHeader + 3, // 3: rpc.DiffFileHunkHeaders.hunk_headers:type_name -> rpc.HunkHeader + 11, // 4: rpc.GetDiffHunkHeadersRequest.base:type_name -> rpc.ReadRequest + 5, // 5: rpc.GetDiffHunkHeadersResponse.files:type_name -> rpc.DiffFileHunkHeaders + 11, // 6: rpc.DiffCutRequest.base:type_name -> rpc.ReadRequest + 3, // 7: rpc.DiffCutResponse.hunk_header:type_name -> rpc.HunkHeader + 0, // 8: rpc.DiffService.RawDiff:input_type -> rpc.DiffRequest + 0, // 9: rpc.DiffService.DiffShortStat:input_type -> rpc.DiffRequest + 6, // 10: rpc.DiffService.GetDiffHunkHeaders:input_type -> rpc.GetDiffHunkHeadersRequest + 8, // 11: rpc.DiffService.DiffCut:input_type -> rpc.DiffCutRequest + 1, // 12: rpc.DiffService.RawDiff:output_type -> rpc.RawDiffResponse + 2, // 13: rpc.DiffService.DiffShortStat:output_type -> rpc.DiffShortStatResponse + 7, // 14: rpc.DiffService.GetDiffHunkHeaders:output_type -> rpc.GetDiffHunkHeadersResponse + 9, // 15: rpc.DiffService.DiffCut:output_type -> rpc.DiffCutResponse + 12, // [12:16] is the sub-list for method output_type + 8, // [8:12] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_diff_proto_init() } @@ -994,7 +1012,7 @@ func file_diff_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_diff_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 1, }, diff --git a/gitrpc/rpc/http.pb.go b/gitrpc/rpc/http.pb.go index 9afe821bf..7006fe359 100644 --- a/gitrpc/rpc/http.pb.go +++ b/gitrpc/rpc/http.pb.go @@ -151,6 +151,7 @@ type ServicePackRequest struct { // Depending on the service the matching base type has to be passed // // Types that are assignable to Base: + // // *ServicePackRequest_ReadBase // *ServicePackRequest_WriteBase Base isServicePackRequest_Base `protobuf_oneof:"base"` diff --git a/gitrpc/rpc/operations.pb.go b/gitrpc/rpc/operations.pb.go index 517aeef89..a06443219 100644 --- a/gitrpc/rpc/operations.pb.go +++ b/gitrpc/rpc/operations.pb.go @@ -247,6 +247,7 @@ type CommitFilesAction struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Payload: + // // *CommitFilesAction_Header // *CommitFilesAction_Content Payload isCommitFilesAction_Payload `protobuf_oneof:"payload"` @@ -330,6 +331,7 @@ type CommitFilesRequest struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Payload: + // // *CommitFilesRequest_Header // *CommitFilesRequest_Action Payload isCommitFilesRequest_Payload `protobuf_oneof:"payload"` diff --git a/gitrpc/rpc/repo.pb.go b/gitrpc/rpc/repo.pb.go index ec7642836..45d310831 100644 --- a/gitrpc/rpc/repo.pb.go +++ b/gitrpc/rpc/repo.pb.go @@ -130,6 +130,7 @@ type CreateRepositoryRequest struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Data: + // // *CreateRepositoryRequest_Header // *CreateRepositoryRequest_File Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"` @@ -949,6 +950,7 @@ type GetBlobResponse struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Data: + // // *GetBlobResponse_Header // *GetBlobResponse_Content Data isGetBlobResponse_Data `protobuf_oneof:"data"` @@ -1556,6 +1558,116 @@ func (*DeleteRepositoryResponse) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{23} } +type MergeBaseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + Ref1 string `protobuf:"bytes,2,opt,name=ref1,proto3" json:"ref1,omitempty"` + Ref2 string `protobuf:"bytes,3,opt,name=ref2,proto3" json:"ref2,omitempty"` +} + +func (x *MergeBaseRequest) Reset() { + *x = MergeBaseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MergeBaseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MergeBaseRequest) ProtoMessage() {} + +func (x *MergeBaseRequest) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[24] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MergeBaseRequest.ProtoReflect.Descriptor instead. +func (*MergeBaseRequest) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{24} +} + +func (x *MergeBaseRequest) GetBase() *ReadRequest { + if x != nil { + return x.Base + } + return nil +} + +func (x *MergeBaseRequest) GetRef1() string { + if x != nil { + return x.Ref1 + } + return "" +} + +func (x *MergeBaseRequest) GetRef2() string { + if x != nil { + return x.Ref2 + } + return "" +} + +type MergeBaseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MergeBaseSha string `protobuf:"bytes,1,opt,name=merge_base_sha,json=mergeBaseSha,proto3" json:"merge_base_sha,omitempty"` +} + +func (x *MergeBaseResponse) Reset() { + *x = MergeBaseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MergeBaseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MergeBaseResponse) ProtoMessage() {} + +func (x *MergeBaseResponse) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[25] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MergeBaseResponse.ProtoReflect.Descriptor instead. +func (*MergeBaseResponse) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{25} +} + +func (x *MergeBaseResponse) GetMergeBaseSha() string { + if x != nil { + return x.MergeBaseSha + } + return "" +} + var File_repo_proto protoreflect.FileDescriptor var file_repo_proto_rawDesc = []byte{ @@ -1711,65 +1823,79 @@ var file_repo_proto_rawDesc = []byte{ 0x70, 0x63, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x22, 0x1a, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x2a, 0x52, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, - 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01, 0x12, 0x16, 0x0a, - 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x10, 0x02, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, - 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, - 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, - 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53, 0x79, 0x6d, 0x6c, - 0x69, 0x6e, 0x6b, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, - 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x45, 0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x54, - 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, - 0x03, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, - 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x32, 0x9d, 0x05, 0x0a, 0x11, 0x52, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x51, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x28, 0x01, 0x12, 0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, - 0x65, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, - 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x43, - 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x18, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, - 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x13, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, - 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0b, 0x4c, - 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, - 0x3a, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x15, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x14, 0x47, - 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, - 0x63, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, + 0x65, 0x22, 0x60, 0x0a, 0x10, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, + 0x65, 0x66, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x66, 0x31, 0x12, + 0x12, 0x0a, 0x04, 0x72, 0x65, 0x66, 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, + 0x65, 0x66, 0x32, 0x22, 0x39, 0x0a, 0x11, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x65, 0x72, 0x67, + 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61, 0x2a, 0x52, + 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, + 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x72, + 0x65, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x54, 0x79, 0x70, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, + 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x10, 0x02, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, + 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, + 0x6f, 0x64, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x72, 0x65, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53, 0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, + 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, + 0x64, 0x65, 0x45, 0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, + 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x03, 0x12, 0x16, + 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x32, 0xd9, 0x05, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x10, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, + 0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x17, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, + 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x43, 0x0a, 0x0c, 0x47, + 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x36, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x13, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x3a, 0x0a, 0x09, + 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, - 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, - 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, - 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, + 0x61, 0x73, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, + 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, + 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1785,7 +1911,7 @@ func file_repo_proto_rawDescGZIP() []byte { } var file_repo_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 24) +var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 26) var file_repo_proto_goTypes = []interface{}{ (TreeNodeType)(0), // 0: rpc.TreeNodeType (TreeNodeMode)(0), // 1: rpc.TreeNodeMode @@ -1813,61 +1939,66 @@ var file_repo_proto_goTypes = []interface{}{ (*CommitDivergence)(nil), // 23: rpc.CommitDivergence (*DeleteRepositoryRequest)(nil), // 24: rpc.DeleteRepositoryRequest (*DeleteRepositoryResponse)(nil), // 25: rpc.DeleteRepositoryResponse - (*FileUpload)(nil), // 26: rpc.FileUpload - (*WriteRequest)(nil), // 27: rpc.WriteRequest - (*Identity)(nil), // 28: rpc.Identity - (*ReadRequest)(nil), // 29: rpc.ReadRequest - (*Commit)(nil), // 30: rpc.Commit + (*MergeBaseRequest)(nil), // 26: rpc.MergeBaseRequest + (*MergeBaseResponse)(nil), // 27: rpc.MergeBaseResponse + (*FileUpload)(nil), // 28: rpc.FileUpload + (*WriteRequest)(nil), // 29: rpc.WriteRequest + (*Identity)(nil), // 30: rpc.Identity + (*ReadRequest)(nil), // 31: rpc.ReadRequest + (*Commit)(nil), // 32: rpc.Commit } var file_repo_proto_depIdxs = []int32{ 3, // 0: rpc.CreateRepositoryRequest.header:type_name -> rpc.CreateRepositoryRequestHeader - 26, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload - 27, // 2: rpc.CreateRepositoryRequestHeader.base:type_name -> rpc.WriteRequest - 28, // 3: rpc.CreateRepositoryRequestHeader.author:type_name -> rpc.Identity - 28, // 4: rpc.CreateRepositoryRequestHeader.committer:type_name -> rpc.Identity - 29, // 5: rpc.GetTreeNodeRequest.base:type_name -> rpc.ReadRequest + 28, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload + 29, // 2: rpc.CreateRepositoryRequestHeader.base:type_name -> rpc.WriteRequest + 30, // 3: rpc.CreateRepositoryRequestHeader.author:type_name -> rpc.Identity + 30, // 4: rpc.CreateRepositoryRequestHeader.committer:type_name -> rpc.Identity + 31, // 5: rpc.GetTreeNodeRequest.base:type_name -> rpc.ReadRequest 9, // 6: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode - 30, // 7: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit - 29, // 8: rpc.ListTreeNodesRequest.base:type_name -> rpc.ReadRequest + 32, // 7: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit + 31, // 8: rpc.ListTreeNodesRequest.base:type_name -> rpc.ReadRequest 9, // 9: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode - 30, // 10: rpc.ListTreeNodesResponse.commit:type_name -> rpc.Commit + 32, // 10: rpc.ListTreeNodesResponse.commit:type_name -> rpc.Commit 0, // 11: rpc.TreeNode.type:type_name -> rpc.TreeNodeType 1, // 12: rpc.TreeNode.mode:type_name -> rpc.TreeNodeMode - 29, // 13: rpc.GetCommitRequest.base:type_name -> rpc.ReadRequest - 30, // 14: rpc.GetCommitResponse.commit:type_name -> rpc.Commit - 29, // 15: rpc.ListCommitsRequest.base:type_name -> rpc.ReadRequest - 30, // 16: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit - 29, // 17: rpc.GetBlobRequest.base:type_name -> rpc.ReadRequest + 31, // 13: rpc.GetCommitRequest.base:type_name -> rpc.ReadRequest + 32, // 14: rpc.GetCommitResponse.commit:type_name -> rpc.Commit + 31, // 15: rpc.ListCommitsRequest.base:type_name -> rpc.ReadRequest + 32, // 16: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit + 31, // 17: rpc.GetBlobRequest.base:type_name -> rpc.ReadRequest 16, // 18: rpc.GetBlobResponse.header:type_name -> rpc.GetBlobResponseHeader - 29, // 19: rpc.GetSubmoduleRequest.base:type_name -> rpc.ReadRequest + 31, // 19: rpc.GetSubmoduleRequest.base:type_name -> rpc.ReadRequest 19, // 20: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule - 29, // 21: rpc.GetCommitDivergencesRequest.base:type_name -> rpc.ReadRequest + 31, // 21: rpc.GetCommitDivergencesRequest.base:type_name -> rpc.ReadRequest 21, // 22: rpc.GetCommitDivergencesRequest.requests:type_name -> rpc.CommitDivergenceRequest 23, // 23: rpc.GetCommitDivergencesResponse.divergences:type_name -> rpc.CommitDivergence - 27, // 24: rpc.DeleteRepositoryRequest.base:type_name -> rpc.WriteRequest - 2, // 25: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest - 5, // 26: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest - 7, // 27: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest - 17, // 28: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest - 14, // 29: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest - 12, // 30: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest - 10, // 31: rpc.RepositoryService.GetCommit:input_type -> rpc.GetCommitRequest - 20, // 32: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest - 24, // 33: rpc.RepositoryService.DeleteRepository:input_type -> rpc.DeleteRepositoryRequest - 4, // 34: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse - 6, // 35: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse - 8, // 36: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse - 18, // 37: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse - 15, // 38: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse - 13, // 39: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse - 11, // 40: rpc.RepositoryService.GetCommit:output_type -> rpc.GetCommitResponse - 22, // 41: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse - 25, // 42: rpc.RepositoryService.DeleteRepository:output_type -> rpc.DeleteRepositoryResponse - 34, // [34:43] is the sub-list for method output_type - 25, // [25:34] is the sub-list for method input_type - 25, // [25:25] is the sub-list for extension type_name - 25, // [25:25] is the sub-list for extension extendee - 0, // [0:25] is the sub-list for field type_name + 29, // 24: rpc.DeleteRepositoryRequest.base:type_name -> rpc.WriteRequest + 31, // 25: rpc.MergeBaseRequest.base:type_name -> rpc.ReadRequest + 2, // 26: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest + 5, // 27: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest + 7, // 28: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest + 17, // 29: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest + 14, // 30: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest + 12, // 31: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest + 10, // 32: rpc.RepositoryService.GetCommit:input_type -> rpc.GetCommitRequest + 20, // 33: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest + 24, // 34: rpc.RepositoryService.DeleteRepository:input_type -> rpc.DeleteRepositoryRequest + 26, // 35: rpc.RepositoryService.MergeBase:input_type -> rpc.MergeBaseRequest + 4, // 36: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse + 6, // 37: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse + 8, // 38: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse + 18, // 39: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse + 15, // 40: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse + 13, // 41: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse + 11, // 42: rpc.RepositoryService.GetCommit:output_type -> rpc.GetCommitResponse + 22, // 43: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse + 25, // 44: rpc.RepositoryService.DeleteRepository:output_type -> rpc.DeleteRepositoryResponse + 27, // 45: rpc.RepositoryService.MergeBase:output_type -> rpc.MergeBaseResponse + 36, // [36:46] is the sub-list for method output_type + 26, // [26:36] is the sub-list for method input_type + 26, // [26:26] is the sub-list for extension type_name + 26, // [26:26] is the sub-list for extension extendee + 0, // [0:26] is the sub-list for field type_name } func init() { file_repo_proto_init() } @@ -2165,6 +2296,30 @@ func file_repo_proto_init() { return nil } } + file_repo_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MergeBaseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_repo_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MergeBaseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_repo_proto_msgTypes[0].OneofWrappers = []interface{}{ (*CreateRepositoryRequest_Header)(nil), @@ -2180,7 +2335,7 @@ func file_repo_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_repo_proto_rawDesc, NumEnums: 2, - NumMessages: 24, + NumMessages: 26, NumExtensions: 0, NumServices: 1, }, diff --git a/gitrpc/rpc/repo_grpc.pb.go b/gitrpc/rpc/repo_grpc.pb.go index 50a97e214..8b75e9974 100644 --- a/gitrpc/rpc/repo_grpc.pb.go +++ b/gitrpc/rpc/repo_grpc.pb.go @@ -31,6 +31,7 @@ type RepositoryServiceClient interface { GetCommit(ctx context.Context, in *GetCommitRequest, opts ...grpc.CallOption) (*GetCommitResponse, error) GetCommitDivergences(ctx context.Context, in *GetCommitDivergencesRequest, opts ...grpc.CallOption) (*GetCommitDivergencesResponse, error) DeleteRepository(ctx context.Context, in *DeleteRepositoryRequest, opts ...grpc.CallOption) (*DeleteRepositoryResponse, error) + MergeBase(ctx context.Context, in *MergeBaseRequest, opts ...grpc.CallOption) (*MergeBaseResponse, error) } type repositoryServiceClient struct { @@ -216,6 +217,15 @@ func (c *repositoryServiceClient) DeleteRepository(ctx context.Context, in *Dele return out, nil } +func (c *repositoryServiceClient) MergeBase(ctx context.Context, in *MergeBaseRequest, opts ...grpc.CallOption) (*MergeBaseResponse, error) { + out := new(MergeBaseResponse) + err := c.cc.Invoke(ctx, "/rpc.RepositoryService/MergeBase", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // RepositoryServiceServer is the server API for RepositoryService service. // All implementations must embed UnimplementedRepositoryServiceServer // for forward compatibility @@ -229,6 +239,7 @@ type RepositoryServiceServer interface { GetCommit(context.Context, *GetCommitRequest) (*GetCommitResponse, error) GetCommitDivergences(context.Context, *GetCommitDivergencesRequest) (*GetCommitDivergencesResponse, error) DeleteRepository(context.Context, *DeleteRepositoryRequest) (*DeleteRepositoryResponse, error) + MergeBase(context.Context, *MergeBaseRequest) (*MergeBaseResponse, error) mustEmbedUnimplementedRepositoryServiceServer() } @@ -263,6 +274,9 @@ func (UnimplementedRepositoryServiceServer) GetCommitDivergences(context.Context func (UnimplementedRepositoryServiceServer) DeleteRepository(context.Context, *DeleteRepositoryRequest) (*DeleteRepositoryResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteRepository not implemented") } +func (UnimplementedRepositoryServiceServer) MergeBase(context.Context, *MergeBaseRequest) (*MergeBaseResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MergeBase not implemented") +} func (UnimplementedRepositoryServiceServer) mustEmbedUnimplementedRepositoryServiceServer() {} // UnsafeRepositoryServiceServer may be embedded to opt out of forward compatibility for this service. @@ -455,6 +469,24 @@ func _RepositoryService_DeleteRepository_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _RepositoryService_MergeBase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MergeBaseRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RepositoryServiceServer).MergeBase(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.RepositoryService/MergeBase", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RepositoryServiceServer).MergeBase(ctx, req.(*MergeBaseRequest)) + } + return interceptor(ctx, in, info, handler) +} + // RepositoryService_ServiceDesc is the grpc.ServiceDesc for RepositoryService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -482,6 +514,10 @@ var RepositoryService_ServiceDesc = grpc.ServiceDesc{ MethodName: "DeleteRepository", Handler: _RepositoryService_DeleteRepository_Handler, }, + { + MethodName: "MergeBase", + Handler: _RepositoryService_MergeBase_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/gitrpc/rpc/shared.pb.go b/gitrpc/rpc/shared.pb.go index 084d3dfb6..65817ec5b 100644 --- a/gitrpc/rpc/shared.pb.go +++ b/gitrpc/rpc/shared.pb.go @@ -298,6 +298,7 @@ type FileUpload struct { unknownFields protoimpl.UnknownFields // Types that are assignable to Data: + // // *FileUpload_Header // *FileUpload_Chunk Data isFileUpload_Data `protobuf_oneof:"data"` diff --git a/internal/api/controller/pullreq/comment_create.go b/internal/api/controller/pullreq/comment_create.go index 7dedf5b0d..8a7e95793 100644 --- a/internal/api/controller/pullreq/comment_create.go +++ b/internal/api/controller/pullreq/comment_create.go @@ -129,7 +129,7 @@ func (c *Controller) CommentCreate( // Migrate the comment if necessary... Note: we still need to return the code comment as is. needsNewLineMigrate := in.SourceCommitSHA != cut.LatestSourceSHA - needsOldLineMigrate := pr.MergeBaseSHA != nil && *pr.MergeBaseSHA != cut.MergeBaseSHA + needsOldLineMigrate := pr.MergeBaseSHA != cut.MergeBaseSHA if err == nil && (needsNewLineMigrate || needsOldLineMigrate) { comments := []*types.CodeComment{act.AsCodeComment()} diff --git a/internal/api/controller/pullreq/merge.go b/internal/api/controller/pullreq/merge.go index 52a24a839..73fb14190 100644 --- a/internal/api/controller/pullreq/merge.go +++ b/internal/api/controller/pullreq/merge.go @@ -133,7 +133,7 @@ func (c *Controller) Merge( // update all Merge specific information (might be empty if previous merge check failed) pr.MergeCheckStatus = enum.MergeCheckStatusMergeable pr.MergeTargetSHA = &mergeOutput.BaseSHA - pr.MergeBaseSHA = &mergeOutput.MergeBaseSHA + pr.MergeBaseSHA = mergeOutput.MergeBaseSHA pr.MergeSHA = &mergeOutput.MergeSHA pr.MergeConflicts = nil diff --git a/internal/api/controller/pullreq/pr_commits.go b/internal/api/controller/pullreq/pr_commits.go index 54e7adc58..e8d4b49df 100644 --- a/internal/api/controller/pullreq/pr_commits.go +++ b/internal/api/controller/pullreq/pr_commits.go @@ -33,14 +33,8 @@ func (c *Controller) Commits( return nil, fmt.Errorf("failed to get pull request by number: %w", err) } - gitRef := pr.SourceBranch - if pr.SourceSHA != "" { - gitRef = pr.SourceSHA - } - afterRef := pr.TargetBranch - if pr.MergeBaseSHA != nil { - afterRef = *pr.MergeBaseSHA - } + gitRef := pr.SourceSHA + afterRef := pr.MergeBaseSHA rpcOut, err := c.gitRPCClient.ListCommits(ctx, &gitrpc.ListCommitsParams{ ReadParams: gitrpc.CreateRPCReadParams(repo), diff --git a/internal/api/controller/pullreq/pr_create.go b/internal/api/controller/pullreq/pr_create.go index dcb8f81c9..7790cfcd4 100644 --- a/internal/api/controller/pullreq/pr_create.go +++ b/internal/api/controller/pullreq/pr_create.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/harness/gitness/gitrpc" "github.com/harness/gitness/internal/api/usererror" "github.com/harness/gitness/internal/auth" pullreqevents "github.com/harness/gitness/internal/events/pullreq" @@ -71,6 +72,17 @@ func (c *Controller) Create( return nil, err } + mergeBaseResult, err := c.gitRPCClient.MergeBase(ctx, gitrpc.MergeBaseParams{ + ReadParams: gitrpc.ReadParams{RepoUID: sourceRepo.GitUID}, + Ref1: in.SourceBranch, + Ref2: in.TargetBranch, + }) + if err != nil { + return nil, fmt.Errorf("failed to find merge base: %w", err) + } + + mergeBaseSHA := mergeBaseResult.MergeBaseSHA + targetRepo, err = c.repoStore.UpdateOptLock(ctx, targetRepo, func(repo *types.Repository) error { repo.PullReqSeq++ return nil @@ -79,7 +91,7 @@ func (c *Controller) Create( return nil, fmt.Errorf("failed to aquire PullReqSeq number: %w", err) } - pr := newPullReq(session, targetRepo.PullReqSeq, sourceRepo, targetRepo, in, sourceSHA) + pr := newPullReq(session, targetRepo.PullReqSeq, sourceRepo, targetRepo, in, sourceSHA, mergeBaseSHA) err = c.pullreqStore.Create(ctx, pr) if err != nil { @@ -103,7 +115,7 @@ func newPullReq( sourceRepo *types.Repository, targetRepo *types.Repository, in *CreateInput, - sourceSHA string, + sourceSHA, mergeBaseSHA string, ) *types.PullReq { now := time.Now().UnixMilli() return &types.PullReq{ @@ -128,6 +140,7 @@ func newPullReq( Merged: nil, MergeCheckStatus: enum.MergeCheckStatusUnchecked, MergeMethod: nil, + MergeBaseSHA: mergeBaseSHA, Author: *session.Principal.ToPrincipalInfo(), Merger: nil, } diff --git a/internal/api/controller/pullreq/pr_diff.go b/internal/api/controller/pullreq/pr_diff.go index d9ee00d5a..1194eff0c 100644 --- a/internal/api/controller/pullreq/pr_diff.go +++ b/internal/api/controller/pullreq/pr_diff.go @@ -32,14 +32,8 @@ func (c *Controller) RawDiff( return fmt.Errorf("failed to get pull request by number: %w", err) } - headRef := pr.SourceBranch - if pr.SourceSHA != "" { - headRef = pr.SourceSHA - } - baseRef := pr.TargetBranch - if pr.MergeBaseSHA != nil { - baseRef = *pr.MergeBaseSHA - } + headRef := pr.SourceSHA + baseRef := pr.MergeBaseSHA return c.gitRPCClient.RawDiff(ctx, &gitrpc.DiffParams{ ReadParams: gitrpc.CreateRPCReadParams(repo), diff --git a/internal/api/controller/pullreq/pr_find.go b/internal/api/controller/pullreq/pr_find.go index 26558f1f1..497dadafd 100644 --- a/internal/api/controller/pullreq/pr_find.go +++ b/internal/api/controller/pullreq/pr_find.go @@ -36,14 +36,8 @@ func (c *Controller) Find( return nil, err } - headRef := pr.SourceBranch - if pr.SourceSHA != "" { - headRef = pr.SourceSHA - } - baseRef := pr.TargetBranch - if pr.MergeBaseSHA != nil { - baseRef = *pr.MergeBaseSHA - } + headRef := pr.SourceSHA + baseRef := pr.MergeBaseSHA output, err := c.gitRPCClient.DiffStats(ctx, &gitrpc.DiffParams{ ReadParams: gitrpc.CreateRPCReadParams(repo), diff --git a/internal/events/pullreq/events_branch.go b/internal/events/pullreq/events_branch.go index 56ea31e57..0f43a922a 100644 --- a/internal/events/pullreq/events_branch.go +++ b/internal/events/pullreq/events_branch.go @@ -16,9 +16,11 @@ const BranchUpdatedEvent events.EventType = "branch-updated" type BranchUpdatedPayload struct { Base - OldSHA string `json:"old_sha"` - NewSHA string `json:"new_sha"` - Forced bool `json:"forced"` + OldSHA string `json:"old_sha"` + NewSHA string `json:"new_sha"` + OldMergeBaseSHA string `json:"old_merge_base_sha"` + NewMergeBaseSHA string `json:"new_merge_base_sha"` + Forced bool `json:"forced"` } func (r *Reporter) BranchUpdated(ctx context.Context, payload *BranchUpdatedPayload) { diff --git a/internal/services/codecomments/migrator.go b/internal/services/codecomments/migrator.go index e940a95d5..cde858676 100644 --- a/internal/services/codecomments/migrator.go +++ b/internal/services/codecomments/migrator.go @@ -8,6 +8,7 @@ import ( "context" "github.com/harness/gitness/gitrpc" + gitrpcenum "github.com/harness/gitness/gitrpc/enum" "github.com/harness/gitness/types" "github.com/rs/zerolog/log" @@ -75,7 +76,7 @@ func (migrator *Migrator) MigrateOld( ) } -//nolint:gocognit // refactor if needed +//nolint:gocognit,funlen // refactor if needed func (migrator *Migrator) migrate( ctx context.Context, repoGitUID string, @@ -136,7 +137,15 @@ func (migrator *Migrator) migrate( } // Handle file delete - if len(file.HunkHeaders) == 1 && file.HunkHeaders[0].NewLine == 0 && file.HunkHeaders[0].NewSpan == 0 { + if _, isDeleted := file.FileHeader.Extensions[gitrpcenum.DiffExtHeaderDeletedFileMode]; isDeleted { + for _, codeComment := range codeComments { + codeComment.Outdated = true + } + continue + } + + // Handle new files - shouldn't happen because code comments should exist for a non-existing file. + if _, isAdded := file.FileHeader.Extensions[gitrpcenum.DiffExtHeaderNewFileMode]; isAdded { for _, codeComment := range codeComments { codeComment.Outdated = true } diff --git a/internal/services/pullreq/handlers_branch.go b/internal/services/pullreq/handlers_branch.go index 545c0baed..3dceee943 100644 --- a/internal/services/pullreq/handlers_branch.go +++ b/internal/services/pullreq/handlers_branch.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/harness/gitness/events" + "github.com/harness/gitness/gitrpc" gitevents "github.com/harness/gitness/internal/events/git" pullreqevents "github.com/harness/gitness/internal/events/pullreq" "github.com/harness/gitness/types" @@ -23,8 +24,33 @@ import ( func (s *Service) triggerPREventOnBranchUpdate(ctx context.Context, event *events.Event[*gitevents.BranchUpdatedPayload], ) error { + // TODO: This function is currently executed directly on branch update event. + // TODO: But it should be executed after the PR's head ref has been updated. + // TODO: This is to make sure the commit exists on the target repository for forked repositories. s.forEveryOpenPR(ctx, event.Payload.RepoID, event.Payload.Ref, func(pr *types.PullReq) error { - pr, err := s.pullreqStore.UpdateOptLock(ctx, pr, func(pr *types.PullReq) error { + // First check if the merge base has changed + + targetRepoGit, err := s.repoGitInfoCache.Get(ctx, pr.TargetRepoID) + if err != nil { + return fmt.Errorf("failed to get repo git info: %w", err) + } + + mergeBaseInfo, err := s.gitRPCClient.MergeBase(ctx, gitrpc.MergeBaseParams{ + ReadParams: gitrpc.ReadParams{RepoUID: targetRepoGit.GitUID}, + Ref1: event.Payload.NewSHA, + Ref2: pr.TargetBranch, + }) + if err != nil { + return fmt.Errorf("failed to get merge base after branch update to=%s for PR=%d: %w", + event.Payload.NewSHA, pr.Number, err) + } + + oldMergeBase := pr.MergeBaseSHA + newMergeBase := mergeBaseInfo.MergeBaseSHA + + // Update the database with the latest source commit SHA and the merge base SHA. + + pr, err = s.pullreqStore.UpdateOptLock(ctx, pr, func(pr *types.PullReq) error { pr.ActivitySeq++ if pr.SourceSHA != event.Payload.OldSHA { return fmt.Errorf( @@ -33,6 +59,7 @@ func (s *Service) triggerPREventOnBranchUpdate(ctx context.Context, } pr.SourceSHA = event.Payload.NewSHA + pr.MergeBaseSHA = newMergeBase // reset merge-check fields for new run pr.MergeCheckStatus = enum.MergeCheckStatusUnchecked @@ -63,9 +90,11 @@ func (s *Service) triggerPREventOnBranchUpdate(ctx context.Context, PrincipalID: event.Payload.PrincipalID, Number: pr.Number, }, - OldSHA: event.Payload.OldSHA, - NewSHA: event.Payload.NewSHA, - Forced: event.Payload.Forced, + OldSHA: event.Payload.OldSHA, + NewSHA: event.Payload.NewSHA, + OldMergeBaseSHA: oldMergeBase, + NewMergeBaseSHA: newMergeBase, + Forced: event.Payload.Forced, }) return nil }) diff --git a/internal/services/pullreq/handlers_code_comments.go b/internal/services/pullreq/handlers_code_comments.go index 7fee56fbc..fd46d7134 100644 --- a/internal/services/pullreq/handlers_code_comments.go +++ b/internal/services/pullreq/handlers_code_comments.go @@ -11,27 +11,35 @@ import ( "github.com/harness/gitness/events" pullreqevents "github.com/harness/gitness/internal/events/pullreq" "github.com/harness/gitness/types" - - "github.com/rs/zerolog/log" ) func (s *Service) updateCodeCommentsOnBranchUpdate(ctx context.Context, event *events.Event[*pullreqevents.BranchUpdatedPayload], ) error { - oldSourceSHA := event.Payload.OldSHA // NOTE: we're ignoring the old value and instead try to update all - newSourceSHA := event.Payload.NewSHA - - log.Ctx(ctx).Debug(). - Str("oldSHA", oldSourceSHA). - Str("newSHA", newSourceSHA). - Msgf("code comment update after source branch update") - - repoGit, err := s.repoGitInfoCache.Get(ctx, event.Payload.SourceRepoID) + repoGit, err := s.repoGitInfoCache.Get(ctx, event.Payload.TargetRepoID) if err != nil { return fmt.Errorf("failed to get repo git info: %w", err) } - codeComments, err := s.codeCommentView.ListNotAtSourceSHA(ctx, event.Payload.PullReqID, newSourceSHA) + var codeComments []*types.CodeComment + + newMergeBaseSHA := event.Payload.NewMergeBaseSHA + + codeComments, err = s.codeCommentView.ListNotAtMergeBaseSHA(ctx, event.Payload.PullReqID, newMergeBaseSHA) + if err != nil { + return fmt.Errorf("failed to get list of code comments for update after merge base update: %w", err) + } + + s.codeCommentMigrator.MigrateOld(ctx, repoGit.GitUID, newMergeBaseSHA, codeComments) + + err = s.codeCommentView.UpdateAll(ctx, codeComments) + if err != nil { + return fmt.Errorf("failed to update code comments after merge base update: %w", err) + } + + newSourceSHA := event.Payload.NewSHA + + codeComments, err = s.codeCommentView.ListNotAtSourceSHA(ctx, event.Payload.PullReqID, newSourceSHA) if err != nil { return fmt.Errorf("failed to get list of code comments for update after source branch update: %w", err) } @@ -45,28 +53,3 @@ func (s *Service) updateCodeCommentsOnBranchUpdate(ctx context.Context, return nil } - -func (s *Service) updateCodeCommentsOnMergeBaseUpdate(ctx context.Context, - pr *types.PullReq, - gitUID string, - oldMergeBaseSHA, newMergeBaseSHA string, -) error { - log.Ctx(ctx).Debug(). - Str("oldSHA", oldMergeBaseSHA). - Str("newSHA", newMergeBaseSHA). - Msgf("code comment update after merge base update") - - codeComments, err := s.codeCommentView.ListNotAtMergeBaseSHA(ctx, pr.ID, newMergeBaseSHA) - if err != nil { - return fmt.Errorf("failed to get list of code comments for update after merge base update: %w", err) - } - - s.codeCommentMigrator.MigrateOld(ctx, gitUID, newMergeBaseSHA, codeComments) - - err = s.codeCommentView.UpdateAll(ctx, codeComments) - if err != nil { - return fmt.Errorf("failed to update code comments after merge base update: %w", err) - } - - return nil -} diff --git a/internal/services/pullreq/handlers_mergeable.go b/internal/services/pullreq/handlers_mergeable.go index 17e8d491a..b583c0882 100644 --- a/internal/services/pullreq/handlers_mergeable.go +++ b/internal/services/pullreq/handlers_mergeable.go @@ -122,7 +122,7 @@ func (s *Service) deleteMergeRef(ctx context.Context, principalID int64, repoID return nil } -//nolint:funlen,gocognit // refactor if required. +//nolint:funlen // refactor if required. func (s *Service) updateMergeData( ctx context.Context, principalID int64, @@ -131,6 +131,10 @@ func (s *Service) updateMergeData( oldSHA string, newSHA string, ) error { + // TODO: Merge check should not update the merge base. + // TODO: Instead it should accept it as an argument and fail if it doesn't match. + // Then is would not longer be necessary to cancel already active mergeability checks. + pr, err := s.pullreqStore.FindByNumber(ctx, repoID, prNum) if err != nil { return fmt.Errorf("failed to get pull request number %d: %w", prNum, err) @@ -227,13 +231,12 @@ func (s *Service) updateMergeData( // TODO: gitrpc should return sha's either way, and also conflicting files! pr.MergeCheckStatus = enum.MergeCheckStatusConflict pr.MergeTargetSHA = &output.BaseSHA - pr.MergeBaseSHA = &output.MergeBaseSHA pr.MergeSHA = nil pr.MergeConflicts = nil } else { pr.MergeCheckStatus = enum.MergeCheckStatusMergeable pr.MergeTargetSHA = &output.BaseSHA - pr.MergeBaseSHA = &output.MergeBaseSHA + pr.MergeBaseSHA = output.MergeBaseSHA // TODO: Merge check should not update the merge base. pr.MergeSHA = &output.MergeSHA pr.MergeConflicts = nil } @@ -243,14 +246,5 @@ func (s *Service) updateMergeData( return fmt.Errorf("failed to update PR merge ref in db with error: %w", err) } - if pr.MergeBaseSHA != nil && *pr.MergeBaseSHA != output.MergeBaseSHA { - oldMergeBaseSHA := *pr.MergeBaseSHA - newMergeBaseSHA := output.MergeBaseSHA - err = s.updateCodeCommentsOnMergeBaseUpdate(ctx, pr, sourceRepo.GitUID, oldMergeBaseSHA, newMergeBaseSHA) - if err != nil { - return fmt.Errorf("failed to update code comment after merge base SHA change: %w", err) - } - } - return nil } diff --git a/internal/store/database/code_comment.go b/internal/store/database/code_comment.go index 1a2fde9dc..b69f5f9a9 100644 --- a/internal/store/database/code_comment.go +++ b/internal/store/database/code_comment.go @@ -103,6 +103,10 @@ func (s *CodeCommentView) list(ctx context.Context, // UpdateAll updates all code comments provided in the slice. func (s *CodeCommentView) UpdateAll(ctx context.Context, codeComments []*types.CodeComment) error { + if len(codeComments) == 0 { + return nil + } + const sqlQuery = ` UPDATE pullreq_activities SET diff --git a/internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.down.sql b/internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.down.sql new file mode 100644 index 000000000..b3501caff --- /dev/null +++ b/internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.down.sql @@ -0,0 +1,4 @@ +ALTER TABLE pullreqs + ALTER COLUMN pullreq_merge_base_sha DROP DEFAULT, + ALTER COLUMN pullreq_merge_base_sha DROP NOT NULL; +UPDATE pullreqs SET pullreq_merge_base_sha = NULL WHERE pullreq_merge_base_sha = ''; \ No newline at end of file diff --git a/internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.up.sql b/internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.up.sql new file mode 100644 index 000000000..e0985cd6b --- /dev/null +++ b/internal/store/database/migrate/postgres/0015_alter_pullreq_merge_base_not_nullable.up.sql @@ -0,0 +1,4 @@ +UPDATE pullreqs SET pullreq_merge_base_sha = '' WHERE pullreq_merge_base_sha IS NULL; +ALTER TABLE pullreqs + ALTER COLUMN pullreq_merge_base_sha SET DEFAULT '', + ALTER COLUMN pullreq_merge_base_sha SET NOT NULL; \ No newline at end of file diff --git a/internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.down.sql b/internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.down.sql new file mode 100644 index 000000000..e2648bb56 --- /dev/null +++ b/internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.down.sql @@ -0,0 +1,4 @@ +ALTER TABLE pullreqs ADD COLUMN pullreq_merge_base_sha_nullable TEXT; +UPDATE pullreqs SET pullreq_merge_base_sha_nullable = pullreq_merge_base_sha WHERE pullreq_merge_base_sha <> ''; +ALTER TABLE pullreqs DROP COLUMN pullreq_merge_base_sha; +ALTER TABLE pullreqs RENAME COLUMN pullreq_merge_base_sha_nullable TO pullreq_merge_base_sha; diff --git a/internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.up.sql b/internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.up.sql new file mode 100644 index 000000000..8f3ec955d --- /dev/null +++ b/internal/store/database/migrate/sqlite/0015_alter_pullreq_merge_base_not_nullable.up.sql @@ -0,0 +1,4 @@ +ALTER TABLE pullreqs ADD COLUMN pullreq_merge_base_sha_not_nullable TEXT NOT NULL DEFAULT ''; +UPDATE pullreqs SET pullreq_merge_base_sha_not_nullable = pullreq_merge_base_sha WHERE pullreq_merge_base_sha IS NOT NULL; +ALTER TABLE pullreqs DROP COLUMN pullreq_merge_base_sha; +ALTER TABLE pullreqs RENAME COLUMN pullreq_merge_base_sha_not_nullable TO pullreq_merge_base_sha; diff --git a/internal/store/database/pullreq.go b/internal/store/database/pullreq.go index 6443a01ce..71fbd9113 100644 --- a/internal/store/database/pullreq.go +++ b/internal/store/database/pullreq.go @@ -73,7 +73,7 @@ type pullReq struct { MergeCheckStatus enum.MergeCheckStatus `db:"pullreq_merge_check_status"` MergeTargetSHA null.String `db:"pullreq_merge_target_sha"` - MergeBaseSHA null.String `db:"pullreq_merge_base_sha"` + MergeBaseSHA string `db:"pullreq_merge_base_sha"` MergeSHA null.String `db:"pullreq_merge_sha"` MergeConflicts null.String `db:"pullreq_merge_conflicts"` } @@ -481,7 +481,7 @@ func mapPullReq(pr *pullReq) *types.PullReq { MergeMethod: (*enum.MergeMethod)(pr.MergeMethod.Ptr()), MergeCheckStatus: pr.MergeCheckStatus, MergeTargetSHA: pr.MergeTargetSHA.Ptr(), - MergeBaseSHA: pr.MergeBaseSHA.Ptr(), + MergeBaseSHA: pr.MergeBaseSHA, MergeSHA: pr.MergeSHA.Ptr(), MergeConflicts: pr.MergeConflicts.Ptr(), Author: types.PrincipalInfo{}, @@ -521,7 +521,7 @@ func mapInternalPullReq(pr *types.PullReq) *pullReq { MergeMethod: null.StringFromPtr((*string)(pr.MergeMethod)), MergeCheckStatus: pr.MergeCheckStatus, MergeTargetSHA: null.StringFromPtr(pr.MergeTargetSHA), - MergeBaseSHA: null.StringFromPtr(pr.MergeBaseSHA), + MergeBaseSHA: pr.MergeBaseSHA, MergeSHA: null.StringFromPtr(pr.MergeSHA), MergeConflicts: null.StringFromPtr(pr.MergeConflicts), } diff --git a/types/pullreq.go b/types/pullreq.go index e73409c18..16288d010 100644 --- a/types/pullreq.go +++ b/types/pullreq.go @@ -41,7 +41,7 @@ type PullReq struct { MergeCheckStatus enum.MergeCheckStatus `json:"merge_check_status"` MergeTargetSHA *string `json:"merge_target_sha"` - MergeBaseSHA *string `json:"merge_base_sha"` + MergeBaseSHA string `json:"merge_base_sha"` MergeSHA *string `json:"merge_sha"` MergeConflicts *string `json:"merge_conflicts,omitempty"`