diff --git a/gitaly.proto b/gitaly.proto index 34159704815f5d558e2316e3b4b318ccf7aee9fc..2677486240fa1cf82e89c502ac15e8e8d37d2cbe 100644 --- a/gitaly.proto +++ b/gitaly.proto @@ -15,6 +15,11 @@ service Notifications { rpc PostReceive(PostReceiveRequest) returns (PostReceiveResponse) {} } +service Diff { + // Returns stream of CommitDiffResponse: 1 per changed file + rpc CommitDiff(CommitDiffRequest) returns (stream CommitDiffResponse) {}; +} + message InfoRefsRequest { Repository repository = 1; } @@ -32,3 +37,22 @@ message PostReceiveRequest { } message PostReceiveResponse {} + +message CommitDiffRequest { + Repository repository = 1; + string left_commit_id = 2; + string right_commit_id = 3; +} + +// A CommitDiffResponse corresponds to a single changed file in a commit. +message CommitDiffResponse { + bytes from_path = 1; + bytes to_path = 2; + // Blob ID as returned via `git diff --full-index` + string from_id = 3; + string to_id = 4; + int32 old_mode = 5; + int32 new_mode = 6; + bool binary = 7; + repeated bytes raw_chunks = 8; +} diff --git a/go/gitaly.pb.go b/go/gitaly.pb.go index 1ccf60c6c3cdc21da04f98e4c088123eac79e485..2f50e60bb7fa4499ce46cf6650528d42c185e128 100644 --- a/go/gitaly.pb.go +++ b/go/gitaly.pb.go @@ -14,6 +14,8 @@ It has these top-level messages: Repository PostReceiveRequest PostReceiveResponse + CommitDiffRequest + CommitDiffResponse */ package gitaly @@ -109,12 +111,120 @@ func (m *PostReceiveResponse) String() string { return proto.CompactT func (*PostReceiveResponse) ProtoMessage() {} func (*PostReceiveResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +type CommitDiffRequest struct { + Repository *Repository `protobuf:"bytes,1,opt,name=repository" json:"repository,omitempty"` + LeftCommitId string `protobuf:"bytes,2,opt,name=left_commit_id,json=leftCommitId" json:"left_commit_id,omitempty"` + RightCommitId string `protobuf:"bytes,3,opt,name=right_commit_id,json=rightCommitId" json:"right_commit_id,omitempty"` +} + +func (m *CommitDiffRequest) Reset() { *m = CommitDiffRequest{} } +func (m *CommitDiffRequest) String() string { return proto.CompactTextString(m) } +func (*CommitDiffRequest) ProtoMessage() {} +func (*CommitDiffRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *CommitDiffRequest) GetRepository() *Repository { + if m != nil { + return m.Repository + } + return nil +} + +func (m *CommitDiffRequest) GetLeftCommitId() string { + if m != nil { + return m.LeftCommitId + } + return "" +} + +func (m *CommitDiffRequest) GetRightCommitId() string { + if m != nil { + return m.RightCommitId + } + return "" +} + +// A CommitDiffResponse corresponds to a single changed file in a commit. +type CommitDiffResponse struct { + FromPath []byte `protobuf:"bytes,1,opt,name=from_path,json=fromPath,proto3" json:"from_path,omitempty"` + ToPath []byte `protobuf:"bytes,2,opt,name=to_path,json=toPath,proto3" json:"to_path,omitempty"` + // Blob ID as returned via `git diff --full-index` + FromId string `protobuf:"bytes,3,opt,name=from_id,json=fromId" json:"from_id,omitempty"` + ToId string `protobuf:"bytes,4,opt,name=to_id,json=toId" json:"to_id,omitempty"` + OldMode int32 `protobuf:"varint,5,opt,name=old_mode,json=oldMode" json:"old_mode,omitempty"` + NewMode int32 `protobuf:"varint,6,opt,name=new_mode,json=newMode" json:"new_mode,omitempty"` + Binary bool `protobuf:"varint,7,opt,name=binary" json:"binary,omitempty"` + RawChunks [][]byte `protobuf:"bytes,8,rep,name=raw_chunks,json=rawChunks,proto3" json:"raw_chunks,omitempty"` +} + +func (m *CommitDiffResponse) Reset() { *m = CommitDiffResponse{} } +func (m *CommitDiffResponse) String() string { return proto.CompactTextString(m) } +func (*CommitDiffResponse) ProtoMessage() {} +func (*CommitDiffResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +func (m *CommitDiffResponse) GetFromPath() []byte { + if m != nil { + return m.FromPath + } + return nil +} + +func (m *CommitDiffResponse) GetToPath() []byte { + if m != nil { + return m.ToPath + } + return nil +} + +func (m *CommitDiffResponse) GetFromId() string { + if m != nil { + return m.FromId + } + return "" +} + +func (m *CommitDiffResponse) GetToId() string { + if m != nil { + return m.ToId + } + return "" +} + +func (m *CommitDiffResponse) GetOldMode() int32 { + if m != nil { + return m.OldMode + } + return 0 +} + +func (m *CommitDiffResponse) GetNewMode() int32 { + if m != nil { + return m.NewMode + } + return 0 +} + +func (m *CommitDiffResponse) GetBinary() bool { + if m != nil { + return m.Binary + } + return false +} + +func (m *CommitDiffResponse) GetRawChunks() [][]byte { + if m != nil { + return m.RawChunks + } + return nil +} + func init() { proto.RegisterType((*InfoRefsRequest)(nil), "gitaly.InfoRefsRequest") proto.RegisterType((*InfoRefsResponse)(nil), "gitaly.InfoRefsResponse") proto.RegisterType((*Repository)(nil), "gitaly.Repository") proto.RegisterType((*PostReceiveRequest)(nil), "gitaly.PostReceiveRequest") proto.RegisterType((*PostReceiveResponse)(nil), "gitaly.PostReceiveResponse") + proto.RegisterType((*CommitDiffRequest)(nil), "gitaly.CommitDiffRequest") + proto.RegisterType((*CommitDiffResponse)(nil), "gitaly.CommitDiffResponse") } // Reference imports to suppress errors if they are not otherwise used. @@ -344,24 +454,130 @@ var _Notifications_serviceDesc = grpc.ServiceDesc{ Metadata: "gitaly.proto", } +// Client API for Diff service + +type DiffClient interface { + // Returns stream of CommitDiffResponse: 1 per changed file + CommitDiff(ctx context.Context, in *CommitDiffRequest, opts ...grpc.CallOption) (Diff_CommitDiffClient, error) +} + +type diffClient struct { + cc *grpc.ClientConn +} + +func NewDiffClient(cc *grpc.ClientConn) DiffClient { + return &diffClient{cc} +} + +func (c *diffClient) CommitDiff(ctx context.Context, in *CommitDiffRequest, opts ...grpc.CallOption) (Diff_CommitDiffClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Diff_serviceDesc.Streams[0], c.cc, "/gitaly.Diff/CommitDiff", opts...) + if err != nil { + return nil, err + } + x := &diffCommitDiffClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Diff_CommitDiffClient interface { + Recv() (*CommitDiffResponse, error) + grpc.ClientStream +} + +type diffCommitDiffClient struct { + grpc.ClientStream +} + +func (x *diffCommitDiffClient) Recv() (*CommitDiffResponse, error) { + m := new(CommitDiffResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for Diff service + +type DiffServer interface { + // Returns stream of CommitDiffResponse: 1 per changed file + CommitDiff(*CommitDiffRequest, Diff_CommitDiffServer) error +} + +func RegisterDiffServer(s *grpc.Server, srv DiffServer) { + s.RegisterService(&_Diff_serviceDesc, srv) +} + +func _Diff_CommitDiff_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(CommitDiffRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(DiffServer).CommitDiff(m, &diffCommitDiffServer{stream}) +} + +type Diff_CommitDiffServer interface { + Send(*CommitDiffResponse) error + grpc.ServerStream +} + +type diffCommitDiffServer struct { + grpc.ServerStream +} + +func (x *diffCommitDiffServer) Send(m *CommitDiffResponse) error { + return x.ServerStream.SendMsg(m) +} + +var _Diff_serviceDesc = grpc.ServiceDesc{ + ServiceName: "gitaly.Diff", + HandlerType: (*DiffServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "CommitDiff", + Handler: _Diff_CommitDiff_Handler, + ServerStreams: true, + }, + }, + Metadata: "gitaly.proto", +} + func init() { proto.RegisterFile("gitaly.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 256 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x92, 0xc1, 0x4a, 0xc3, 0x40, - 0x10, 0x86, 0x0d, 0x48, 0xa1, 0xd3, 0x8a, 0x32, 0x45, 0x2c, 0xf1, 0x52, 0xf6, 0x20, 0x9e, 0x8a, - 0xc4, 0x67, 0x10, 0x22, 0x8a, 0x84, 0xb5, 0x1e, 0x3c, 0xae, 0xe9, 0x44, 0x17, 0x6b, 0x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0xec, 0xde, 0x9e, 0x57, 0x7a, 0xfc, 0xaf, 0x16, 0xe1, 0x0f, 0x83, 0xb0, - 0x04, 0xe7, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x86, 0x0b, 0x65, 0xc1, 0x14, 0x02, 0x00, 0x00, + // 463 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x53, 0x5d, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0x6d, 0xe2, 0x24, 0x53, 0x97, 0xc2, 0x44, 0x50, 0xd7, 0x15, 0x92, 0x65, 0xa1, 0x2a, + 0x4f, 0x15, 0x32, 0x47, 0x28, 0x88, 0x44, 0xfc, 0x45, 0x4b, 0x79, 0xe0, 0xc9, 0xda, 0x7a, 0xd7, + 0xcd, 0xaa, 0xb6, 0xc7, 0xd8, 0x5b, 0xa2, 0x1c, 0x84, 0x2b, 0x70, 0x33, 0xee, 0x81, 0xbc, 0x8e, + 0xe3, 0xd0, 0xf4, 0x2d, 0x6f, 0x3b, 0xdf, 0xf7, 0xcd, 0x37, 0xe3, 0x99, 0x31, 0x38, 0xb7, 0x4a, + 0xf3, 0x74, 0x75, 0x59, 0x94, 0xa4, 0x09, 0xed, 0x26, 0x0a, 0xde, 0xc3, 0xc9, 0x2c, 0x4f, 0x88, + 0xc9, 0xa4, 0x62, 0xf2, 0xe7, 0xbd, 0xac, 0x34, 0x86, 0x00, 0xa5, 0x2c, 0xa8, 0x52, 0x9a, 0xca, + 0x95, 0x6b, 0xf9, 0xd6, 0xe4, 0x28, 0xc4, 0xcb, 0x75, 0x36, 0xdb, 0x30, 0x6c, 0x4b, 0x15, 0x5c, + 0xc0, 0xb3, 0xce, 0xa6, 0x2a, 0x28, 0xaf, 0x24, 0x22, 0xf4, 0x04, 0xd7, 0xdc, 0x38, 0x38, 0xcc, + 0xbc, 0x03, 0x1f, 0xa0, 0x73, 0xa8, 0x15, 0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3e, 0xbf, 0xab, 0xdc, + 0xa1, 0x7f, 0x38, 0x71, 0xd8, 0xa8, 0xe4, 0xcb, 0x2b, 0x03, 0x84, 0x7f, 0x2c, 0x18, 0x7d, 0xcb, + 0x78, 0xa9, 0xa7, 0xd7, 0xd7, 0x73, 0xfc, 0x08, 0xd8, 0x1e, 0xce, 0xf7, 0x22, 0x25, 0x2e, 0xe6, + 0x3c, 0xbe, 0xc3, 0xd3, 0x76, 0xf2, 0x0f, 0x6e, 0xd3, 0x73, 0x77, 0x89, 0xf5, 0x5a, 0x9f, 0xbc, + 0xb1, 0xf0, 0x13, 0x8c, 0x3b, 0xdc, 0x6c, 0x7d, 0x0f, 0xb7, 0xf0, 0x07, 0x1c, 0x7f, 0x21, 0xad, + 0x12, 0x15, 0x73, 0xad, 0x28, 0xaf, 0x70, 0x0a, 0x47, 0x5b, 0x07, 0x85, 0x5e, 0x9b, 0xbd, 0x7b, + 0xaf, 0xde, 0xf9, 0xa3, 0x5c, 0x6b, 0x1e, 0x7e, 0x85, 0x5e, 0xbd, 0x64, 0xfc, 0x00, 0xd0, 0xad, + 0x1c, 0xcf, 0xda, 0xa4, 0x9d, 0xf3, 0xf4, 0xbc, 0xc7, 0xa8, 0xae, 0xd7, 0x1b, 0xdb, 0xfc, 0xd5, + 0x6f, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x12, 0xbc, 0x0a, 0xd3, 0xe5, 0x03, 0x00, 0x00, } diff --git a/ruby/lib/gitaly/gitaly_pb.rb b/ruby/lib/gitaly/gitaly_pb.rb index 9a040343e7c37ba9b3261b348d4cc61684f54cfc..f92dc5443a3fb57b53d0d858ab0080f829df968d 100644 --- a/ruby/lib/gitaly/gitaly_pb.rb +++ b/ruby/lib/gitaly/gitaly_pb.rb @@ -18,6 +18,21 @@ Google::Protobuf::DescriptorPool.generated_pool.build do end add_message "gitaly.PostReceiveResponse" do end + add_message "gitaly.CommitDiffRequest" do + optional :repository, :message, 1, "gitaly.Repository" + optional :left_commit_id, :string, 2 + optional :right_commit_id, :string, 3 + end + add_message "gitaly.CommitDiffResponse" do + optional :from_path, :bytes, 1 + optional :to_path, :bytes, 2 + optional :from_id, :string, 3 + optional :to_id, :string, 4 + optional :old_mode, :int32, 5 + optional :new_mode, :int32, 6 + optional :binary, :bool, 7 + repeated :raw_chunks, :bytes, 8 + end end module Gitaly @@ -26,4 +41,6 @@ module Gitaly Repository = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.Repository").msgclass PostReceiveRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostReceiveRequest").msgclass PostReceiveResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostReceiveResponse").msgclass + CommitDiffRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.CommitDiffRequest").msgclass + CommitDiffResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.CommitDiffResponse").msgclass end diff --git a/ruby/lib/gitaly/gitaly_services_pb.rb b/ruby/lib/gitaly/gitaly_services_pb.rb index 52872cd371fb22347d8f453146b227728d88d70b..b11fe0b1c54e9faae65372a50d667af4bbe0c619 100644 --- a/ruby/lib/gitaly/gitaly_services_pb.rb +++ b/ruby/lib/gitaly/gitaly_services_pb.rb @@ -35,6 +35,21 @@ module Gitaly rpc :PostReceive, PostReceiveRequest, PostReceiveResponse end + Stub = Service.rpc_stub_class + end + module Diff + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'gitaly.Diff' + + # Returns stream of CommitDiffResponse: 1 per changed file + rpc :CommitDiff, CommitDiffRequest, stream(CommitDiffResponse) + end + Stub = Service.rpc_stub_class end end