From 943708dcc7795444d386c2813441aca8262c6edf Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 01:39:35 -0700 Subject: [PATCH 1/9] feat: [CODE-200]: list commits with date filter --- gitrpc/commit.go | 4 + gitrpc/internal/gitea/commit.go | 22 +- gitrpc/internal/service/interface.go | 4 +- gitrpc/proto/repo.proto | 2 + gitrpc/rpc/repo.pb.go | 315 ++++++++++--------- internal/api/controller/repo/list_commits.go | 4 +- internal/api/handler/repo/list_commits.go | 15 +- internal/api/openapi/repo.go | 32 +- internal/api/request/git.go | 10 + 9 files changed, 247 insertions(+), 161 deletions(-) diff --git a/gitrpc/commit.go b/gitrpc/commit.go index c556043ac..ee97a0149 100644 --- a/gitrpc/commit.go +++ b/gitrpc/commit.go @@ -76,6 +76,8 @@ type ListCommitsParams struct { Page int32 Limit int32 Path string + Since int64 + Until int64 } type RenameDetails struct { @@ -100,6 +102,8 @@ func (c *Client) ListCommits(ctx context.Context, params *ListCommitsParams) (*L Page: params.Page, Limit: params.Limit, Path: params.Path, + Since: params.Since, + Until: params.Until, }) if err != nil { return nil, fmt.Errorf("failed to start stream for commits: %w", err) diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index f086b9964..7723e97c7 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -83,9 +83,9 @@ func getGiteaCommits(giteaRepo *gitea.Repository, commitIDs []string) ([]*gitea. func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, ref string, afterRef string, - page int, limit int, path string, + page int, limit int, path string, since int64, until int64, ) ([]string, error) { - args := make([]string, 0, 8) + args := make([]string, 0, 11) args = append(args, "rev-list") // return commits only up to a certain reference if requested @@ -110,6 +110,16 @@ func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, } } + if since > 0 || until > 0 { + args = append(args, "--date", fmt.Sprint("unix")) + } + if since > 0 { + args = append(args, "--since", fmt.Sprint(since)) + } + if until > 0 { + args = append(args, "--until", fmt.Sprint(until)) + } + stdout, _, runErr := gitea.NewCommand(giteaRepo.Ctx, args...).RunStdBytes(&gitea.RunOpts{Dir: giteaRepo.Path}) if runErr != nil { // TODO: handle error in case they don't have a common merge base! @@ -125,7 +135,7 @@ func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, func (g Adapter) ListCommitSHAs(ctx context.Context, repoPath string, ref string, afterRef string, - page int, limit int, path string, + page int, limit int, path string, since int64, until int64, ) ([]string, error) { giteaRepo, err := gitea.OpenRepository(ctx, repoPath) if err != nil { @@ -133,7 +143,7 @@ func (g Adapter) ListCommitSHAs(ctx context.Context, } defer giteaRepo.Close() - return g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit, path) + return g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit, path, since, until) } // ListCommits lists the commits reachable from ref. @@ -142,7 +152,7 @@ func (g Adapter) ListCommitSHAs(ctx context.Context, func (g Adapter) ListCommits(ctx context.Context, repoPath string, ref string, afterRef string, - page int, limit int, path string, + page int, limit int, path string, since int64, until int64, ) ([]types.Commit, *types.PathRenameDetails, error) { giteaRepo, err := gitea.OpenRepository(ctx, repoPath) if err != nil { @@ -150,7 +160,7 @@ func (g Adapter) ListCommits(ctx context.Context, } defer giteaRepo.Close() - commitSHAs, err := g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit, path) + commitSHAs, err := g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit, path, since, until) if err != nil { return nil, nil, err } diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index 5ecf52fca..802dd9677 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -33,9 +33,9 @@ type GitAdapter interface { GetCommit(ctx context.Context, repoPath string, ref string) (*types.Commit, error) GetCommits(ctx context.Context, repoPath string, refs []string) ([]types.Commit, error) ListCommits(ctx context.Context, repoPath string, - ref string, afterRef string, page int, limit int, path string) ([]types.Commit, *types.PathRenameDetails, error) + ref string, afterRef string, page int, limit int, path string, since int64, until int64) ([]types.Commit, *types.PathRenameDetails, error) ListCommitSHAs(ctx context.Context, repoPath string, - ref string, afterRef string, page int, limit int, path string) ([]string, error) + ref string, afterRef string, page int, limit int, path string, since int64, until int64) ([]string, error) GetLatestCommit(ctx context.Context, repoPath string, ref string, treePath string) (*types.Commit, error) GetFullCommitID(ctx context.Context, repoPath, shortID string) (string, error) GetAnnotatedTag(ctx context.Context, repoPath string, sha string) (*types.Tag, error) diff --git a/gitrpc/proto/repo.proto b/gitrpc/proto/repo.proto index 2a9698152..eb4b755ad 100644 --- a/gitrpc/proto/repo.proto +++ b/gitrpc/proto/repo.proto @@ -98,6 +98,8 @@ message ListCommitsRequest { int32 page = 4; int32 limit = 5; string path = 6; + int64 since = 7; + int64 until = 8; } message ListCommitsResponse { diff --git a/gitrpc/rpc/repo.pb.go b/gitrpc/rpc/repo.pb.go index cfa8f901e..e8ead5274 100644 --- a/gitrpc/rpc/repo.pb.go +++ b/gitrpc/rpc/repo.pb.go @@ -766,6 +766,8 @@ type ListCommitsRequest struct { Page int32 `protobuf:"varint,4,opt,name=page,proto3" json:"page,omitempty"` Limit int32 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"` Path string `protobuf:"bytes,6,opt,name=path,proto3" json:"path,omitempty"` + Since int64 `protobuf:"varint,7,opt,name=since,proto3" json:"since,omitempty"` + Until int64 `protobuf:"varint,8,opt,name=until,proto3" json:"until,omitempty"` } func (x *ListCommitsRequest) Reset() { @@ -842,6 +844,20 @@ func (x *ListCommitsRequest) GetPath() string { return "" } +func (x *ListCommitsRequest) GetSince() int64 { + if x != nil { + return x.Since + } + return 0 +} + +func (x *ListCommitsRequest) GetUntil() int64 { + if x != nil { + return x.Until + } + return 0 +} + type ListCommitsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1826,7 +1842,7 @@ var file_repo_proto_rawDesc = []byte{ 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x22, - 0xa7, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, + 0xd3, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, @@ -1836,156 +1852,159 @@ var file_repo_proto_rawDesc = []byte{ 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x75, 0x0a, 0x13, 0x4c, 0x69, 0x73, - 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x06, 0x63, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x39, 0x0a, 0x0e, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x5f, - 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x73, 0x52, 0x0d, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, - 0x22, 0x64, 0x0a, 0x0d, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x64, - 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x6f, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x19, 0x0a, 0x08, 0x6e, - 0x65, 0x77, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, - 0x65, 0x77, 0x50, 0x61, 0x74, 0x68, 0x22, 0x67, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, - 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, - 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x10, - 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, - 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, - 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, - 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x60, 0x0a, 0x15, - 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x63, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x68, - 0x0a, 0x13, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x67, - 0x69, 0x74, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x69, - 0x74, 0x52, 0x65, 0x66, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x44, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, - 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x2c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x31, - 0x0a, 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, 0x22, 0x9a, 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, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x69, 0x6e, + 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x22, 0x75, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x06, + 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x12, 0x39, 0x0a, 0x0e, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x64, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x0d, 0x72, + 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x64, 0x0a, 0x0d, + 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x1d, 0x0a, + 0x0a, 0x69, 0x73, 0x5f, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, + 0x6f, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6f, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x5f, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x50, 0x61, + 0x74, 0x68, 0x22, 0x67, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, + 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, 0x1d, 0x0a, 0x0a, + 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x6b, 0x0a, 0x0f, 0x47, + 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, + 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x68, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x60, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x73, 0x68, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x68, 0x0a, 0x13, 0x47, 0x65, + 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 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, 0x22, 0x40, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x22, 0x1a, 0x0a, 0x18, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x60, 0x0a, 0x10, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, - 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, - 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, - 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65, 0x66, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x72, 0x65, 0x66, 0x31, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65, 0x66, 0x32, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x66, 0x32, 0x22, 0x39, 0x0a, 0x11, 0x4d, 0x65, 0x72, 0x67, - 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, - 0x0e, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, - 0x53, 0x68, 0x61, 0x2a, 0x52, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01, 0x12, - 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x02, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, - 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, - 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x17, - 0x0a, 0x13, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53, 0x79, - 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x45, 0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14, 0x0a, - 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72, 0x65, - 0x65, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, - 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x32, 0xd9, 0x05, 0x0a, 0x11, - 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x51, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x67, 0x69, 0x74, 0x5f, 0x72, + 0x65, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x69, 0x74, 0x52, 0x65, 0x66, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x22, 0x44, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x09, + 0x73, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, + 0x09, 0x73, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x31, 0x0a, 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, 0x22, 0x9a, 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, 0x24, 0x0a, + 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, + 0x61, 0x73, 0x65, 0x12, 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, 0x22, 0x40, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x25, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x22, 0x1a, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x28, 0x01, 0x12, 0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, - 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, - 0x12, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, - 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, - 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, - 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, - 0x01, 0x12, 0x3a, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x15, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, - 0x14, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, - 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, - 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x4d, - 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, - 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, - 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x22, 0x60, 0x0a, 0x10, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x72, 0x65, 0x66, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x66, 0x31, + 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65, 0x66, 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x72, 0x65, 0x66, 0x32, 0x22, 0x39, 0x0a, 0x11, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x65, 0x72, + 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61, 0x2a, + 0x52, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, + 0x72, 0x65, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x54, + 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x10, 0x02, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x4d, 0x6f, 0x64, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x72, + 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53, 0x79, 0x6d, 0x6c, 0x69, 0x6e, + 0x6b, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, + 0x6f, 0x64, 0x65, 0x45, 0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x03, 0x12, + 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x32, 0xd9, 0x05, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, + 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, + 0x12, 0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, + 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, + 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, + 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x43, 0x0a, 0x0c, + 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, + 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x36, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x13, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0b, 0x4c, 0x69, 0x73, + 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x3a, 0x0a, + 0x09, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x14, 0x47, 0x65, 0x74, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, + 0x73, 0x12, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x4d, 0x65, 0x72, 0x67, 0x65, + 0x42, 0x61, 0x73, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, + 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, + 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/api/controller/repo/list_commits.go b/internal/api/controller/repo/list_commits.go index 42ff1caa8..613b5a064 100644 --- a/internal/api/controller/repo/list_commits.go +++ b/internal/api/controller/repo/list_commits.go @@ -20,7 +20,7 @@ import ( * ListCommits lists the commits of a repo. */ func (c *Controller) ListCommits(ctx context.Context, session *auth.Session, - repoRef string, gitRef string, filter *types.CommitFilter, path string) ([]types.Commit, *types.RenameDetails, error) { + repoRef string, gitRef string, filter *types.CommitFilter, path string, since int64, until int64) ([]types.Commit, *types.RenameDetails, error) { repo, err := c.repoStore.FindByRef(ctx, repoRef) if err != nil { return nil, nil, err @@ -42,6 +42,8 @@ func (c *Controller) ListCommits(ctx context.Context, session *auth.Session, Page: int32(filter.Page), Limit: int32(filter.Limit), Path: path, + Since: since, + Until: until, }) if err != nil { return nil, nil, err diff --git a/internal/api/handler/repo/list_commits.go b/internal/api/handler/repo/list_commits.go index 1834b290f..31fd6216b 100644 --- a/internal/api/handler/repo/list_commits.go +++ b/internal/api/handler/repo/list_commits.go @@ -30,7 +30,7 @@ func HandleListCommits(repoCtrl *repo.Controller) http.HandlerFunc { filter := request.ParseCommitFilter(r) - commits, _, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter, "") + commits, _, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter, "", 0, 0) if err != nil { render.TranslatedUserError(w, err) return @@ -61,8 +61,17 @@ func HandleListCommitsV2(repoCtrl *repo.Controller) http.HandlerFunc { filter := request.ParseCommitFilter(r) path := request.GetPathFromQueryOrDefault(r, "") - - commits, renameDetails, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter, path) + since, err := request.GetSinceFromQueryOrDefault(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } + until, err := request.GetUntilFromQueryOrDefault(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } + commits, renameDetails, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter, path, since, until) if err != nil { render.TranslatedUserError(w, err) return diff --git a/internal/api/openapi/repo.go b/internal/api/openapi/repo.go index 76568b947..be3bf83ae 100644 --- a/internal/api/openapi/repo.go +++ b/internal/api/openapi/repo.go @@ -182,6 +182,36 @@ var queryParameterPath = openapi3.ParameterOrRef{ }, } +var queryParameterSince = openapi3.ParameterOrRef{ + Parameter: &openapi3.Parameter{ + Name: request.QueryPath, + In: openapi3.ParameterInQuery, + Description: ptr.String("Date since when commit information should be retrieved."), + Required: ptr.Bool(false), + Schema: &openapi3.SchemaOrRef{ + Schema: &openapi3.Schema{ + Type: ptrSchemaType(openapi3.SchemaTypeInteger), + Default: ptrptr(""), + }, + }, + }, +} + +var queryParameterUntil = openapi3.ParameterOrRef{ + Parameter: &openapi3.Parameter{ + Name: request.QueryPath, + In: openapi3.ParameterInQuery, + Description: ptr.String("Date until when commit information should be retrieved."), + Required: ptr.Bool(false), + Schema: &openapi3.SchemaOrRef{ + Schema: &openapi3.Schema{ + Type: ptrSchemaType(openapi3.SchemaTypeInteger), + Default: ptrptr(""), + }, + }, + }, +} + var queryParameterIncludeCommit = openapi3.ParameterOrRef{ Parameter: &openapi3.Parameter{ Name: request.QueryParamIncludeCommit, @@ -483,7 +513,7 @@ func repoOperations(reflector *openapi3.Reflector) { opListCommitsV2.WithTags("repository") opListCommitsV2.WithMapOfAnything(map[string]interface{}{"operationId": "listCommitsV2"}) opListCommitsV2.WithParameters(queryParameterGitRef, queryParameterAfterCommits, queryParameterPath, - queryParameterPage, queryParameterLimit) + queryParameterPage, queryParameterLimit, queryParameterSince, queryParameterUntil) _ = reflector.SetRequest(&opListCommitsV2, new(listCommitsRequest), http.MethodGet) _ = reflector.SetJSONResponse(&opListCommitsV2, []types.ListCommitResponse{}, http.StatusOK) _ = reflector.SetJSONResponse(&opListCommitsV2, new(usererror.Error), http.StatusInternalServerError) diff --git a/internal/api/request/git.go b/internal/api/request/git.go index 47d0af28c..f4b88207b 100644 --- a/internal/api/request/git.go +++ b/internal/api/request/git.go @@ -18,6 +18,8 @@ const ( QueryLineFrom = "line_from" QueryLineTo = "line_to" QueryPath = "path" + QuerySince = "since" + QueryUntil = "until" ) func GetGitRefFromQueryOrDefault(r *http.Request, deflt string) string { @@ -82,3 +84,11 @@ func ParseCommitFilter(r *http.Request) *types.CommitFilter { func GetPathFromQueryOrDefault(r *http.Request, deflt string) string { return QueryParamOrDefault(r, QueryPath, deflt) } + +func GetSinceFromQueryOrDefault(r *http.Request) (int64, error) { + return QueryParamAsPositiveInt64(r, QuerySince) +} + +func GetUntilFromQueryOrDefault(r *http.Request) (int64, error) { + return QueryParamAsPositiveInt64(r, QueryUntil) +} From 05849f48e670eccd7f4bac623d1523596881f1de Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 01:53:23 -0700 Subject: [PATCH 2/9] feat: [CODE-200]: list commits with date filter --- gitrpc/internal/service/commit.go | 2 +- gitrpc/internal/service/diff.go | 2 +- gitrpc/internal/service/interface.go | 3 ++- internal/api/controller/repo/list_commits.go | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gitrpc/internal/service/commit.go b/gitrpc/internal/service/commit.go index 2232e4125..e9c7b3cd0 100644 --- a/gitrpc/internal/service/commit.go +++ b/gitrpc/internal/service/commit.go @@ -56,7 +56,7 @@ func (s RepositoryService) ListCommits(request *rpc.ListCommitsRequest, repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) gitCommits, renameDetails, err := s.adapter.ListCommits(ctx, repoPath, request.GetGitRef(), - request.GetAfter(), int(request.GetPage()), int(request.GetLimit()), request.GetPath()) + request.GetAfter(), int(request.GetPage()), int(request.GetLimit()), request.GetPath(), request.GetSince(), request.GetUntil()) if err != nil { return processGitErrorf(err, "failed to get list of commits") } diff --git a/gitrpc/internal/service/diff.go b/gitrpc/internal/service/diff.go index 25fada48c..9dd54d916 100644 --- a/gitrpc/internal/service/diff.go +++ b/gitrpc/internal/service/diff.go @@ -124,7 +124,7 @@ func (s DiffService) DiffCut( return nil, processGitErrorf(err, "failed to find merge base") } - sourceCommits, err := s.adapter.ListCommitSHAs(ctx, repoPath, r.SourceBranch, r.TargetBranch, 0, 1, "") + sourceCommits, err := s.adapter.ListCommitSHAs(ctx, repoPath, r.SourceBranch, r.TargetBranch, 0, 1, "", 0, 0) if err != nil || len(sourceCommits) == 0 { return nil, processGitErrorf(err, "failed to get list of source branch commits") } diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index 802dd9677..4b0f149ea 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -6,9 +6,10 @@ package service import ( "context" - "github.com/harness/gitness/gitrpc/rpc" "io" + "github.com/harness/gitness/gitrpc/rpc" + "github.com/harness/gitness/gitrpc/enum" "github.com/harness/gitness/gitrpc/internal/types" ) diff --git a/internal/api/controller/repo/list_commits.go b/internal/api/controller/repo/list_commits.go index 613b5a064..d47d08c71 100644 --- a/internal/api/controller/repo/list_commits.go +++ b/internal/api/controller/repo/list_commits.go @@ -20,7 +20,8 @@ import ( * ListCommits lists the commits of a repo. */ func (c *Controller) ListCommits(ctx context.Context, session *auth.Session, - repoRef string, gitRef string, filter *types.CommitFilter, path string, since int64, until int64) ([]types.Commit, *types.RenameDetails, error) { + repoRef string, gitRef string, filter *types.CommitFilter, path string, + since int64, until int64) ([]types.Commit, *types.RenameDetails, error) { repo, err := c.repoStore.FindByRef(ctx, repoRef) if err != nil { return nil, nil, err From 0f650f8c289725d97e63308f5d5c43f5d6c9b8b9 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 01:59:46 -0700 Subject: [PATCH 3/9] feat: [CODE-200]: list commits with date filter --- internal/api/openapi/repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/openapi/repo.go b/internal/api/openapi/repo.go index be3bf83ae..6ffbd8964 100644 --- a/internal/api/openapi/repo.go +++ b/internal/api/openapi/repo.go @@ -513,7 +513,7 @@ func repoOperations(reflector *openapi3.Reflector) { opListCommitsV2.WithTags("repository") opListCommitsV2.WithMapOfAnything(map[string]interface{}{"operationId": "listCommitsV2"}) opListCommitsV2.WithParameters(queryParameterGitRef, queryParameterAfterCommits, queryParameterPath, - queryParameterPage, queryParameterLimit, queryParameterSince, queryParameterUntil) + queryParameterSince, queryParameterUntil, queryParameterPage, queryParameterLimit) _ = reflector.SetRequest(&opListCommitsV2, new(listCommitsRequest), http.MethodGet) _ = reflector.SetJSONResponse(&opListCommitsV2, []types.ListCommitResponse{}, http.StatusOK) _ = reflector.SetJSONResponse(&opListCommitsV2, new(usererror.Error), http.StatusInternalServerError) From 1765fef3fd811340fc771096fef98b2099a4d12b Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 02:10:38 -0700 Subject: [PATCH 4/9] feat: [CODE-200]: list commits with date filter --- internal/api/openapi/repo.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/api/openapi/repo.go b/internal/api/openapi/repo.go index 6ffbd8964..f8b236fcc 100644 --- a/internal/api/openapi/repo.go +++ b/internal/api/openapi/repo.go @@ -184,14 +184,14 @@ var queryParameterPath = openapi3.ParameterOrRef{ var queryParameterSince = openapi3.ParameterOrRef{ Parameter: &openapi3.Parameter{ - Name: request.QueryPath, + Name: request.QuerySince, In: openapi3.ParameterInQuery, Description: ptr.String("Date since when commit information should be retrieved."), Required: ptr.Bool(false), Schema: &openapi3.SchemaOrRef{ Schema: &openapi3.Schema{ Type: ptrSchemaType(openapi3.SchemaTypeInteger), - Default: ptrptr(""), + Default: ptrptr(0), }, }, }, @@ -199,14 +199,14 @@ var queryParameterSince = openapi3.ParameterOrRef{ var queryParameterUntil = openapi3.ParameterOrRef{ Parameter: &openapi3.Parameter{ - Name: request.QueryPath, + Name: request.QueryUntil, In: openapi3.ParameterInQuery, Description: ptr.String("Date until when commit information should be retrieved."), Required: ptr.Bool(false), Schema: &openapi3.SchemaOrRef{ Schema: &openapi3.Schema{ Type: ptrSchemaType(openapi3.SchemaTypeInteger), - Default: ptrptr(""), + Default: ptrptr(0), }, }, }, From 7d3443850b0b7e7c5835dde42d2fa169a365508d Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 14:09:58 -0700 Subject: [PATCH 5/9] feat: [CODE-200]: list commits with date filter --- internal/api/openapi/repo.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/api/openapi/repo.go b/internal/api/openapi/repo.go index f8b236fcc..8bca57d4a 100644 --- a/internal/api/openapi/repo.go +++ b/internal/api/openapi/repo.go @@ -186,12 +186,11 @@ var queryParameterSince = openapi3.ParameterOrRef{ Parameter: &openapi3.Parameter{ Name: request.QuerySince, In: openapi3.ParameterInQuery, - Description: ptr.String("Date since when commit information should be retrieved."), + Description: ptr.String("Epoch since when commit information should be retrieved."), Required: ptr.Bool(false), Schema: &openapi3.SchemaOrRef{ Schema: &openapi3.Schema{ - Type: ptrSchemaType(openapi3.SchemaTypeInteger), - Default: ptrptr(0), + Type: ptrSchemaType(openapi3.SchemaTypeInteger), }, }, }, @@ -201,12 +200,11 @@ var queryParameterUntil = openapi3.ParameterOrRef{ Parameter: &openapi3.Parameter{ Name: request.QueryUntil, In: openapi3.ParameterInQuery, - Description: ptr.String("Date until when commit information should be retrieved."), + Description: ptr.String("Epoch until when commit information should be retrieved."), Required: ptr.Bool(false), Schema: &openapi3.SchemaOrRef{ Schema: &openapi3.Schema{ - Type: ptrSchemaType(openapi3.SchemaTypeInteger), - Default: ptrptr(0), + Type: ptrSchemaType(openapi3.SchemaTypeInteger), }, }, }, From 7f6947f0eaa478bd2a033e3e2299c19b40e8dac6 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 14:37:19 -0700 Subject: [PATCH 6/9] feat: [CODE-200]: list commits with date filter --- gitrpc/internal/gitea/commit.go | 52 +++++++++++++---------- gitrpc/internal/service/commit.go | 5 ++- gitrpc/internal/service/diff.go | 3 +- gitrpc/internal/service/interface.go | 6 +-- gitrpc/internal/types/types.go | 7 +++ internal/api/handler/repo/list_commits.go | 4 +- internal/api/request/git.go | 4 +- 7 files changed, 48 insertions(+), 33 deletions(-) diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index 7723e97c7..033c4ef9e 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -81,23 +81,26 @@ func getGiteaCommits(giteaRepo *gitea.Repository, commitIDs []string) ([]*gitea. return giteaCommits, nil } -func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, - ref string, afterRef string, - page int, limit int, path string, since int64, until int64, +func (g Adapter) listCommitSHAs( + giteaRepo *gitea.Repository, + ref string, + page int, + limit int, + filter types.CommitFilter, ) ([]string, error) { - args := make([]string, 0, 11) + args := make([]string, 0, 12) args = append(args, "rev-list") // return commits only up to a certain reference if requested - if afterRef != "" { + if filter.AfterRef != "" { // ^REF tells the rev-list command to return only commits that aren't reachable by SHA - args = append(args, fmt.Sprintf("^%s", afterRef)) + args = append(args, fmt.Sprintf("^%s", filter.AfterRef)) } // add refCommitSHA as starting point args = append(args, ref) - if len(path) != 0 { - args = append(args, "--", path) + if len(filter.Path) != 0 { + args = append(args, "--", filter.Path) } // add pagination if requested @@ -110,14 +113,14 @@ func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, } } - if since > 0 || until > 0 { - args = append(args, "--date", fmt.Sprint("unix")) + if filter.Since > 0 || filter.Until > 0 { + args = append(args, "--date", "unix") } - if since > 0 { - args = append(args, "--since", fmt.Sprint(since)) + if filter.Since > 0 { + args = append(args, "--since", fmt.Sprint(filter.Since)) } - if until > 0 { - args = append(args, "--until", fmt.Sprint(until)) + if filter.Until > 0 { + args = append(args, "--until", fmt.Sprint(filter.Until)) } stdout, _, runErr := gitea.NewCommand(giteaRepo.Ctx, args...).RunStdBytes(&gitea.RunOpts{Dir: giteaRepo.Path}) @@ -132,10 +135,13 @@ func (g Adapter) listCommitSHAs(giteaRepo *gitea.Repository, // ListCommitSHAs lists the commits reachable from ref. // Note: ref & afterRef can be Branch / Tag / CommitSHA. // Note: commits returned are [ref->...->afterRef). -func (g Adapter) ListCommitSHAs(ctx context.Context, +func (g Adapter) ListCommitSHAs( + ctx context.Context, repoPath string, - ref string, afterRef string, - page int, limit int, path string, since int64, until int64, + ref string, + page int, + limit int, + filter types.CommitFilter, ) ([]string, error) { giteaRepo, err := gitea.OpenRepository(ctx, repoPath) if err != nil { @@ -143,7 +149,7 @@ func (g Adapter) ListCommitSHAs(ctx context.Context, } defer giteaRepo.Close() - return g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit, path, since, until) + return g.listCommitSHAs(giteaRepo, ref, page, limit, filter) } // ListCommits lists the commits reachable from ref. @@ -151,8 +157,8 @@ func (g Adapter) ListCommitSHAs(ctx context.Context, // Note: commits returned are [ref->...->afterRef). func (g Adapter) ListCommits(ctx context.Context, repoPath string, - ref string, afterRef string, - page int, limit int, path string, since int64, until int64, + ref string, + page int, limit int, filter types.CommitFilter, ) ([]types.Commit, *types.PathRenameDetails, error) { giteaRepo, err := gitea.OpenRepository(ctx, repoPath) if err != nil { @@ -160,7 +166,7 @@ func (g Adapter) ListCommits(ctx context.Context, } defer giteaRepo.Close() - commitSHAs, err := g.listCommitSHAs(giteaRepo, ref, afterRef, page, limit, path, since, until) + commitSHAs, err := g.listCommitSHAs(giteaRepo, ref, page, limit, filter) if err != nil { return nil, nil, err } @@ -180,8 +186,8 @@ func (g Adapter) ListCommits(ctx context.Context, commits[i] = *commit } - if len(path) != 0 { - renameDetails, err := giteaGetRenameDetails(giteaRepo, commits[0].SHA, path) + if len(filter.Path) != 0 { + renameDetails, err := giteaGetRenameDetails(giteaRepo, commits[0].SHA, filter.Path) if err != nil { return nil, nil, err } diff --git a/gitrpc/internal/service/commit.go b/gitrpc/internal/service/commit.go index e9c7b3cd0..cb1660976 100644 --- a/gitrpc/internal/service/commit.go +++ b/gitrpc/internal/service/commit.go @@ -56,7 +56,10 @@ func (s RepositoryService) ListCommits(request *rpc.ListCommitsRequest, repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) gitCommits, renameDetails, err := s.adapter.ListCommits(ctx, repoPath, request.GetGitRef(), - request.GetAfter(), int(request.GetPage()), int(request.GetLimit()), request.GetPath(), request.GetSince(), request.GetUntil()) + int(request.GetPage()), int(request.GetLimit()), types.CommitFilter{AfterRef: request.After, + Path: request.Path, + Since: request.Since, + Until: request.Until}) if err != nil { return processGitErrorf(err, "failed to get list of commits") } diff --git a/gitrpc/internal/service/diff.go b/gitrpc/internal/service/diff.go index 9dd54d916..5bcdbfea5 100644 --- a/gitrpc/internal/service/diff.go +++ b/gitrpc/internal/service/diff.go @@ -124,7 +124,8 @@ func (s DiffService) DiffCut( return nil, processGitErrorf(err, "failed to find merge base") } - sourceCommits, err := s.adapter.ListCommitSHAs(ctx, repoPath, r.SourceBranch, r.TargetBranch, 0, 1, "", 0, 0) + sourceCommits, err := s.adapter.ListCommitSHAs(ctx, repoPath, r.SourceBranch, 0, 1, + types.CommitFilter{AfterRef: r.TargetBranch}) if err != nil || len(sourceCommits) == 0 { return nil, processGitErrorf(err, "failed to get list of source branch commits") } diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index dcf09471a..8ac4ab900 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -8,8 +8,6 @@ import ( "context" "io" - "github.com/harness/gitness/gitrpc/rpc" - "github.com/harness/gitness/gitrpc/enum" "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" @@ -35,9 +33,9 @@ type GitAdapter interface { GetCommit(ctx context.Context, repoPath string, ref string) (*types.Commit, error) GetCommits(ctx context.Context, repoPath string, refs []string) ([]types.Commit, error) ListCommits(ctx context.Context, repoPath string, - ref string, afterRef string, page int, limit int, path string, since int64, until int64) ([]types.Commit, *types.PathRenameDetails, error) + ref string, page int, limit int, filter types.CommitFilter) ([]types.Commit, *types.PathRenameDetails, error) ListCommitSHAs(ctx context.Context, repoPath string, - ref string, afterRef string, page int, limit int, path string, since int64, until int64) ([]string, error) + ref string, page int, limit int, filter types.CommitFilter) ([]string, error) GetLatestCommit(ctx context.Context, repoPath string, ref string, treePath string) (*types.Commit, error) GetFullCommitID(ctx context.Context, repoPath, shortID string) (string, error) GetAnnotatedTag(ctx context.Context, repoPath string, sha string) (*types.Tag, error) diff --git a/gitrpc/internal/types/types.go b/gitrpc/internal/types/types.go index 02aa03dac..bb0e571ed 100644 --- a/gitrpc/internal/types/types.go +++ b/gitrpc/internal/types/types.go @@ -296,3 +296,10 @@ type PathRenameDetails struct { OldPath string NewPath string } + +type CommitFilter struct { + Path string + AfterRef string + Since int64 + Until int64 +} diff --git a/internal/api/handler/repo/list_commits.go b/internal/api/handler/repo/list_commits.go index 31fd6216b..acde34672 100644 --- a/internal/api/handler/repo/list_commits.go +++ b/internal/api/handler/repo/list_commits.go @@ -61,12 +61,12 @@ func HandleListCommitsV2(repoCtrl *repo.Controller) http.HandlerFunc { filter := request.ParseCommitFilter(r) path := request.GetPathFromQueryOrDefault(r, "") - since, err := request.GetSinceFromQueryOrDefault(r) + since, err := request.GetSinceFromQuery(r) if err != nil { render.TranslatedUserError(w, err) return } - until, err := request.GetUntilFromQueryOrDefault(r) + until, err := request.GetUntilFromQuery(r) if err != nil { render.TranslatedUserError(w, err) return diff --git a/internal/api/request/git.go b/internal/api/request/git.go index f4b88207b..85c566c2b 100644 --- a/internal/api/request/git.go +++ b/internal/api/request/git.go @@ -85,10 +85,10 @@ func GetPathFromQueryOrDefault(r *http.Request, deflt string) string { return QueryParamOrDefault(r, QueryPath, deflt) } -func GetSinceFromQueryOrDefault(r *http.Request) (int64, error) { +func GetSinceFromQuery(r *http.Request) (int64, error) { return QueryParamAsPositiveInt64(r, QuerySince) } -func GetUntilFromQueryOrDefault(r *http.Request) (int64, error) { +func GetUntilFromQuery(r *http.Request) (int64, error) { return QueryParamAsPositiveInt64(r, QueryUntil) } From 73095da2bbb68b9217caf13fa53f6ae66c449bb1 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 21:50:37 +0000 Subject: [PATCH 7/9] Update gitrpc/internal/gitea/commit.go --- gitrpc/internal/gitea/commit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index 033c4ef9e..bd6ae2042 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -88,7 +88,7 @@ func (g Adapter) listCommitSHAs( limit int, filter types.CommitFilter, ) ([]string, error) { - args := make([]string, 0, 12) + args := make([]string, 0, 16) args = append(args, "rev-list") // return commits only up to a certain reference if requested From f34f267084cebfe5c8e663ece0b167f25f745b23 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 15:12:06 -0700 Subject: [PATCH 8/9] feat: [CODE-200]: list commits with date filter --- gitrpc/internal/gitea/commit.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index bd6ae2042..2e6c57dfa 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -117,10 +117,10 @@ func (g Adapter) listCommitSHAs( args = append(args, "--date", "unix") } if filter.Since > 0 { - args = append(args, "--since", fmt.Sprint(filter.Since)) + args = append(args, "--since", strconv.FormatInt(filter.Since, 10)) } if filter.Until > 0 { - args = append(args, "--until", fmt.Sprint(filter.Until)) + args = append(args, "--until", strconv.FormatInt(filter.Until, 10)) } stdout, _, runErr := gitea.NewCommand(giteaRepo.Ctx, args...).RunStdBytes(&gitea.RunOpts{Dir: giteaRepo.Path}) From a6615c91a2c309a8dcd628593d0ef377851dafbc Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 17 May 2023 15:22:59 -0700 Subject: [PATCH 9/9] feat: [CODE-200]: list commits with date filter --- internal/api/controller/repo/list_commits.go | 9 +++---- internal/api/handler/repo/list_commits.go | 27 +++++++++----------- internal/api/request/git.go | 15 +++++++++-- types/git.go | 3 +++ 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/internal/api/controller/repo/list_commits.go b/internal/api/controller/repo/list_commits.go index d47d08c71..c5a4a0f42 100644 --- a/internal/api/controller/repo/list_commits.go +++ b/internal/api/controller/repo/list_commits.go @@ -20,8 +20,7 @@ import ( * ListCommits lists the commits of a repo. */ func (c *Controller) ListCommits(ctx context.Context, session *auth.Session, - repoRef string, gitRef string, filter *types.CommitFilter, path string, - since int64, until int64) ([]types.Commit, *types.RenameDetails, error) { + repoRef string, gitRef string, filter *types.CommitFilter) ([]types.Commit, *types.RenameDetails, error) { repo, err := c.repoStore.FindByRef(ctx, repoRef) if err != nil { return nil, nil, err @@ -42,9 +41,9 @@ func (c *Controller) ListCommits(ctx context.Context, session *auth.Session, After: filter.After, Page: int32(filter.Page), Limit: int32(filter.Limit), - Path: path, - Since: since, - Until: until, + Path: filter.Path, + Since: filter.Since, + Until: filter.Until, }) if err != nil { return nil, nil, err diff --git a/internal/api/handler/repo/list_commits.go b/internal/api/handler/repo/list_commits.go index acde34672..6ab3b278a 100644 --- a/internal/api/handler/repo/list_commits.go +++ b/internal/api/handler/repo/list_commits.go @@ -28,9 +28,13 @@ func HandleListCommits(repoCtrl *repo.Controller) http.HandlerFunc { gitRef := request.GetGitRefFromQueryOrDefault(r, "") - filter := request.ParseCommitFilter(r) + filter, err := request.ParseCommitFilter(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } - commits, _, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter, "", 0, 0) + commits, _, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter) if err != nil { render.TranslatedUserError(w, err) return @@ -58,20 +62,13 @@ func HandleListCommitsV2(repoCtrl *repo.Controller) http.HandlerFunc { gitRef := request.GetGitRefFromQueryOrDefault(r, "") - filter := request.ParseCommitFilter(r) + filter, err := request.ParseCommitFilter(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } - path := request.GetPathFromQueryOrDefault(r, "") - since, err := request.GetSinceFromQuery(r) - if err != nil { - render.TranslatedUserError(w, err) - return - } - until, err := request.GetUntilFromQuery(r) - if err != nil { - render.TranslatedUserError(w, err) - return - } - commits, renameDetails, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter, path, since, until) + commits, renameDetails, err := repoCtrl.ListCommits(ctx, session, repoRef, gitRef, filter) if err != nil { render.TranslatedUserError(w, err) return diff --git a/internal/api/request/git.go b/internal/api/request/git.go index 85c566c2b..96672895c 100644 --- a/internal/api/request/git.go +++ b/internal/api/request/git.go @@ -71,14 +71,25 @@ func ParseTagFilter(r *http.Request) *types.TagFilter { } // ParseCommitFilter extracts the commit filter from the url. -func ParseCommitFilter(r *http.Request) *types.CommitFilter { +func ParseCommitFilter(r *http.Request) (*types.CommitFilter, error) { + since, err := QueryParamAsPositiveInt64(r, QuerySince) + if err != nil { + return nil, err + } + until, err := QueryParamAsPositiveInt64(r, QueryUntil) + if err != nil { + return nil, err + } return &types.CommitFilter{ After: QueryParamOrDefault(r, QueryParamAfter, ""), PaginationFilter: types.PaginationFilter{ Page: ParsePage(r), Limit: ParseLimit(r), }, - } + Path: QueryParamOrDefault(r, QueryPath, ""), + Since: since, + Until: until, + }, nil } func GetPathFromQueryOrDefault(r *http.Request, deflt string) string { diff --git a/types/git.go b/types/git.go index 52e1303d6..602697ec4 100644 --- a/types/git.go +++ b/types/git.go @@ -22,6 +22,9 @@ type PaginationFilter struct { type CommitFilter struct { PaginationFilter After string `json:"after"` + Path string `json:"path"` + Since int64 `json:"since"` + Until int64 `json:"until"` } // BranchFilter stores branch query parameters.