diff --git a/gitrpc/commit.go b/gitrpc/commit.go index b882909b8..f8c3bc680 100644 --- a/gitrpc/commit.go +++ b/gitrpc/commit.go @@ -101,3 +101,76 @@ func (c *Client) ListCommits(ctx context.Context, params *ListCommitsParams) (*L return output, nil } + +type GetCommitDivergencesParams struct { + // RepoUID is the uid of the git repository + RepoUID string + MaxCount int32 + Requests []CommitDivergenceRequest +} + +type GetCommitDivergencesOutput struct { + Divergences []CommitDivergence +} + +// CommitDivergenceRequest contains the refs for which the converging commits should be counted. +type CommitDivergenceRequest struct { + // From is the ref from which the counting of the diverging commits starts. + From string + // To is the ref at which the counting of the diverging commits ends. + To string +} + +// CommitDivergence contains the information of the count of converging commits between two refs. +type CommitDivergence struct { + // Ahead is the count of commits the 'From' ref is ahead of the 'To' ref. + Ahead int32 + // Behind is the count of commits the 'From' ref is behind the 'To' ref. + Behind int32 +} + +func (c *Client) GetCommitDivergences(ctx context.Context, + params *GetCommitDivergencesParams) (*GetCommitDivergencesOutput, error) { + if params == nil { + return nil, ErrNoParamsProvided + } + + // build rpc request + req := &rpc.GetCommitDivergencesRequest{ + RepoUid: params.RepoUID, + MaxCount: params.MaxCount, + Requests: make([]*rpc.CommitDivergenceRequest, len(params.Requests)), + } + for i := range params.Requests { + req.Requests[i] = &rpc.CommitDivergenceRequest{ + From: params.Requests[i].From, + To: params.Requests[i].To, + } + } + resp, err := c.repoService.GetCommitDivergences(ctx, req) + if err != nil { + return nil, processRPCErrorf(err, "failed to get diverging commits from server") + } + + divergences := resp.GetDivergences() + if divergences == nil { + return nil, fmt.Errorf("server response divergences were nil") + } + + // build output + output := &GetCommitDivergencesOutput{ + Divergences: make([]CommitDivergence, len(divergences)), + } + for i := range divergences { + if divergences[i] == nil { + return nil, fmt.Errorf("server returned nil divergence") + } + + output.Divergences[i] = CommitDivergence{ + Ahead: divergences[i].Ahead, + Behind: divergences[i].Behind, + } + } + + return output, nil +} diff --git a/gitrpc/interface.go b/gitrpc/interface.go index 3500d62f5..0790d04f6 100644 --- a/gitrpc/interface.go +++ b/gitrpc/interface.go @@ -20,6 +20,7 @@ type Interface interface { DeleteBranch(ctx context.Context, params *DeleteBranchParams) error ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error) ListCommitTags(ctx context.Context, params *ListCommitTagsParams) (*ListCommitTagsOutput, error) + GetCommitDivergences(ctx context.Context, params *GetCommitDivergencesParams) (*GetCommitDivergencesOutput, error) /* * Git Cli Service diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index 365344752..fe102d3b3 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -7,7 +7,10 @@ package gitea import ( "bytes" "context" + "errors" "fmt" + "strconv" + "strings" gitea "code.gitea.io/gitea/modules/git" "github.com/harness/gitness/gitrpc/internal/types" @@ -162,3 +165,81 @@ func (g Adapter) GetCommits(ctx context.Context, repoPath string, refs []string) return commits, nil } + +// GetCommitDivergences returns the count of the diverging commits for all branch pairs. +// IMPORTANT: If a max is provided it limits the overal count of diverging commits +// (max 10 could lead to (0, 10) while it's actually (2, 12)). +func (g Adapter) GetCommitDivergences(ctx context.Context, repoPath string, + requests []types.CommitDivergenceRequest, max int32) ([]types.CommitDivergence, error) { + var err error + res := make([]types.CommitDivergence, len(requests)) + for i, req := range requests { + res[i], err = g.getCommitDivergence(ctx, repoPath, req, max) + if errors.Is(err, types.ErrNotFound) { + res[i] = types.CommitDivergence{Ahead: -1, Behind: -1} + continue + } + if err != nil { + return nil, err + } + } + + return res, nil +} + +// getCommitDivergence returns the count of diverging commits for a pair of branches. +// IMPORTANT: If a max is provided it limits the overal count of diverging commits +// (max 10 could lead to (0, 10) while it's actually (2, 12)). +// NOTE: Gitea implementation makes two git cli calls, but it can be done with one +// (downside is the max behavior explained above). +func (g Adapter) getCommitDivergence(ctx context.Context, repoPath string, + req types.CommitDivergenceRequest, max int32) (types.CommitDivergence, error) { + // prepare args + args := []string{ + "rev-list", + "--count", + "--left-right", + } + // limit count if requested. + if max > 0 { + args = append(args, "--max-count") + args = append(args, fmt.Sprint(max)) + } + // add query to get commits without shared base commits + args = append(args, fmt.Sprintf("%s...%s", req.From, req.To)) + + var err error + cmd := gitea.NewCommand(ctx, args...) + stdOut, stdErr, err := cmd.RunStdString(&gitea.RunOpts{Dir: repoPath}) + if err != nil { + return types.CommitDivergence{}, + processGiteaErrorf(err, "git rev-list failed for '%s...%s' (stdErr: '%s')", req.From, req.To, stdErr) + } + + // parse output, e.g.: `1 2\n` + rawLeft, rawRight, ok := strings.Cut(stdOut, "\t") + if !ok { + return types.CommitDivergence{}, fmt.Errorf("git rev-list returned unexpected output '%s'", stdOut) + } + + // trim any unnecessary characters + rawLeft = strings.TrimRight(rawLeft, " \t") + rawRight = strings.TrimRight(rawRight, " \t\n") + + // parse numbers + left, err := strconv.ParseInt(rawLeft, 10, 32) + if err != nil { + return types.CommitDivergence{}, + fmt.Errorf("failed to parse git rev-list output for ahead '%s' (full: '%s')): %w", rawLeft, stdOut, err) + } + right, err := strconv.ParseInt(rawRight, 10, 32) + if err != nil { + return types.CommitDivergence{}, + fmt.Errorf("failed to parse git rev-list output for behind '%s' (full: '%s')): %w", rawRight, stdOut, err) + } + + return types.CommitDivergence{ + Ahead: int32(left), + Behind: int32(right), + }, nil +} diff --git a/gitrpc/internal/gitea/mapping.go b/gitrpc/internal/gitea/mapping.go index fb2f7d33f..9e7c06884 100644 --- a/gitrpc/internal/gitea/mapping.go +++ b/gitrpc/internal/gitea/mapping.go @@ -53,6 +53,11 @@ func mapGiteaRunStdError(err gitea.RunStdError, fallback error) error { // exit status 1 - error: branch 'mybranch' not found. case err.IsExitCode(1) && strings.Contains(err.Stderr(), "not found"): return types.ErrNotFound + + // exit status 128 - fatal: ambiguous argument 'branch1...branch2': unknown revision or path not in the working tree. + case err.IsExitCode(128) && strings.Contains(err.Stderr(), "unknown revision"): + return types.ErrNotFound + default: return fallback } diff --git a/gitrpc/internal/service/commit.go b/gitrpc/internal/service/commit.go index a197fd6fd..82ae8bcb1 100644 --- a/gitrpc/internal/service/commit.go +++ b/gitrpc/internal/service/commit.go @@ -7,6 +7,7 @@ package service import ( "context" + "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" "github.com/rs/zerolog/log" "google.golang.org/grpc/codes" @@ -66,3 +67,42 @@ func (s RepositoryService) getLatestCommit(ctx context.Context, repoPath string, return mapGitCommit(gitCommit) } + +func (s RepositoryService) GetCommitDivergences(ctx context.Context, + request *rpc.GetCommitDivergencesRequest) (*rpc.GetCommitDivergencesResponse, error) { + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + + // map to gitea requests + requests := request.GetRequests() + if requests == nil { + return nil, status.Error(codes.InvalidArgument, "requests is nil") + } + giteaDivergenceRequests := make([]types.CommitDivergenceRequest, len(requests)) + for i := range requests { + if requests[i] == nil { + return nil, status.Errorf(codes.InvalidArgument, "requests[%d] is nil", i) + } + giteaDivergenceRequests[i].From = requests[i].From + giteaDivergenceRequests[i].To = requests[i].To + } + + // call gitea + giteaDivergenceResponses, err := s.adapter.GetCommitDivergences(ctx, repoPath, + giteaDivergenceRequests, request.GetMaxCount()) + if err != nil { + return nil, processGitErrorf(err, "failed to get diverging commits") + } + + // map to rpc response + response := &rpc.GetCommitDivergencesResponse{ + Divergences: make([]*rpc.CommitDivergence, len(giteaDivergenceResponses)), + } + for i := range giteaDivergenceResponses { + response.Divergences[i] = &rpc.CommitDivergence{ + Ahead: giteaDivergenceResponses[i].Ahead, + Behind: giteaDivergenceResponses[i].Behind, + } + } + + return response, nil +} diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index 9a0dac139..9ba1361ba 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -34,4 +34,6 @@ type GitAdapter interface { GetAnnotatedTags(ctx context.Context, repoPath string, shas []string) ([]types.Tag, error) CreateBranch(ctx context.Context, repoPath string, branchName string, target string) (*types.Branch, error) DeleteBranch(ctx context.Context, repoPath string, branchName string, force bool) error + GetCommitDivergences(ctx context.Context, repoPath string, + requests []types.CommitDivergenceRequest, max int32) ([]types.CommitDivergence, error) } diff --git a/gitrpc/internal/types/types.go b/gitrpc/internal/types/types.go index 9fe7bea54..2e15ba871 100644 --- a/gitrpc/internal/types/types.go +++ b/gitrpc/internal/types/types.go @@ -222,3 +222,19 @@ type Blob struct { // NOTE: can be only partial Content - compare len(.Content) with .Size Content []byte } + +// CommitDivergenceRequest contains the refs for which the converging commits should be counted. +type CommitDivergenceRequest struct { + // From is the ref from which the counting of the diverging commits starts. + From string + // To is the ref at which the counting of the diverging commits ends. + To string +} + +// CommitDivergence contains the information of the count of converging commits between two refs. +type CommitDivergence struct { + // Ahead is the count of commits the 'From' ref is ahead of the 'To' ref. + Ahead int32 + // Behind is the count of commits the 'From' ref is behind the 'To' ref. + Behind int32 +} diff --git a/gitrpc/proto/repo.proto b/gitrpc/proto/repo.proto index 5d8374994..9756026ef 100644 --- a/gitrpc/proto/repo.proto +++ b/gitrpc/proto/repo.proto @@ -13,6 +13,7 @@ service RepositoryService { rpc GetSubmodule(GetSubmoduleRequest) returns (GetSubmoduleResponse); rpc GetBlob(GetBlobRequest) returns (GetBlobResponse); rpc ListCommits(ListCommitsRequest) returns (stream ListCommitsResponse); + rpc GetCommitDivergences(GetCommitDivergencesRequest) returns (GetCommitDivergencesResponse); } message CreateRepositoryRequest { @@ -123,4 +124,25 @@ message GetSubmoduleResponse { message Submodule { string name = 1; string url = 2; +} + +message GetCommitDivergencesRequest { + string repo_uid = 1; + int32 max_count = 2; + repeated CommitDivergenceRequest requests = 3; +} + +message CommitDivergenceRequest { + string from = 1; + string to = 2; +} + + +message GetCommitDivergencesResponse { + repeated CommitDivergence divergences = 1; +} + +message CommitDivergence { + int32 ahead = 1; + int32 behind = 2; } \ No newline at end of file diff --git a/gitrpc/rpc/repo.pb.go b/gitrpc/rpc/repo.pb.go index 4b3d690b3..650c8f0d0 100644 --- a/gitrpc/rpc/repo.pb.go +++ b/gitrpc/rpc/repo.pb.go @@ -1172,6 +1172,226 @@ func (x *Submodule) GetUrl() string { return "" } +type GetCommitDivergencesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` + MaxCount int32 `protobuf:"varint,2,opt,name=max_count,json=maxCount,proto3" json:"max_count,omitempty"` + Requests []*CommitDivergenceRequest `protobuf:"bytes,3,rep,name=requests,proto3" json:"requests,omitempty"` +} + +func (x *GetCommitDivergencesRequest) Reset() { + *x = GetCommitDivergencesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCommitDivergencesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCommitDivergencesRequest) ProtoMessage() {} + +func (x *GetCommitDivergencesRequest) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[17] + 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 GetCommitDivergencesRequest.ProtoReflect.Descriptor instead. +func (*GetCommitDivergencesRequest) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{17} +} + +func (x *GetCommitDivergencesRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +func (x *GetCommitDivergencesRequest) GetMaxCount() int32 { + if x != nil { + return x.MaxCount + } + return 0 +} + +func (x *GetCommitDivergencesRequest) GetRequests() []*CommitDivergenceRequest { + if x != nil { + return x.Requests + } + return nil +} + +type CommitDivergenceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` +} + +func (x *CommitDivergenceRequest) Reset() { + *x = CommitDivergenceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitDivergenceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitDivergenceRequest) ProtoMessage() {} + +func (x *CommitDivergenceRequest) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[18] + 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 CommitDivergenceRequest.ProtoReflect.Descriptor instead. +func (*CommitDivergenceRequest) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{18} +} + +func (x *CommitDivergenceRequest) GetFrom() string { + if x != nil { + return x.From + } + return "" +} + +func (x *CommitDivergenceRequest) GetTo() string { + if x != nil { + return x.To + } + return "" +} + +type GetCommitDivergencesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Divergences []*CommitDivergence `protobuf:"bytes,1,rep,name=divergences,proto3" json:"divergences,omitempty"` +} + +func (x *GetCommitDivergencesResponse) Reset() { + *x = GetCommitDivergencesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCommitDivergencesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCommitDivergencesResponse) ProtoMessage() {} + +func (x *GetCommitDivergencesResponse) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[19] + 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 GetCommitDivergencesResponse.ProtoReflect.Descriptor instead. +func (*GetCommitDivergencesResponse) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{19} +} + +func (x *GetCommitDivergencesResponse) GetDivergences() []*CommitDivergence { + if x != nil { + return x.Divergences + } + return nil +} + +type CommitDivergence struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ahead int32 `protobuf:"varint,1,opt,name=ahead,proto3" json:"ahead,omitempty"` + Behind int32 `protobuf:"varint,2,opt,name=behind,proto3" json:"behind,omitempty"` +} + +func (x *CommitDivergence) Reset() { + *x = CommitDivergence{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitDivergence) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitDivergence) ProtoMessage() {} + +func (x *CommitDivergence) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[20] + 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 CommitDivergence.ProtoReflect.Descriptor instead. +func (*CommitDivergence) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{20} +} + +func (x *CommitDivergence) GetAhead() int32 { + if x != nil { + return x.Ahead + } + return 0 +} + +func (x *CommitDivergence) GetBehind() int32 { + if x != nil { + return x.Behind + } + return 0 +} + var File_repo_proto protoreflect.FileDescriptor var file_repo_proto_rawDesc = []byte{ @@ -1281,50 +1501,79 @@ var file_repo_proto_rawDesc = []byte{ 0x09, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 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, 0xb1, 0x03, 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, 0x34, 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, 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, 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, + 0x22, 0x8f, 0x01, 0x0a, 0x1b, 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, + 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6f, 0x55, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6d, + 0x61, 0x78, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x22, 0x3d, 0x0a, 0x17, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, + 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, + 0x6f, 0x22, 0x57, 0x0a, 0x1c, 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, 0x37, 0x0a, 0x0b, 0x64, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0b, 0x64, + 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x40, 0x0a, 0x10, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x61, 0x68, 0x65, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x61, + 0x68, 0x65, 0x61, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x65, 0x68, 0x69, 0x6e, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x65, 0x68, 0x69, 0x6e, 0x64, 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, 0x8e, 0x04, 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, 0x34, + 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, 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, 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, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 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 ( @@ -1340,7 +1589,7 @@ func file_repo_proto_rawDescGZIP() []byte { } var file_repo_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_repo_proto_goTypes = []interface{}{ (TreeNodeType)(0), // 0: rpc.TreeNodeType (TreeNodeMode)(0), // 1: rpc.TreeNodeMode @@ -1361,39 +1610,47 @@ var file_repo_proto_goTypes = []interface{}{ (*GetSubmoduleRequest)(nil), // 16: rpc.GetSubmoduleRequest (*GetSubmoduleResponse)(nil), // 17: rpc.GetSubmoduleResponse (*Submodule)(nil), // 18: rpc.Submodule - (*FileUpload)(nil), // 19: rpc.FileUpload - (*Commit)(nil), // 20: rpc.Commit + (*GetCommitDivergencesRequest)(nil), // 19: rpc.GetCommitDivergencesRequest + (*CommitDivergenceRequest)(nil), // 20: rpc.CommitDivergenceRequest + (*GetCommitDivergencesResponse)(nil), // 21: rpc.GetCommitDivergencesResponse + (*CommitDivergence)(nil), // 22: rpc.CommitDivergence + (*FileUpload)(nil), // 23: rpc.FileUpload + (*Commit)(nil), // 24: rpc.Commit } var file_repo_proto_depIdxs = []int32{ 3, // 0: rpc.CreateRepositoryRequest.header:type_name -> rpc.CreateRepositoryRequestHeader - 19, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload + 23, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload 9, // 2: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode - 20, // 3: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit + 24, // 3: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit 9, // 4: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode - 20, // 5: rpc.ListTreeNodesResponse.commit:type_name -> rpc.Commit + 24, // 5: rpc.ListTreeNodesResponse.commit:type_name -> rpc.Commit 0, // 6: rpc.TreeNode.type:type_name -> rpc.TreeNodeType 1, // 7: rpc.TreeNode.mode:type_name -> rpc.TreeNodeMode 12, // 8: rpc.ListCommitsResponse.header:type_name -> rpc.ListCommitsResponseHeader - 20, // 9: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit + 24, // 9: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit 15, // 10: rpc.GetBlobResponse.blob:type_name -> rpc.Blob 18, // 11: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule - 2, // 12: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest - 5, // 13: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest - 7, // 14: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest - 16, // 15: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest - 13, // 16: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest - 10, // 17: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest - 4, // 18: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse - 6, // 19: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse - 8, // 20: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse - 17, // 21: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse - 14, // 22: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse - 11, // 23: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse - 18, // [18:24] is the sub-list for method output_type - 12, // [12:18] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 20, // 12: rpc.GetCommitDivergencesRequest.requests:type_name -> rpc.CommitDivergenceRequest + 22, // 13: rpc.GetCommitDivergencesResponse.divergences:type_name -> rpc.CommitDivergence + 2, // 14: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest + 5, // 15: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest + 7, // 16: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest + 16, // 17: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest + 13, // 18: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest + 10, // 19: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest + 19, // 20: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest + 4, // 21: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse + 6, // 22: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse + 8, // 23: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse + 17, // 24: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse + 14, // 25: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse + 11, // 26: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse + 21, // 27: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse + 21, // [21:28] is the sub-list for method output_type + 14, // [14:21] 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 } func init() { file_repo_proto_init() } @@ -1607,6 +1864,54 @@ func file_repo_proto_init() { return nil } } + file_repo_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCommitDivergencesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_repo_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitDivergenceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_repo_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCommitDivergencesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_repo_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitDivergence); 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), @@ -1622,7 +1927,7 @@ func file_repo_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_repo_proto_rawDesc, NumEnums: 2, - NumMessages: 17, + NumMessages: 21, NumExtensions: 0, NumServices: 1, }, diff --git a/gitrpc/rpc/repo_grpc.pb.go b/gitrpc/rpc/repo_grpc.pb.go index 607231308..e39ccb925 100644 --- a/gitrpc/rpc/repo_grpc.pb.go +++ b/gitrpc/rpc/repo_grpc.pb.go @@ -28,6 +28,7 @@ type RepositoryServiceClient interface { GetSubmodule(ctx context.Context, in *GetSubmoduleRequest, opts ...grpc.CallOption) (*GetSubmoduleResponse, error) GetBlob(ctx context.Context, in *GetBlobRequest, opts ...grpc.CallOption) (*GetBlobResponse, error) ListCommits(ctx context.Context, in *ListCommitsRequest, opts ...grpc.CallOption) (RepositoryService_ListCommitsClient, error) + GetCommitDivergences(ctx context.Context, in *GetCommitDivergencesRequest, opts ...grpc.CallOption) (*GetCommitDivergencesResponse, error) } type repositoryServiceClient struct { @@ -163,6 +164,15 @@ func (x *repositoryServiceListCommitsClient) Recv() (*ListCommitsResponse, error return m, nil } +func (c *repositoryServiceClient) GetCommitDivergences(ctx context.Context, in *GetCommitDivergencesRequest, opts ...grpc.CallOption) (*GetCommitDivergencesResponse, error) { + out := new(GetCommitDivergencesResponse) + err := c.cc.Invoke(ctx, "/rpc.RepositoryService/GetCommitDivergences", 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 @@ -173,6 +183,7 @@ type RepositoryServiceServer interface { GetSubmodule(context.Context, *GetSubmoduleRequest) (*GetSubmoduleResponse, error) GetBlob(context.Context, *GetBlobRequest) (*GetBlobResponse, error) ListCommits(*ListCommitsRequest, RepositoryService_ListCommitsServer) error + GetCommitDivergences(context.Context, *GetCommitDivergencesRequest) (*GetCommitDivergencesResponse, error) mustEmbedUnimplementedRepositoryServiceServer() } @@ -198,6 +209,9 @@ func (UnimplementedRepositoryServiceServer) GetBlob(context.Context, *GetBlobReq func (UnimplementedRepositoryServiceServer) ListCommits(*ListCommitsRequest, RepositoryService_ListCommitsServer) error { return status.Errorf(codes.Unimplemented, "method ListCommits not implemented") } +func (UnimplementedRepositoryServiceServer) GetCommitDivergences(context.Context, *GetCommitDivergencesRequest) (*GetCommitDivergencesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCommitDivergences not implemented") +} func (UnimplementedRepositoryServiceServer) mustEmbedUnimplementedRepositoryServiceServer() {} // UnsafeRepositoryServiceServer may be embedded to opt out of forward compatibility for this service. @@ -333,6 +347,24 @@ func (x *repositoryServiceListCommitsServer) Send(m *ListCommitsResponse) error return x.ServerStream.SendMsg(m) } +func _RepositoryService_GetCommitDivergences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCommitDivergencesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RepositoryServiceServer).GetCommitDivergences(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.RepositoryService/GetCommitDivergences", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RepositoryServiceServer).GetCommitDivergences(ctx, req.(*GetCommitDivergencesRequest)) + } + 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) @@ -352,6 +384,10 @@ var RepositoryService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetBlob", Handler: _RepositoryService_GetBlob_Handler, }, + { + MethodName: "GetCommitDivergences", + Handler: _RepositoryService_GetCommitDivergences_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/internal/api/controller/repo/get_commit_divergences.go b/internal/api/controller/repo/get_commit_divergences.go new file mode 100644 index 000000000..cd497ea4d --- /dev/null +++ b/internal/api/controller/repo/get_commit_divergences.go @@ -0,0 +1,95 @@ +// 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 repo + +import ( + "context" + + "github.com/harness/gitness/gitrpc" + apiauth "github.com/harness/gitness/internal/api/auth" + "github.com/harness/gitness/internal/api/request" + "github.com/harness/gitness/internal/api/usererror" + "github.com/harness/gitness/internal/auth" + "github.com/harness/gitness/types/enum" +) + +type GetCommitDivergencesInput struct { + // MaxCount restricts the maximum number of diverging commits that are counted. + // IMPORTANT: This restricts the total commit count, so a (5, 18) restricted to 10 will return (0, 10) + MaxCount int32 `json:"maxCount"` + Requests []CommitDivergenceRequest `json:"requests"` +} + +// CommitDivergenceRequest contains the refs for which the converging commits should be counted. +type CommitDivergenceRequest struct { + // From is the ref from which the counting of the diverging commits starts. + From string `json:"from"` + // To is the ref at which the counting of the diverging commits ends. + // If the value is empty the divergence is caluclated to the default branch of the repo. + To string `json:"to"` +} + +// CommitDivergence contains the information of the count of converging commits between two refs. +type CommitDivergence struct { + // Ahead is the count of commits the 'From' ref is ahead of the 'To' ref. + Ahead int32 `json:"ahead"` + // Behind is the count of commits the 'From' ref is behind the 'To' ref. + Behind int32 `json:"behind"` +} + +/* +* GetCommitDivergences returns the commit divergences between reference pairs. + */ +func (c *Controller) GetCommitDivergences(ctx context.Context, session *auth.Session, + repoRef string, in *GetCommitDivergencesInput) ([]CommitDivergence, error) { + repo, err := c.repoStore.FindRepoFromRef(ctx, repoRef) + if err != nil { + return nil, err + } + + if err = apiauth.CheckRepo(ctx, c.authorizer, session, repo, enum.PermissionRepoView, false); err != nil { + return nil, err + } + + // if no requests were provided return an empty list + if in == nil || len(in.Requests) == 0 { + return []CommitDivergence{}, nil + } + + // if num of requests > page max return error + if len(in.Requests) > request.PerPageMax { + return nil, usererror.ErrRequestTooLarge + } + + // map to rpc params + options := &gitrpc.GetCommitDivergencesParams{ + RepoUID: repo.GitUID, + MaxCount: in.MaxCount, + Requests: make([]gitrpc.CommitDivergenceRequest, len(in.Requests)), + } + for i := range in.Requests { + options.Requests[i].From = in.Requests[i].From + options.Requests[i].To = in.Requests[i].To + // backfil default branch if no 'to' was provided + if len(options.Requests[i].To) == 0 { + options.Requests[i].To = repo.DefaultBranch + } + } + + // TODO: We should cache the responses as times can reach multiple seconds + rpcOutput, err := c.gitRPCClient.GetCommitDivergences(ctx, options) + if err != nil { + return nil, err + } + + // map to output type + divergences := make([]CommitDivergence, len(rpcOutput.Divergences)) + for i := range rpcOutput.Divergences { + divergences[i].Ahead = rpcOutput.Divergences[i].Ahead + divergences[i].Behind = rpcOutput.Divergences[i].Behind + } + + return divergences, nil +} diff --git a/internal/api/handler/repo/calculate_commit_divergence.go b/internal/api/handler/repo/calculate_commit_divergence.go new file mode 100644 index 000000000..04f124e08 --- /dev/null +++ b/internal/api/handler/repo/calculate_commit_divergence.go @@ -0,0 +1,44 @@ +// 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 repo + +import ( + "encoding/json" + "net/http" + + "github.com/harness/gitness/internal/api/controller/repo" + "github.com/harness/gitness/internal/api/render" + "github.com/harness/gitness/internal/api/request" +) + +/* + * Writes json-encoded branch information to the http response body. + */ +func HandleCalculateCommitDivergence(repoCtrl *repo.Controller) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + session, _ := request.AuthSessionFrom(ctx) + repoRef, err := request.GetRepoRefFromPath(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } + + in := new(repo.GetCommitDivergencesInput) + err = json.NewDecoder(r.Body).Decode(in) + if err != nil { + render.BadRequestf(w, "Invalid request body: %s.", err) + return + } + + divergences, err := repoCtrl.GetCommitDivergences(ctx, session, repoRef, in) + if err != nil { + render.TranslatedUserError(w, err) + return + } + + render.JSON(w, http.StatusOK, divergences) + } +} diff --git a/internal/api/openapi/repo.go b/internal/api/openapi/repo.go index 63557c2a8..b24da6588 100644 --- a/internal/api/openapi/repo.go +++ b/internal/api/openapi/repo.go @@ -92,6 +92,11 @@ type listCommitsRequest struct { repoRequest } +type calculateCommitDivergenceRequest struct { + repoRequest + repo.GetCommitDivergencesInput +} + type listBranchesRequest struct { repoRequest } @@ -290,7 +295,7 @@ func repoOperations(reflector *openapi3.Reflector) { _ = reflector.SetJSONResponse(&opServiceAccounts, new(usererror.Error), http.StatusUnauthorized) _ = reflector.SetJSONResponse(&opServiceAccounts, new(usererror.Error), http.StatusForbidden) _ = reflector.SetJSONResponse(&opServiceAccounts, new(usererror.Error), http.StatusNotFound) - _ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repoRef}/serviceAccounts", opServiceAccounts) + _ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repoRef}/service_accounts", opServiceAccounts) opListPaths := openapi3.Operation{} opListPaths.WithTags("repository") @@ -350,6 +355,18 @@ func repoOperations(reflector *openapi3.Reflector) { _ = reflector.SetJSONResponse(&opListCommits, new(usererror.Error), http.StatusNotFound) _ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repoRef}/commits", opListCommits) + opCalulateCommitDivergence := openapi3.Operation{} + opCalulateCommitDivergence.WithTags("repository") + opCalulateCommitDivergence.WithMapOfAnything(map[string]interface{}{"operationId": "calculateCommitDivergence"}) + _ = reflector.SetRequest(&opCalulateCommitDivergence, new(calculateCommitDivergenceRequest), http.MethodPost) + _ = reflector.SetJSONResponse(&opCalulateCommitDivergence, []repo.CommitDivergence{}, http.StatusOK) + _ = reflector.SetJSONResponse(&opCalulateCommitDivergence, new(usererror.Error), http.StatusInternalServerError) + _ = reflector.SetJSONResponse(&opCalulateCommitDivergence, new(usererror.Error), http.StatusUnauthorized) + _ = reflector.SetJSONResponse(&opCalulateCommitDivergence, new(usererror.Error), http.StatusForbidden) + _ = reflector.SetJSONResponse(&opCalulateCommitDivergence, new(usererror.Error), http.StatusNotFound) + _ = reflector.Spec.AddOperation(http.MethodPost, "/repos/{repoRef}/commits/calculate_divergence", + opCalulateCommitDivergence) + opCreateBranch := openapi3.Operation{} opCreateBranch.WithTags("repository") opCreateBranch.WithMapOfAnything(map[string]interface{}{"operationId": "createBranch"}) diff --git a/internal/api/openapi/space.go b/internal/api/openapi/space.go index e73f484fd..d620059de 100644 --- a/internal/api/openapi/space.go +++ b/internal/api/openapi/space.go @@ -208,7 +208,7 @@ func spaceOperations(reflector *openapi3.Reflector) { _ = reflector.SetJSONResponse(&opServiceAccounts, new(usererror.Error), http.StatusUnauthorized) _ = reflector.SetJSONResponse(&opServiceAccounts, new(usererror.Error), http.StatusForbidden) _ = reflector.SetJSONResponse(&opServiceAccounts, new(usererror.Error), http.StatusNotFound) - _ = reflector.Spec.AddOperation(http.MethodGet, "/spaces/{spaceRef}/serviceAccounts", opServiceAccounts) + _ = reflector.Spec.AddOperation(http.MethodGet, "/spaces/{spaceRef}/service_accounts", opServiceAccounts) opListPaths := openapi3.Operation{} opListPaths.WithTags("space") diff --git a/internal/api/usererror/usererror.go b/internal/api/usererror/usererror.go index b271ee505..7358c338e 100644 --- a/internal/api/usererror/usererror.go +++ b/internal/api/usererror/usererror.go @@ -47,6 +47,9 @@ var ( // ErrDefaultBranchCantBeDeleted is returned if the user tries to delete the default branch of a repository. ErrDefaultBranchCantBeDeleted = New(http.StatusBadRequest, "The default branch of a repository can't be deleted") + + // ErrRequestTooLarge is returned if the request it too large. + ErrRequestTooLarge = New(http.StatusRequestEntityTooLarge, "The request is too large") ) // Error represents a json-encoded API error. diff --git a/internal/router/api.go b/internal/router/api.go index 42e61fe04..39467b149 100644 --- a/internal/router/api.go +++ b/internal/router/api.go @@ -124,7 +124,7 @@ func setupSpaces(r chi.Router, spaceCtrl *space.Controller) { r.Post("/move", handlerspace.HandleMove(spaceCtrl)) r.Get("/spaces", handlerspace.HandleListSpaces(spaceCtrl)) r.Get("/repos", handlerspace.HandleListRepos(spaceCtrl)) - r.Get("/serviceAccounts", handlerspace.HandleListServiceAccounts(spaceCtrl)) + r.Get("/service_accounts", handlerspace.HandleListServiceAccounts(spaceCtrl)) // Child collections r.Route("/paths", func(r chi.Router) { @@ -151,7 +151,7 @@ func setupRepos(r chi.Router, repoCtrl *repo.Controller) { r.Delete("/", handlerrepo.HandleDelete(repoCtrl)) r.Post("/move", handlerrepo.HandleMove(repoCtrl)) - r.Get("/serviceAccounts", handlerrepo.HandleListServiceAccounts(repoCtrl)) + r.Get("/service_accounts", handlerrepo.HandleListServiceAccounts(repoCtrl)) // content operations // NOTE: this allows /content and /content/ to both be valid (without any other tricks.) @@ -163,6 +163,8 @@ func setupRepos(r chi.Router, repoCtrl *repo.Controller) { // commit operations r.Route("/commits", func(r chi.Router) { r.Get("/", handlerrepo.HandleListCommits(repoCtrl)) + + r.Post("/calculate_divergence", handlerrepo.HandleCalculateCommitDivergence(repoCtrl)) }) // branch operations @@ -223,7 +225,7 @@ func setupUsers(r chi.Router, userCtrl *user.Controller) { } func setupServiceAccounts(r chi.Router, saCtrl *serviceaccount.Controller) { - r.Route("/serviceAccounts", func(r chi.Router) { + r.Route("/service_accounts", func(r chi.Router) { // create takes parent information via body r.Post("/", handlerserviceaccount.HandleCreate(saCtrl)) diff --git a/web/src/services/scm/index.tsx b/web/src/services/scm/index.tsx index f878c1460..9d5a36ffc 100644 --- a/web/src/services/scm/index.tsx +++ b/web/src/services/scm/index.tsx @@ -23,6 +23,11 @@ export interface FormDataOpenapiRegisterRequest { username?: string } +export interface OpenapiCalculateCommitDivergenceRequest { + maxCount?: number + requests?: RepoDivergenceRequest[] | null +} + export type OpenapiContent = RepoFileContent | OpenapiDirContent | RepoSymlinkContent | RepoSubmoduleContent export interface OpenapiContentInfo { @@ -144,6 +149,16 @@ export interface RepoContentInfo { export type RepoContentType = string +export interface RepoDivergence { + ahead?: number + behind?: number +} + +export interface RepoDivergenceRequest { + from?: string + to?: string +} + export interface RepoFileContent { data?: string encoding?: RepoFileEncodingType @@ -606,6 +621,63 @@ export const useListCommits = ({ repoRef, ...props }: UseListCommitsProps) => { base: getConfigNew('scm'), pathParams: { repoRef }, ...props } ) +export interface CalculateCommitDivergencePathParams { + repoRef: string +} + +export type CalculateCommitDivergenceProps = Omit< + MutateProps< + RepoDivergence[], + UsererrorError, + void, + OpenapiCalculateCommitDivergenceRequest, + CalculateCommitDivergencePathParams + >, + 'path' | 'verb' +> & + CalculateCommitDivergencePathParams + +export const CalculateCommitDivergence = ({ repoRef, ...props }: CalculateCommitDivergenceProps) => ( + + verb="POST" + path={`/repos/${repoRef}/commits/calculate_divergence`} + base={getConfigNew('scm')} + {...props} + /> +) + +export type UseCalculateCommitDivergenceProps = Omit< + UseMutateProps< + RepoDivergence[], + UsererrorError, + void, + OpenapiCalculateCommitDivergenceRequest, + CalculateCommitDivergencePathParams + >, + 'path' | 'verb' +> & + CalculateCommitDivergencePathParams + +export const useCalculateCommitDivergence = ({ repoRef, ...props }: UseCalculateCommitDivergenceProps) => + useMutate< + RepoDivergence[], + UsererrorError, + void, + OpenapiCalculateCommitDivergenceRequest, + CalculateCommitDivergencePathParams + >( + 'POST', + (paramsInPath: CalculateCommitDivergencePathParams) => + `/repos/${paramsInPath.repoRef}/commits/calculate_divergence`, + { base: getConfigNew('scm'), pathParams: { repoRef }, ...props } + ) + export interface GetContentQueryParams { /** * The git reference (branch / tag / commitID) that will be used to retrieve the data. If no value is provided the default branch of the repository is used. @@ -797,7 +869,7 @@ export type ListRepositoryServiceAccountsProps = Omit< export const ListRepositoryServiceAccounts = ({ repoRef, ...props }: ListRepositoryServiceAccountsProps) => ( - path={`/repos/${repoRef}/serviceAccounts`} + path={`/repos/${repoRef}/service_accounts`} base={getConfigNew('scm')} {...props} /> @@ -811,7 +883,7 @@ export type UseListRepositoryServiceAccountsProps = Omit< export const useListRepositoryServiceAccounts = ({ repoRef, ...props }: UseListRepositoryServiceAccountsProps) => useGet( - (paramsInPath: ListRepositoryServiceAccountsPathParams) => `/repos/${paramsInPath.repoRef}/serviceAccounts`, + (paramsInPath: ListRepositoryServiceAccountsPathParams) => `/repos/${paramsInPath.repoRef}/service_accounts`, { base: getConfigNew('scm'), pathParams: { repoRef }, ...props } ) @@ -1206,7 +1278,7 @@ export type ListServiceAccountsProps = Omit< export const ListServiceAccounts = ({ spaceRef, ...props }: ListServiceAccountsProps) => ( - path={`/spaces/${spaceRef}/serviceAccounts`} + path={`/spaces/${spaceRef}/service_accounts`} base={getConfigNew('scm')} {...props} /> @@ -1220,7 +1292,7 @@ export type UseListServiceAccountsProps = Omit< export const useListServiceAccounts = ({ spaceRef, ...props }: UseListServiceAccountsProps) => useGet( - (paramsInPath: ListServiceAccountsPathParams) => `/spaces/${paramsInPath.spaceRef}/serviceAccounts`, + (paramsInPath: ListServiceAccountsPathParams) => `/spaces/${paramsInPath.spaceRef}/service_accounts`, { base: getConfigNew('scm'), pathParams: { spaceRef }, ...props } ) diff --git a/web/src/services/scm/swagger.yaml b/web/src/services/scm/swagger.yaml index a48227a56..bea1ed8e2 100644 --- a/web/src/services/scm/swagger.yaml +++ b/web/src/services/scm/swagger.yaml @@ -410,7 +410,7 @@ paths: description: Internal Server Error tags: - repository - /repos/{repoRef}/branches/{name}: + /repos/{repoRef}/branches/{branchName}: delete: operationId: deleteBranch parameters: @@ -420,7 +420,7 @@ paths: schema: type: string - in: path - name: name + name: branchName required: true schema: type: string @@ -523,6 +523,55 @@ paths: description: Internal Server Error tags: - repository + /repos/{repoRef}/commits/calculate_divergence: + post: + operationId: calculateCommitDivergence + parameters: + - in: path + name: repoRef + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OpenapiCalculateCommitDivergenceRequest' + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/RepoDivergence' + type: array + description: OK + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/UsererrorError' + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/UsererrorError' + description: Forbidden + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/UsererrorError' + description: Not Found + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/UsererrorError' + description: Internal Server Error + tags: + - repository /repos/{repoRef}/content/{path}: get: operationId: getContent @@ -784,7 +833,7 @@ paths: description: Internal Server Error tags: - repository - /repos/{repoRef}/serviceAccounts: + /repos/{repoRef}/service_accounts: get: operationId: listRepositoryServiceAccounts parameters: @@ -1451,7 +1500,7 @@ paths: description: Internal Server Error tags: - space - /spaces/{spaceRef}/serviceAccounts: + /spaces/{spaceRef}/service_accounts: get: operationId: listServiceAccounts parameters: @@ -1826,6 +1875,16 @@ components: username: type: string type: object + OpenapiCalculateCommitDivergenceRequest: + properties: + maxCount: + type: integer + requests: + items: + $ref: '#/components/schemas/RepoDivergenceRequest' + nullable: true + type: array + type: object OpenapiContent: oneOf: - $ref: '#/components/schemas/RepoFileContent' @@ -2032,6 +2091,20 @@ components: type: object RepoContentType: type: string + RepoDivergence: + properties: + ahead: + type: integer + behind: + type: integer + type: object + RepoDivergenceRequest: + properties: + from: + type: string + to: + type: string + type: object RepoFileContent: properties: data: