diff options
author | David Kim <dkim@gitlab.com> | 2022-12-13 12:17:02 +0300 |
---|---|---|
committer | David Kim <dkim@gitlab.com> | 2022-12-21 08:27:24 +0300 |
commit | 542d4f3dd2dd57b174fb116213816db591e640b2 (patch) | |
tree | 3c7981878217864ae5f9165ef5455577008e3c78 | |
parent | 23cf4aac8151774a1aaedf8f4c014156320c9db3 (diff) |
Add new GetPatchID RPC
Patch IDs are a unique ID computed by hashing a patch with some parameters like line numbers ignored.
The patch ID can thus be used to compare whether diffs make the same change.
Please refer to git-patch-id(1) for further information.
-rw-r--r-- | internal/git/command_description.go | 3 | ||||
-rw-r--r-- | internal/gitaly/service/diff/patch_id.go | 84 | ||||
-rw-r--r-- | internal/gitaly/service/diff/patch_id_test.go | 138 | ||||
-rw-r--r-- | proto/diff.proto | 30 | ||||
-rw-r--r-- | proto/go/gitalypb/diff.pb.go | 320 | ||||
-rw-r--r-- | proto/go/gitalypb/diff_grpc.pb.go | 47 |
6 files changed, 545 insertions, 77 deletions
diff --git a/internal/git/command_description.go b/internal/git/command_description.go index 99a932cc4..0ed09e7f9 100644 --- a/internal/git/command_description.go +++ b/internal/git/command_description.go @@ -202,6 +202,9 @@ var commandDescriptions = map[string]commandDescription{ flags: scNoRefUpdates, opts: packConfiguration(), }, + "patch-id": { + flags: scNoRefUpdates | scNoEndOfOptions, + }, "prune": { flags: scNoRefUpdates, }, diff --git a/internal/gitaly/service/diff/patch_id.go b/internal/gitaly/service/diff/patch_id.go new file mode 100644 index 000000000..aa8e5f50a --- /dev/null +++ b/internal/gitaly/service/diff/patch_id.go @@ -0,0 +1,84 @@ +package diff + +import ( + "context" + "errors" + "strings" + + "gitlab.com/gitlab-org/gitaly/v15/internal/git" + "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service" + "gitlab.com/gitlab-org/gitaly/v15/internal/structerr" + "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" +) + +func (s *server) GetPatchID(ctx context.Context, in *gitalypb.GetPatchIDRequest) (*gitalypb.GetPatchIDResponse, error) { + if err := validatePatchIDRequest(in); err != nil { + return nil, structerr.NewInvalidArgument("%w", err) + } + + var diffCmdStderr strings.Builder + + diffCmd, err := s.gitCmdFactory.New(ctx, in.Repository, + git.Command{ + Name: "diff", + Args: []string{string(in.GetOldRevision()), string(in.GetNewRevision())}, + }, + git.WithStderr(&diffCmdStderr), + ) + if err != nil { + return nil, structerr.New("spawning diff: %w", err) + } + + var patchIDStdout strings.Builder + var patchIDStderr strings.Builder + + patchIDCmd, err := s.gitCmdFactory.NewWithoutRepo(ctx, + git.Command{ + Name: "patch-id", + Flags: []git.Option{git.Flag{Name: "--stable"}}, + }, + git.WithStdin(diffCmd), + git.WithStdout(&patchIDStdout), + git.WithStderr(&patchIDStderr), + ) + if err != nil { + return nil, structerr.New("spawning patch-id: %w", err) + } + + if err := patchIDCmd.Wait(); err != nil { + return nil, structerr.New("waiting for patch-id: %w", err).WithMetadata("stderr", patchIDStderr.String()) + } + + if err := diffCmd.Wait(); err != nil { + return nil, structerr.New("waiting for git-diff: %w", err).WithMetadata("stderr", diffCmdStderr.String()) + } + + if patchIDStdout.Len() == 0 { + return nil, structerr.NewFailedPrecondition("no difference between old and new revision") + } + + // When computing patch IDs for commits directly via e.g. `git show | git patch-id` then the second + // field printed by git-patch-id(1) denotes the commit of the patch ID. As we only generate patch IDs + // from a diff here the second field will always be the zero OID, so we ignore it. + patchID, _, found := strings.Cut(patchIDStdout.String(), " ") + + if !found { + return nil, structerr.NewFailedPrecondition("unexpected patch ID format") + } + + return &gitalypb.GetPatchIDResponse{PatchId: patchID}, nil +} + +func validatePatchIDRequest(in *gitalypb.GetPatchIDRequest) error { + if err := service.ValidateRepository(in.GetRepository()); err != nil { + return err + } + if string(in.GetOldRevision()) == "" { + return errors.New("empty OldRevision") + } + if string(in.GetNewRevision()) == "" { + return errors.New("empty NewRevision") + } + + return nil +} diff --git a/internal/gitaly/service/diff/patch_id_test.go b/internal/gitaly/service/diff/patch_id_test.go new file mode 100644 index 000000000..432cc47cd --- /dev/null +++ b/internal/gitaly/service/diff/patch_id_test.go @@ -0,0 +1,138 @@ +//go:build !gitaly_test_sha256 + +package diff + +import ( + "testing" + + "gitlab.com/gitlab-org/gitaly/v15/internal/structerr" + "gitlab.com/gitlab-org/gitaly/v15/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" +) + +func TestGetPatchID(t *testing.T) { + t.Parallel() + ctx := testhelper.Context(t) + _, repoProto, _, client := setupDiffService(t, ctx) + + testCases := []struct { + desc string + setup func() *gitalypb.GetPatchIDRequest + expectedResponse *gitalypb.GetPatchIDResponse + expectedErr error + }{ + { + desc: "returns patch-id successfully", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("HEAD~3"), + NewRevision: []byte("HEAD"), + } + }, + expectedResponse: &gitalypb.GetPatchIDResponse{PatchId: "1d108b99acd03f94e015c5237afa7bc24382f1f6"}, + }, + { + desc: "returns patch-id successfully with commit ids", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("55bc176024cfa3baaceb71db584c7e5df900ea65"), + NewRevision: []byte("c1c67abbaf91f624347bb3ae96eabe3a1b742478"), + } + }, + expectedResponse: &gitalypb.GetPatchIDResponse{PatchId: "1c5c57c2b6ef85b3cd248c34318bcce5bec3b540"}, + }, + { + desc: "returns patch-id successfully for a specific file", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("HEAD~3:.gitattributes"), + NewRevision: []byte("HEAD:.gitattributes"), + } + }, + expectedResponse: &gitalypb.GetPatchIDResponse{PatchId: "ed52511a91dd53dcf58acf6e85be5456b54f2f8a"}, + }, + { + desc: "file didn't exist in the old revision", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("HEAD~3:files/flat/path/correct/content.txt"), + NewRevision: []byte("HEAD:files/flat/path/correct/content.txt"), + } + }, + expectedErr: structerr.New("waiting for git-diff: exit status 128"), + }, + { + desc: "unknown revisions", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("0000000000000000000000000000000000000000"), + NewRevision: []byte("1111111111111111111111111111111111111111"), + } + }, + expectedErr: structerr.New("waiting for git-diff: exit status 128").WithMetadata("stderr", ""), + }, + { + desc: "no diff from the given revisions", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("HEAD"), + NewRevision: []byte("HEAD"), + } + }, + expectedErr: structerr.NewFailedPrecondition("no difference between old and new revision"), + }, + { + desc: "empty repository", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: nil, + OldRevision: []byte("HEAD~1"), + NewRevision: []byte("HEAD"), + } + }, + expectedErr: structerr.NewInvalidArgument(testhelper.GitalyOrPraefect( + "empty Repository", + "repo scoped: empty Repository", + )), + }, + { + desc: "empty old revision", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + NewRevision: []byte("HEAD"), + } + }, + expectedErr: structerr.NewInvalidArgument("empty OldRevision"), + }, + { + desc: "empty new revision", + setup: func() *gitalypb.GetPatchIDRequest { + return &gitalypb.GetPatchIDRequest{ + Repository: repoProto, + OldRevision: []byte("HEAD~1"), + } + }, + expectedErr: structerr.NewInvalidArgument("empty NewRevision"), + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.desc, func(t *testing.T) { + t.Parallel() + + request := tc.setup() + response, err := client.GetPatchID(ctx, request) + + testhelper.RequireGrpcError(t, tc.expectedErr, err) + testhelper.ProtoEqual(t, tc.expectedResponse, response) + }) + } +} diff --git a/proto/diff.proto b/proto/diff.proto index 3247ceb57..6905af2c4 100644 --- a/proto/diff.proto +++ b/proto/diff.proto @@ -53,6 +53,15 @@ service DiffService { }; } + // GetPatchID computes a patch ID for a patch. Patch IDs are a unique ID computed by hashing + // a patch with some parameters like line numbers ignored. The patch ID can thus be used to compare + // whether diffs make the same change. Please refer to git-patch-id(1) for further information. + // If the difference between old and new change is empty then this RPC returns an error. + rpc GetPatchID(GetPatchIDRequest) returns (GetPatchIDResponse) { + option (op_type) = { + op: ACCESSOR + }; + } } // This comment is left unintentionally blank. @@ -312,3 +321,24 @@ message ChangedPaths { // new_mode is the mode of the changed path after the change. Please refer to `old_mode` for a list of potential values. int32 new_mode = 4; } + +// GetPatchIDRequest is a request for the GetPatchID RPC. +message GetPatchIDRequest { + // Repository is the repository the patch ID shall be computed in. + Repository repository = 1 [(target_repository)=true]; + // OldRevision is the old revision that shall be used to compute the patch + // from that will then be passed to git-patch-id(1). Accepts revisions as + // specified in gitrevisions(5). + bytes old_revision = 2; + // newRevision is the new revision that shall be used to compute the patch + // from that will then be passed to git-patch-id(1). Accepts revisions as + // specified in gitrevisions(5). + bytes new_revision = 3; +} + +// GetPatchIDResponse is a response for the GetPatchID RPC. +message GetPatchIDResponse { + // PatchId is the patch ID that was generated by hashing the diff of the + // given old and new revision. + string patch_id = 1; +} diff --git a/proto/go/gitalypb/diff.pb.go b/proto/go/gitalypb/diff.pb.go index ad38fd178..10d55083b 100644 --- a/proto/go/gitalypb/diff.pb.go +++ b/proto/go/gitalypb/diff.pb.go @@ -1306,6 +1306,127 @@ func (x *ChangedPaths) GetNewMode() int32 { return 0 } +// GetPatchIDRequest is a request for the GetPatchID RPC. +type GetPatchIDRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Repository is the repository the patch ID shall be computed in. + Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + // OldRevision is the old revision that shall be used to compute the patch + // from that will then be passed to git-patch-id(1). Accepts revisions as + // specified in gitrevisions(5). + OldRevision []byte `protobuf:"bytes,2,opt,name=old_revision,json=oldRevision,proto3" json:"old_revision,omitempty"` + // newRevision is the new revision that shall be used to compute the patch + // from that will then be passed to git-patch-id(1). Accepts revisions as + // specified in gitrevisions(5). + NewRevision []byte `protobuf:"bytes,3,opt,name=new_revision,json=newRevision,proto3" json:"new_revision,omitempty"` +} + +func (x *GetPatchIDRequest) Reset() { + *x = GetPatchIDRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_diff_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPatchIDRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPatchIDRequest) ProtoMessage() {} + +func (x *GetPatchIDRequest) ProtoReflect() protoreflect.Message { + mi := &file_diff_proto_msgTypes[15] + 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 GetPatchIDRequest.ProtoReflect.Descriptor instead. +func (*GetPatchIDRequest) Descriptor() ([]byte, []int) { + return file_diff_proto_rawDescGZIP(), []int{15} +} + +func (x *GetPatchIDRequest) GetRepository() *Repository { + if x != nil { + return x.Repository + } + return nil +} + +func (x *GetPatchIDRequest) GetOldRevision() []byte { + if x != nil { + return x.OldRevision + } + return nil +} + +func (x *GetPatchIDRequest) GetNewRevision() []byte { + if x != nil { + return x.NewRevision + } + return nil +} + +// GetPatchIDResponse is a response for the GetPatchID RPC. +type GetPatchIDResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // PatchId is the patch ID that was generated by hashing the diff of the + // given old and new revision. + PatchId string `protobuf:"bytes,1,opt,name=patch_id,json=patchId,proto3" json:"patch_id,omitempty"` +} + +func (x *GetPatchIDResponse) Reset() { + *x = GetPatchIDResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_diff_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPatchIDResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPatchIDResponse) ProtoMessage() {} + +func (x *GetPatchIDResponse) ProtoReflect() protoreflect.Message { + mi := &file_diff_proto_msgTypes[16] + 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 GetPatchIDResponse.ProtoReflect.Descriptor instead. +func (*GetPatchIDResponse) Descriptor() ([]byte, []int) { + return file_diff_proto_rawDescGZIP(), []int{16} +} + +func (x *GetPatchIDResponse) GetPatchId() string { + if x != nil { + return x.PatchId + } + return "" +} + // Request is a single request to pass to git diff-tree. type FindChangedPathsRequest_Request struct { state protoimpl.MessageState @@ -1322,7 +1443,7 @@ type FindChangedPathsRequest_Request struct { func (x *FindChangedPathsRequest_Request) Reset() { *x = FindChangedPathsRequest_Request{} if protoimpl.UnsafeEnabled { - mi := &file_diff_proto_msgTypes[15] + mi := &file_diff_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1335,7 +1456,7 @@ func (x *FindChangedPathsRequest_Request) String() string { func (*FindChangedPathsRequest_Request) ProtoMessage() {} func (x *FindChangedPathsRequest_Request) ProtoReflect() protoreflect.Message { - mi := &file_diff_proto_msgTypes[15] + mi := &file_diff_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1407,7 +1528,7 @@ type FindChangedPathsRequest_Request_TreeRequest struct { func (x *FindChangedPathsRequest_Request_TreeRequest) Reset() { *x = FindChangedPathsRequest_Request_TreeRequest{} if protoimpl.UnsafeEnabled { - mi := &file_diff_proto_msgTypes[16] + mi := &file_diff_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1420,7 +1541,7 @@ func (x *FindChangedPathsRequest_Request_TreeRequest) String() string { func (*FindChangedPathsRequest_Request_TreeRequest) ProtoMessage() {} func (x *FindChangedPathsRequest_Request_TreeRequest) ProtoReflect() protoreflect.Message { - mi := &file_diff_proto_msgTypes[16] + mi := &file_diff_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1469,7 +1590,7 @@ type FindChangedPathsRequest_Request_CommitRequest struct { func (x *FindChangedPathsRequest_Request_CommitRequest) Reset() { *x = FindChangedPathsRequest_Request_CommitRequest{} if protoimpl.UnsafeEnabled { - mi := &file_diff_proto_msgTypes[17] + mi := &file_diff_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1482,7 +1603,7 @@ func (x *FindChangedPathsRequest_Request_CommitRequest) String() string { func (*FindChangedPathsRequest_Request_CommitRequest) ProtoMessage() {} func (x *FindChangedPathsRequest_Request_CommitRequest) ProtoReflect() protoreflect.Message { - mi := &file_diff_proto_msgTypes[17] + mi := &file_diff_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1711,41 +1832,59 @@ var file_diff_proto_rawDesc = []byte{ 0x08, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4f, 0x50, - 0x49, 0x45, 0x44, 0x10, 0x04, 0x32, 0xea, 0x03, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, - 0x69, 0x66, 0x66, 0x12, 0x19, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, - 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, - 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, - 0x08, 0x02, 0x30, 0x01, 0x12, 0x50, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x65, - 0x6c, 0x74, 0x61, 0x12, 0x1a, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1b, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, - 0x65, 0x6c, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, - 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x07, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, - 0x66, 0x12, 0x16, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, - 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, - 0x6c, 0x79, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x47, 0x0a, 0x08, - 0x52, 0x61, 0x77, 0x50, 0x61, 0x74, 0x63, 0x68, 0x12, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, - 0x79, 0x2e, 0x52, 0x61, 0x77, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x61, 0x77, 0x50, 0x61, - 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, - 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x4a, 0x0a, 0x09, 0x44, 0x69, 0x66, 0x66, 0x53, 0x74, 0x61, - 0x74, 0x73, 0x12, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x44, 0x69, 0x66, 0x66, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x67, - 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, - 0x01, 0x12, 0x5f, 0x0a, 0x10, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, - 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x46, - 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, - 0x46, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, - 0x30, 0x01, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x69, 0x74, 0x61, - 0x6c, 0x79, 0x2f, 0x76, 0x31, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, - 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x45, 0x44, 0x10, 0x04, 0x22, 0x93, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x74, + 0x63, 0x68, 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0a, 0x72, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x6f, 0x6c, 0x64, 0x5f, 0x72, 0x65, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x6c, 0x64, + 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x77, 0x5f, + 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, + 0x6e, 0x65, 0x77, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2f, 0x0a, 0x12, 0x47, + 0x65, 0x74, 0x50, 0x61, 0x74, 0x63, 0x68, 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x49, 0x64, 0x32, 0xb7, 0x04, 0x0a, + 0x0b, 0x44, 0x69, 0x66, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0a, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x66, 0x66, 0x12, 0x19, 0x2e, 0x67, 0x69, 0x74, + 0x61, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x50, 0x0a, 0x0b, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x12, 0x1a, 0x2e, 0x67, 0x69, 0x74, + 0x61, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x44, 0x0a, + 0x07, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x12, 0x16, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, + 0x79, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, + 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, + 0x02, 0x30, 0x01, 0x12, 0x47, 0x0a, 0x08, 0x52, 0x61, 0x77, 0x50, 0x61, 0x74, 0x63, 0x68, 0x12, + 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x61, 0x77, 0x50, 0x61, 0x74, 0x63, + 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, + 0x79, 0x2e, 0x52, 0x61, 0x77, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x4a, 0x0a, 0x09, + 0x44, 0x69, 0x66, 0x66, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x61, + 0x6c, 0x79, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x44, 0x69, 0x66, + 0x66, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, + 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x5f, 0x0a, 0x10, 0x46, 0x69, 0x6e, 0x64, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x73, 0x12, 0x1f, 0x2e, 0x67, + 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x64, 0x50, 0x61, 0x74, 0x68, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, + 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x4b, 0x0a, 0x0a, 0x47, 0x65, 0x74, + 0x50, 0x61, 0x74, 0x63, 0x68, 0x49, 0x44, 0x12, 0x19, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, + 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x74, 0x63, 0x68, 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x50, + 0x61, 0x74, 0x63, 0x68, 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, + 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2d, 0x6f, 0x72, 0x67, 0x2f, + 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2f, 0x76, 0x31, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1761,7 +1900,7 @@ func file_diff_proto_rawDescGZIP() []byte { } var file_diff_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 18) +var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 20) var file_diff_proto_goTypes = []interface{}{ (CommitDiffRequest_DiffMode)(0), // 0: gitaly.CommitDiffRequest.DiffMode (ChangedPaths_Status)(0), // 1: gitaly.ChangedPaths.Status @@ -1780,43 +1919,48 @@ var file_diff_proto_goTypes = []interface{}{ (*FindChangedPathsRequest)(nil), // 14: gitaly.FindChangedPathsRequest (*FindChangedPathsResponse)(nil), // 15: gitaly.FindChangedPathsResponse (*ChangedPaths)(nil), // 16: gitaly.ChangedPaths - (*FindChangedPathsRequest_Request)(nil), // 17: gitaly.FindChangedPathsRequest.Request - (*FindChangedPathsRequest_Request_TreeRequest)(nil), // 18: gitaly.FindChangedPathsRequest.Request.TreeRequest - (*FindChangedPathsRequest_Request_CommitRequest)(nil), // 19: gitaly.FindChangedPathsRequest.Request.CommitRequest - (*Repository)(nil), // 20: gitaly.Repository + (*GetPatchIDRequest)(nil), // 17: gitaly.GetPatchIDRequest + (*GetPatchIDResponse)(nil), // 18: gitaly.GetPatchIDResponse + (*FindChangedPathsRequest_Request)(nil), // 19: gitaly.FindChangedPathsRequest.Request + (*FindChangedPathsRequest_Request_TreeRequest)(nil), // 20: gitaly.FindChangedPathsRequest.Request.TreeRequest + (*FindChangedPathsRequest_Request_CommitRequest)(nil), // 21: gitaly.FindChangedPathsRequest.Request.CommitRequest + (*Repository)(nil), // 22: gitaly.Repository } var file_diff_proto_depIdxs = []int32{ - 20, // 0: gitaly.CommitDiffRequest.repository:type_name -> gitaly.Repository + 22, // 0: gitaly.CommitDiffRequest.repository:type_name -> gitaly.Repository 0, // 1: gitaly.CommitDiffRequest.diff_mode:type_name -> gitaly.CommitDiffRequest.DiffMode - 20, // 2: gitaly.CommitDeltaRequest.repository:type_name -> gitaly.Repository + 22, // 2: gitaly.CommitDeltaRequest.repository:type_name -> gitaly.Repository 5, // 3: gitaly.CommitDeltaResponse.deltas:type_name -> gitaly.CommitDelta - 20, // 4: gitaly.RawDiffRequest.repository:type_name -> gitaly.Repository - 20, // 5: gitaly.RawPatchRequest.repository:type_name -> gitaly.Repository - 20, // 6: gitaly.DiffStatsRequest.repository:type_name -> gitaly.Repository + 22, // 4: gitaly.RawDiffRequest.repository:type_name -> gitaly.Repository + 22, // 5: gitaly.RawPatchRequest.repository:type_name -> gitaly.Repository + 22, // 6: gitaly.DiffStatsRequest.repository:type_name -> gitaly.Repository 12, // 7: gitaly.DiffStatsResponse.stats:type_name -> gitaly.DiffStats - 20, // 8: gitaly.FindChangedPathsRequest.repository:type_name -> gitaly.Repository - 17, // 9: gitaly.FindChangedPathsRequest.requests:type_name -> gitaly.FindChangedPathsRequest.Request + 22, // 8: gitaly.FindChangedPathsRequest.repository:type_name -> gitaly.Repository + 19, // 9: gitaly.FindChangedPathsRequest.requests:type_name -> gitaly.FindChangedPathsRequest.Request 16, // 10: gitaly.FindChangedPathsResponse.paths:type_name -> gitaly.ChangedPaths 1, // 11: gitaly.ChangedPaths.status:type_name -> gitaly.ChangedPaths.Status - 18, // 12: gitaly.FindChangedPathsRequest.Request.tree_request:type_name -> gitaly.FindChangedPathsRequest.Request.TreeRequest - 19, // 13: gitaly.FindChangedPathsRequest.Request.commit_request:type_name -> gitaly.FindChangedPathsRequest.Request.CommitRequest - 2, // 14: gitaly.DiffService.CommitDiff:input_type -> gitaly.CommitDiffRequest - 4, // 15: gitaly.DiffService.CommitDelta:input_type -> gitaly.CommitDeltaRequest - 7, // 16: gitaly.DiffService.RawDiff:input_type -> gitaly.RawDiffRequest - 9, // 17: gitaly.DiffService.RawPatch:input_type -> gitaly.RawPatchRequest - 11, // 18: gitaly.DiffService.DiffStats:input_type -> gitaly.DiffStatsRequest - 14, // 19: gitaly.DiffService.FindChangedPaths:input_type -> gitaly.FindChangedPathsRequest - 3, // 20: gitaly.DiffService.CommitDiff:output_type -> gitaly.CommitDiffResponse - 6, // 21: gitaly.DiffService.CommitDelta:output_type -> gitaly.CommitDeltaResponse - 8, // 22: gitaly.DiffService.RawDiff:output_type -> gitaly.RawDiffResponse - 10, // 23: gitaly.DiffService.RawPatch:output_type -> gitaly.RawPatchResponse - 13, // 24: gitaly.DiffService.DiffStats:output_type -> gitaly.DiffStatsResponse - 15, // 25: gitaly.DiffService.FindChangedPaths:output_type -> gitaly.FindChangedPathsResponse - 20, // [20:26] is the sub-list for method output_type - 14, // [14:20] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 22, // 12: gitaly.GetPatchIDRequest.repository:type_name -> gitaly.Repository + 20, // 13: gitaly.FindChangedPathsRequest.Request.tree_request:type_name -> gitaly.FindChangedPathsRequest.Request.TreeRequest + 21, // 14: gitaly.FindChangedPathsRequest.Request.commit_request:type_name -> gitaly.FindChangedPathsRequest.Request.CommitRequest + 2, // 15: gitaly.DiffService.CommitDiff:input_type -> gitaly.CommitDiffRequest + 4, // 16: gitaly.DiffService.CommitDelta:input_type -> gitaly.CommitDeltaRequest + 7, // 17: gitaly.DiffService.RawDiff:input_type -> gitaly.RawDiffRequest + 9, // 18: gitaly.DiffService.RawPatch:input_type -> gitaly.RawPatchRequest + 11, // 19: gitaly.DiffService.DiffStats:input_type -> gitaly.DiffStatsRequest + 14, // 20: gitaly.DiffService.FindChangedPaths:input_type -> gitaly.FindChangedPathsRequest + 17, // 21: gitaly.DiffService.GetPatchID:input_type -> gitaly.GetPatchIDRequest + 3, // 22: gitaly.DiffService.CommitDiff:output_type -> gitaly.CommitDiffResponse + 6, // 23: gitaly.DiffService.CommitDelta:output_type -> gitaly.CommitDeltaResponse + 8, // 24: gitaly.DiffService.RawDiff:output_type -> gitaly.RawDiffResponse + 10, // 25: gitaly.DiffService.RawPatch:output_type -> gitaly.RawPatchResponse + 13, // 26: gitaly.DiffService.DiffStats:output_type -> gitaly.DiffStatsResponse + 15, // 27: gitaly.DiffService.FindChangedPaths:output_type -> gitaly.FindChangedPathsResponse + 18, // 28: gitaly.DiffService.GetPatchID:output_type -> gitaly.GetPatchIDResponse + 22, // [22:29] is the sub-list for method output_type + 15, // [15:22] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_diff_proto_init() } @@ -2008,7 +2152,7 @@ func file_diff_proto_init() { } } file_diff_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FindChangedPathsRequest_Request); i { + switch v := v.(*GetPatchIDRequest); i { case 0: return &v.state case 1: @@ -2020,7 +2164,7 @@ func file_diff_proto_init() { } } file_diff_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FindChangedPathsRequest_Request_TreeRequest); i { + switch v := v.(*GetPatchIDResponse); i { case 0: return &v.state case 1: @@ -2032,6 +2176,30 @@ func file_diff_proto_init() { } } file_diff_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindChangedPathsRequest_Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_diff_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindChangedPathsRequest_Request_TreeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_diff_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*FindChangedPathsRequest_Request_CommitRequest); i { case 0: return &v.state @@ -2044,7 +2212,7 @@ func file_diff_proto_init() { } } } - file_diff_proto_msgTypes[15].OneofWrappers = []interface{}{ + file_diff_proto_msgTypes[17].OneofWrappers = []interface{}{ (*FindChangedPathsRequest_Request_TreeRequest_)(nil), (*FindChangedPathsRequest_Request_CommitRequest_)(nil), } @@ -2054,7 +2222,7 @@ func file_diff_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_diff_proto_rawDesc, NumEnums: 2, - NumMessages: 18, + NumMessages: 20, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/go/gitalypb/diff_grpc.pb.go b/proto/go/gitalypb/diff_grpc.pb.go index f2e7f843b..5cbcaa875 100644 --- a/proto/go/gitalypb/diff_grpc.pb.go +++ b/proto/go/gitalypb/diff_grpc.pb.go @@ -34,6 +34,11 @@ type DiffServiceClient interface { DiffStats(ctx context.Context, in *DiffStatsRequest, opts ...grpc.CallOption) (DiffService_DiffStatsClient, error) // Return a list of files changed along with the status of each file FindChangedPaths(ctx context.Context, in *FindChangedPathsRequest, opts ...grpc.CallOption) (DiffService_FindChangedPathsClient, error) + // GetPatchID computes a patch ID for a patch. Patch IDs are a unique ID computed by hashing + // a patch with some parameters like line numbers ignored. The patch ID can thus be used to compare + // whether diffs make the same change. Please refer to git-patch-id(1) for further information. + // If the difference between old and new change is empty then this RPC returns an error. + GetPatchID(ctx context.Context, in *GetPatchIDRequest, opts ...grpc.CallOption) (*GetPatchIDResponse, error) } type diffServiceClient struct { @@ -236,6 +241,15 @@ func (x *diffServiceFindChangedPathsClient) Recv() (*FindChangedPathsResponse, e return m, nil } +func (c *diffServiceClient) GetPatchID(ctx context.Context, in *GetPatchIDRequest, opts ...grpc.CallOption) (*GetPatchIDResponse, error) { + out := new(GetPatchIDResponse) + err := c.cc.Invoke(ctx, "/gitaly.DiffService/GetPatchID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // DiffServiceServer is the server API for DiffService service. // All implementations must embed UnimplementedDiffServiceServer // for forward compatibility @@ -252,6 +266,11 @@ type DiffServiceServer interface { DiffStats(*DiffStatsRequest, DiffService_DiffStatsServer) error // Return a list of files changed along with the status of each file FindChangedPaths(*FindChangedPathsRequest, DiffService_FindChangedPathsServer) error + // GetPatchID computes a patch ID for a patch. Patch IDs are a unique ID computed by hashing + // a patch with some parameters like line numbers ignored. The patch ID can thus be used to compare + // whether diffs make the same change. Please refer to git-patch-id(1) for further information. + // If the difference between old and new change is empty then this RPC returns an error. + GetPatchID(context.Context, *GetPatchIDRequest) (*GetPatchIDResponse, error) mustEmbedUnimplementedDiffServiceServer() } @@ -277,6 +296,9 @@ func (UnimplementedDiffServiceServer) DiffStats(*DiffStatsRequest, DiffService_D func (UnimplementedDiffServiceServer) FindChangedPaths(*FindChangedPathsRequest, DiffService_FindChangedPathsServer) error { return status.Errorf(codes.Unimplemented, "method FindChangedPaths not implemented") } +func (UnimplementedDiffServiceServer) GetPatchID(context.Context, *GetPatchIDRequest) (*GetPatchIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPatchID not implemented") +} func (UnimplementedDiffServiceServer) mustEmbedUnimplementedDiffServiceServer() {} // UnsafeDiffServiceServer may be embedded to opt out of forward compatibility for this service. @@ -416,13 +438,36 @@ func (x *diffServiceFindChangedPathsServer) Send(m *FindChangedPathsResponse) er return x.ServerStream.SendMsg(m) } +func _DiffService_GetPatchID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPatchIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DiffServiceServer).GetPatchID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitaly.DiffService/GetPatchID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DiffServiceServer).GetPatchID(ctx, req.(*GetPatchIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + // DiffService_ServiceDesc is the grpc.ServiceDesc for DiffService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var DiffService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "gitaly.DiffService", HandlerType: (*DiffServiceServer)(nil), - Methods: []grpc.MethodDesc{}, + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPatchID", + Handler: _DiffService_GetPatchID_Handler, + }, + }, Streams: []grpc.StreamDesc{ { StreamName: "CommitDiff", |