From 6c567b38d0cfa5afac3b5ce9e947a27d3f09cffe Mon Sep 17 00:00:00 2001 From: Johannes Batzill Date: Thu, 5 Jan 2023 11:03:35 -0800 Subject: [PATCH] [MISC] Move GitRPC to Read/WriteRequest, Update Create/Delete Branch to use Push, Setup githook Symlink, Accept Incoming X-Request-Id (#157) --- cli/server/config.go | 25 +- cli/server/harness.wire_gen.go | 3 +- cli/server/standalone.wire_gen.go | 2 +- gitrpc/blob.go | 5 +- gitrpc/branch.go | 15 +- gitrpc/client.go | 5 - gitrpc/common.go | 47 ++ gitrpc/{rpc/metadata.go => config.go} | 10 +- gitrpc/diff.go | 14 +- gitrpc/interface.go | 4 +- gitrpc/internal/gitea/branch.go | 31 ++ gitrpc/internal/middleware/log.go | 36 +- gitrpc/internal/service/blob.go | 8 +- gitrpc/internal/service/branch.go | 109 +++-- gitrpc/internal/service/commit.go | 14 +- gitrpc/internal/service/diff.go | 19 +- gitrpc/internal/service/env.go | 11 +- gitrpc/internal/service/http.go | 77 +-- gitrpc/internal/service/interface.go | 1 + gitrpc/internal/service/operations.go | 38 +- gitrpc/internal/service/ref.go | 24 +- gitrpc/internal/service/repo.go | 53 +- gitrpc/internal/service/shared_repo.go | 132 +++-- gitrpc/internal/service/submodule.go | 8 +- gitrpc/internal/service/tag.go | 7 +- gitrpc/internal/service/tree.go | 15 +- gitrpc/internal/types/errors.go | 1 + gitrpc/log_interceptor.go | 20 +- gitrpc/operations.go | 28 +- gitrpc/proto/diff.proto | 8 +- gitrpc/proto/http.proto | 27 +- gitrpc/proto/operations.proto | 4 +- gitrpc/proto/ref.proto | 22 +- gitrpc/proto/repo.proto | 38 +- gitrpc/proto/shared.proto | 17 +- gitrpc/ref.go | 8 +- gitrpc/repo.go | 11 +- gitrpc/rpc/constants.go | 16 + gitrpc/rpc/diff.pb.go | 67 +-- gitrpc/rpc/http.pb.go | 181 ++++--- gitrpc/rpc/operations.pb.go | 145 +++--- gitrpc/rpc/ref.pb.go | 298 ++++++------ gitrpc/rpc/repo.pb.go | 460 +++++++++--------- gitrpc/rpc/shared.pb.go | 377 +++++++++++--- gitrpc/server/config.go | 7 +- gitrpc/server/server.go | 15 +- gitrpc/server/wire.go | 6 +- gitrpc/smarthttp.go | 46 +- gitrpc/submodule.go | 9 +- gitrpc/tag.go | 5 +- gitrpc/tree.go | 10 +- internal/api/controller/pullreq/controller.go | 9 +- internal/api/controller/repo/commit.go | 12 +- internal/api/controller/repo/controller.go | 27 + internal/api/controller/repo/create_branch.go | 6 +- internal/api/controller/repo/delete_branch.go | 4 +- internal/api/controller/repo/diff.go | 4 +- .../controller/repo/get_commit_divergences.go | 6 +- internal/api/controller/repo/get_content.go | 42 +- internal/api/controller/repo/list_branches.go | 2 +- .../api/controller/repo/list_commit_tags.go | 2 +- internal/api/controller/repo/list_commits.go | 10 +- internal/api/handler/repo/http_git.go | 22 +- .../api/middleware/accesslog/accesslog.go | 27 - internal/api/middleware/logging/logging.go | 69 +++ internal/api/request/context.go | 15 + internal/auth/authz/unsafe.go | 2 +- internal/router/api.go | 6 +- internal/router/git.go | 6 +- internal/webhook/branch.go | 6 +- types/config.go | 16 +- types/git.go | 2 + 72 files changed, 1756 insertions(+), 1078 deletions(-) create mode 100644 gitrpc/common.go rename gitrpc/{rpc/metadata.go => config.go} (57%) create mode 100644 gitrpc/rpc/constants.go delete mode 100644 internal/api/middleware/accesslog/accesslog.go create mode 100644 internal/api/middleware/logging/logging.go diff --git a/cli/server/config.go b/cli/server/config.go index c647089be..5737a532f 100644 --- a/cli/server/config.go +++ b/cli/server/config.go @@ -41,6 +41,11 @@ func load() (*types.Config, error) { return nil, fmt.Errorf("unable to ensure that git root is set in config: %w", err) } + err = ensureGitServerHookIsSet(config) + if err != nil { + return nil, fmt.Errorf("unable to ensure that server hook is set in config: %w", err) + } + return config, nil } @@ -89,6 +94,19 @@ func ensureGitRootIsSet(config *types.Config) error { return nil } +func ensureGitServerHookIsSet(config *types.Config) error { + if config.Git.ServerHookPath == "" { + executablePath, err := os.Executable() + if err != nil { + return fmt.Errorf("failed to get path of current executable: %w", err) + } + + config.Git.ServerHookPath = executablePath + } + + return nil +} + // PackageConfigsWireSet contains providers that generate configs required for sub packages. var PackageConfigsWireSet = wire.NewSet( ProvideGitRPCServerConfig, @@ -99,9 +117,10 @@ var PackageConfigsWireSet = wire.NewSet( func ProvideGitRPCServerConfig(config *types.Config) server.Config { return server.Config{ - Bind: config.Server.GRPC.Bind, - GitRoot: config.Git.Root, - ReposTempPath: config.Git.ReposTempPath, + Bind: config.Server.GRPC.Bind, + GitRoot: config.Git.Root, + TmpDir: config.Git.TmpDir, + ServerHookPath: config.Git.ServerHookPath, } } diff --git a/cli/server/harness.wire_gen.go b/cli/server/harness.wire_gen.go index ede937b69..3c27c3f3b 100644 --- a/cli/server/harness.wire_gen.go +++ b/cli/server/harness.wire_gen.go @@ -7,7 +7,6 @@ package server import ( "context" - "github.com/harness/gitness/events" "github.com/harness/gitness/gitrpc" events2 "github.com/harness/gitness/gitrpc/events" @@ -129,7 +128,7 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) { routerRouter := router2.ProvideRouter(apiHandler, gitHandler, webHandler) serverServer := server.ProvideServer(config, routerRouter) serverConfig := ProvideGitRPCServerConfig(config) - server3, err := server2.ProvideServer(serverConfig, eventsSystem) + server3, err := server2.ProvideServer(serverConfig) if err != nil { return nil, err } diff --git a/cli/server/standalone.wire_gen.go b/cli/server/standalone.wire_gen.go index cbf7e93a7..60e04da49 100644 --- a/cli/server/standalone.wire_gen.go +++ b/cli/server/standalone.wire_gen.go @@ -90,7 +90,7 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) { routerRouter := router.ProvideRouter(apiHandler, gitHandler, webHandler) serverServer := server.ProvideServer(config, routerRouter) serverConfig := ProvideGitRPCServerConfig(config) - server3, err := server2.ProvideServer(serverConfig, eventsSystem) + server3, err := server2.ProvideServer(serverConfig) if err != nil { return nil, err } diff --git a/gitrpc/blob.go b/gitrpc/blob.go index f9716e683..a6d88575e 100644 --- a/gitrpc/blob.go +++ b/gitrpc/blob.go @@ -12,7 +12,7 @@ import ( ) type GetBlobParams struct { - RepoUID string + ReadParams SHA string SizeLimit int64 } @@ -33,8 +33,9 @@ func (c *Client) GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobOu if params == nil { return nil, ErrNoParamsProvided } + resp, err := c.repoService.GetBlob(ctx, &rpc.GetBlobRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), Sha: params.SHA, SizeLimit: params.SizeLimit, }) diff --git a/gitrpc/branch.go b/gitrpc/branch.go index 53a978d68..57a2c9c78 100644 --- a/gitrpc/branch.go +++ b/gitrpc/branch.go @@ -24,8 +24,7 @@ const ( ) type CreateBranchParams struct { - // RepoUID is the uid of the git repository - RepoUID string + WriteParams // BranchName is the name of the branch BranchName string // Target is a git reference (branch / tag / commit SHA) @@ -37,15 +36,13 @@ type CreateBranchOutput struct { } type DeleteBranchParams struct { - // RepoUID is the uid of the git repository - RepoUID string + WriteParams // Name is the name of the branch BranchName string } type ListBranchesParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams IncludeCommit bool Query string Sort BranchSortOption @@ -69,7 +66,7 @@ func (c *Client) CreateBranch(ctx context.Context, params *CreateBranchParams) ( return nil, ErrNoParamsProvided } resp, err := c.refService.CreateBranch(ctx, &rpc.CreateBranchRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCWriteRequest(params.WriteParams), Target: params.Target, BranchName: params.BranchName, }) @@ -93,7 +90,7 @@ func (c *Client) DeleteBranch(ctx context.Context, params *DeleteBranchParams) e return ErrNoParamsProvided } _, err := c.refService.DeleteBranch(ctx, &rpc.DeleteBranchRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCWriteRequest(params.WriteParams), BranchName: params.BranchName, // TODO: what are scenarios where we wouldn't want to force delete? // Branch protection is a different story, and build on top application layer. @@ -112,7 +109,7 @@ func (c *Client) ListBranches(ctx context.Context, params *ListBranchesParams) ( } stream, err := c.refService.ListBranches(ctx, &rpc.ListBranchesRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), IncludeCommit: params.IncludeCommit, Query: params.Query, Sort: mapToRPCListBranchesSortOption(params.Sort), diff --git a/gitrpc/client.go b/gitrpc/client.go index f7c0998e1..9ffe5bf85 100644 --- a/gitrpc/client.go +++ b/gitrpc/client.go @@ -11,11 +11,6 @@ import ( "google.golang.org/grpc/credentials/insecure" ) -// Config represents the config for the gitrpc client. -type Config struct { - Bind string -} - type Client struct { conn *grpc.ClientConn repoService rpc.RepositoryServiceClient diff --git a/gitrpc/common.go b/gitrpc/common.go new file mode 100644 index 000000000..ab94a8dc2 --- /dev/null +++ b/gitrpc/common.go @@ -0,0 +1,47 @@ +// 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 gitrpc + +import "github.com/harness/gitness/gitrpc/rpc" + +// ReadParams contains the base parameters for read operations. +type ReadParams struct { + RepoUID string +} + +// WriteParams contains the base parameters for write operations. +type WriteParams struct { + RepoUID string + Actor Identity + EnvVars map[string]string +} + +func mapToRPCReadRequest(p ReadParams) *rpc.ReadRequest { + return &rpc.ReadRequest{ + RepoUid: p.RepoUID, + } +} + +func mapToRPCWriteRequest(p WriteParams) *rpc.WriteRequest { + out := &rpc.WriteRequest{ + RepoUid: p.RepoUID, + Actor: &rpc.Identity{ + Name: p.Actor.Name, + Email: p.Actor.Email, + }, + EnvVars: make([]*rpc.EnvVar, len(p.EnvVars)), + } + + i := 0 + for k, v := range p.EnvVars { + out.EnvVars[i] = &rpc.EnvVar{ + Name: k, + Value: v, + } + i++ + } + + return out +} diff --git a/gitrpc/rpc/metadata.go b/gitrpc/config.go similarity index 57% rename from gitrpc/rpc/metadata.go rename to gitrpc/config.go index 37f8ce589..8af8b6581 100644 --- a/gitrpc/rpc/metadata.go +++ b/gitrpc/config.go @@ -2,9 +2,9 @@ // 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 rpc +package gitrpc -const ( - // MetadataKeyRequestID is the key used to store the request ID in the metadata. - MetadataKeyRequestID = "request-id" -) +// Config represents the config for the gitrpc client. +type Config struct { + Bind string +} diff --git a/gitrpc/diff.go b/gitrpc/diff.go index 712bf77a6..1f46e6056 100644 --- a/gitrpc/diff.go +++ b/gitrpc/diff.go @@ -13,17 +13,17 @@ import ( "github.com/harness/gitness/gitrpc/rpc" ) -type RawDiffRequest struct { - RepoID string +type RawDiffParams struct { + ReadParams LeftCommitID string RightCommitID string } -func (c *Client) RawDiff(ctx context.Context, in *RawDiffRequest, w io.Writer) error { +func (c *Client) RawDiff(ctx context.Context, params *RawDiffParams, out io.Writer) error { diff, err := c.diffService.RawDiff(ctx, &rpc.RawDiffRequest{ - RepoId: in.RepoID, - LeftCommitId: in.LeftCommitID, - RightCommitId: in.RightCommitID, + Base: mapToRPCReadRequest(params.ReadParams), + LeftCommitId: params.LeftCommitID, + RightCommitId: params.RightCommitID, }) if err != nil { return err @@ -35,7 +35,7 @@ func (c *Client) RawDiff(ctx context.Context, in *RawDiffRequest, w io.Writer) e return resp.GetData(), err }) - if _, err = io.Copy(w, reader); err != nil { + if _, err = io.Copy(out, reader); err != nil { return fmt.Errorf("copy rpc data: %w", err) } diff --git a/gitrpc/interface.go b/gitrpc/interface.go index efd99eb17..3811f4c41 100644 --- a/gitrpc/interface.go +++ b/gitrpc/interface.go @@ -26,7 +26,7 @@ type Interface interface { ListCommits(ctx context.Context, params *ListCommitsParams) (*ListCommitsOutput, error) ListCommitTags(ctx context.Context, params *ListCommitTagsParams) (*ListCommitTagsOutput, error) GetCommitDivergences(ctx context.Context, params *GetCommitDivergencesParams) (*GetCommitDivergencesOutput, error) - CommitFiles(ctx context.Context, params *CommitFilesOptions) (CommitFilesResponse, error) + CommitFiles(ctx context.Context, params *CommitFilesParams) (CommitFilesResponse, error) /* * Git Cli Service @@ -37,5 +37,5 @@ type Interface interface { /* * Diff services */ - RawDiff(ctx context.Context, in *RawDiffRequest, w io.Writer) error + RawDiff(ctx context.Context, in *RawDiffParams, w io.Writer) error } diff --git a/gitrpc/internal/gitea/branch.go b/gitrpc/internal/gitea/branch.go index 6d068f4b3..82857983f 100644 --- a/gitrpc/internal/gitea/branch.go +++ b/gitrpc/internal/gitea/branch.go @@ -59,6 +59,37 @@ func (g Adapter) CreateBranch(ctx context.Context, repoPath string, }, nil } +// GetBranch gets an existing branch. +func (g Adapter) GetBranch(ctx context.Context, repoPath string, + branchName string) (*types.Branch, error) { + giteaRepo, err := gitea.OpenRepository(ctx, repoPath) + if err != nil { + return nil, err + } + defer giteaRepo.Close() + + giteaBranch, err := giteaRepo.GetBranch(branchName) + if err != nil { + return nil, processGiteaErrorf(err, "failed to get branch '%s'", branchName) + } + + giteaCommit, err := giteaBranch.GetCommit() + if err != nil { + return nil, processGiteaErrorf(err, "failed to get commit '%s'", branchName) + } + + commit, err := mapGiteaCommit(giteaCommit) + if err != nil { + return nil, fmt.Errorf("failed to map gitea commit: %w", err) + } + + return &types.Branch{ + Name: giteaBranch.Name, + SHA: giteaCommit.ID.String(), + Commit: commit, + }, nil +} + // DeleteBranch deletes an existing branch. func (g Adapter) DeleteBranch(ctx context.Context, repoPath string, branchName string, force bool) (string, error) { giteaRepo, err := gitea.OpenRepository(ctx, repoPath) diff --git a/gitrpc/internal/middleware/log.go b/gitrpc/internal/middleware/log.go index 0402c0717..4d05d8f3b 100644 --- a/gitrpc/internal/middleware/log.go +++ b/gitrpc/internal/middleware/log.go @@ -19,6 +19,13 @@ import ( "google.golang.org/grpc/status" ) +const ( + RequestIDNone string = "gitrpc_none" +) + +// requestIDKey is context key for storing and retrieving the request ID to and from a context. +type requestIDKey struct{} + // LogInterceptor injects a zerolog logger with common grpc related annotations and logs the completion of the call. // If the metadata contains a request id, the logger is annotated with the same request ID, otherwise with a new one. type LogInterceptor struct { @@ -31,7 +38,7 @@ func NewLogInterceptor() LogInterceptor { func (i LogInterceptor) UnaryInterceptor() grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - ctx = injectLogger(ctx, info.FullMethod) + ctx = injectLogging(ctx, info.FullMethod) // measure execution time start := time.Now() @@ -46,7 +53,7 @@ func (i LogInterceptor) UnaryInterceptor() grpc.UnaryServerInterceptor { func (i LogInterceptor) StreamInterceptor() grpc.StreamServerInterceptor { return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { - ctx := injectLogger(stream.Context(), info.FullMethod) + ctx := injectLogging(stream.Context(), info.FullMethod) // wrap stream with updated context stream = &logServerStream{ @@ -64,7 +71,22 @@ func (i LogInterceptor) StreamInterceptor() grpc.StreamServerInterceptor { } } -func injectLogger(ctx context.Context, fullMethod string) context.Context { +// WithRequestID returns a copy of parent in which the request id value is set. +func WithRequestID(parent context.Context, v string) context.Context { + return context.WithValue(parent, requestIDKey{}, v) +} + +// RequestIDFrom retrieves the request id from the context. +// If no request id exists, RequestIDNone is returned. +func RequestIDFrom(ctx context.Context) string { + if v, ok := ctx.Value(requestIDKey{}).(string); ok { + return v + } + + return RequestIDNone +} + +func injectLogging(ctx context.Context, fullMethod string) context.Context { // split fullMethod into service and method (expected format: "/package.service/method...") // If it doesn't match the expected format, the full string is put into method. service, method := "", fullMethod @@ -74,11 +96,15 @@ func injectLogger(ctx context.Context, fullMethod string) context.Context { } } + // get request id (or create a new one) and inject it for later usage (git env variables) + requestID := getOrCreateRequestID(ctx) + ctx = WithRequestID(ctx, requestID) + // create new logCtx with injected info logCtx := log.Logger.With(). Str("grpc.service", service). Str("grpc.method", method). - Str("grpc.request_id", getOrCreateRequestID(ctx)) + Str("grpc.request_id", requestID) // add peer information if available if p, ok := peer.FromContext(ctx); ok && p.Addr != nil { @@ -110,7 +136,7 @@ func getOrCreateRequestID(ctx context.Context) string { } } - // use same type of request IDs as used for http + // use same type of request IDs as used by zerolog return xid.New().String() } diff --git a/gitrpc/internal/service/blob.go b/gitrpc/internal/service/blob.go index d2417cce3..7a3c1824e 100644 --- a/gitrpc/internal/service/blob.go +++ b/gitrpc/internal/service/blob.go @@ -7,11 +7,17 @@ package service import ( "context" + "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" ) func (s RepositoryService) GetBlob(ctx context.Context, request *rpc.GetBlobRequest) (*rpc.GetBlobResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) // TODO: do we need to validate request for nil? gitBlob, err := s.adapter.GetBlob(ctx, repoPath, request.GetSha(), request.GetSizeLimit()) if err != nil { diff --git a/gitrpc/internal/service/branch.go b/gitrpc/internal/service/branch.go index e77e20edb..7abf5974e 100644 --- a/gitrpc/internal/service/branch.go +++ b/gitrpc/internal/service/branch.go @@ -8,11 +8,11 @@ import ( "context" "fmt" - "github.com/harness/gitness/gitrpc/events" "github.com/harness/gitness/gitrpc/internal/gitea" "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" + "code.gitea.io/gitea/modules/git" "github.com/rs/zerolog/log" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -22,20 +22,43 @@ var listBranchesRefFields = []types.GitReferenceField{types.GitReferenceFieldRef func (s ReferenceService) CreateBranch(ctx context.Context, request *rpc.CreateBranchRequest) (*rpc.CreateBranchResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) - - gitBranch, err := s.adapter.CreateBranch(ctx, repoPath, request.GetBranchName(), request.GetTarget()) - if err != nil { - return nil, processGitErrorf(err, "failed to create branch") + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty } - // at this point the branch got created (emit event even if we'd fail to map the git branch) - s.eventReporter.BranchCreated(ctx, &events.BranchCreatedPayload{ - RepoUID: request.RepoUid, - BranchName: request.BranchName, - FullRef: fmt.Sprintf("refs/heads/%s", request.BranchName), - SHA: gitBranch.SHA, - }) + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) + + // TODO: why are we using gitea operations here?! + repo, err := git.OpenRepository(ctx, repoPath) + if err != nil { + return nil, processGitErrorf(err, "failed to open repo") + } + + sharedRepo, err := NewSharedRepo(s.tmpDir, base.GetRepoUid(), repo) + if err != nil { + return nil, processGitErrorf(err, "failed to create new shared repo") + } + defer sharedRepo.Close(ctx) + + // clone repo + err = sharedRepo.Clone(ctx, request.GetTarget()) + if err != nil { + return nil, processGitErrorf(err, "failed to clone shared repo with branch '%s'", request.GetBranchName()) + } + + // push to new branch (all changes should go through push flow for hooks and other safety meassures) + err = sharedRepo.Push(ctx, base, request.GetTarget(), request.GetBranchName()) + if err != nil { + return nil, processGitErrorf(err, "failed to push new branch '%s'", request.GetBranchName()) + } + + // get branch + // TODO: get it from shared repo to avoid opening another gitea repo + gitBranch, err := s.adapter.GetBranch(ctx, repoPath, request.GetBranchName()) + if err != nil { + return nil, processGitErrorf(err, "failed to get gitea branch '%s'", request.GetBranchName()) + } branch, err := mapGitBranch(gitBranch) if err != nil { @@ -49,29 +72,59 @@ func (s ReferenceService) CreateBranch(ctx context.Context, func (s ReferenceService) DeleteBranch(ctx context.Context, request *rpc.DeleteBranchRequest) (*rpc.DeleteBranchResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) - - // TODO: block deletion of protected branch (in the future) - sha, err := s.adapter.DeleteBranch(ctx, repoPath, request.GetBranchName(), request.GetForce()) - if err != nil { - return nil, processGitErrorf(err, "failed to delete branch") + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty } - // at this point the branch got created (emit event even if we'd fail to map the git branch) - s.eventReporter.BranchDeleted(ctx, &events.BranchDeletedPayload{ - RepoUID: request.RepoUid, - BranchName: request.BranchName, - FullRef: fmt.Sprintf("refs/heads/%s", request.BranchName), - SHA: sha, - }) + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) - return &rpc.DeleteBranchResponse{}, nil + // TODO: why are we using gitea operations here?! + repo, err := git.OpenRepository(ctx, repoPath) + if err != nil { + return nil, processGitErrorf(err, "failed to open repo") + } + + sharedRepo, err := NewSharedRepo(s.tmpDir, base.GetRepoUid(), repo) + if err != nil { + return nil, processGitErrorf(err, "failed to create new shared repo") + } + defer sharedRepo.Close(ctx) + + // clone repo (technically we don't care about which branch we clone) + err = sharedRepo.Clone(ctx, request.GetBranchName()) + if err != nil { + return nil, processGitErrorf(err, "failed to clone shared repo with branch '%s'", request.GetBranchName()) + } + + // get latest branch commit before we delete + gitCommit, err := sharedRepo.GetBranchCommit(request.GetBranchName()) + if err != nil { + return nil, processGitErrorf(err, "failed to get gitea commit for branch '%s'", request.GetBranchName()) + } + + // push to new branch (all changes should go through push flow for hooks and other safety meassures) + // NOTE: setting sourceRef to empty will delete the remote branch when pushing: + // https://git-scm.com/docs/git-push#Documentation/git-push.txt-ltrefspecgt82308203 + err = sharedRepo.Push(ctx, base, "", request.GetBranchName()) + if err != nil { + return nil, processGitErrorf(err, "failed to delete branch '%s' from remote repo", request.GetBranchName()) + } + + return &rpc.DeleteBranchResponse{ + Sha: gitCommit.ID.String(), + }, nil } func (s ReferenceService) ListBranches(request *rpc.ListBranchesRequest, stream rpc.ReferenceService_ListBranchesServer) error { + base := request.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty + } + ctx := stream.Context() - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) // get all required information from git refrences branches, err := s.listBranchesLoadReferenceData(ctx, repoPath, request) diff --git a/gitrpc/internal/service/commit.go b/gitrpc/internal/service/commit.go index bd14511fa..7afe3ad92 100644 --- a/gitrpc/internal/service/commit.go +++ b/gitrpc/internal/service/commit.go @@ -17,8 +17,13 @@ import ( func (s RepositoryService) ListCommits(request *rpc.ListCommitsRequest, stream rpc.RepositoryService_ListCommitsServer) error { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty + } + ctx := stream.Context() + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) gitCommits, err := s.adapter.ListCommits(ctx, repoPath, request.GetGitRef(), request.GetAfter(), int(request.GetPage()), int(request.GetLimit())) @@ -58,7 +63,12 @@ func (s RepositoryService) getLatestCommit(ctx context.Context, repoPath string, func (s RepositoryService) GetCommitDivergences(ctx context.Context, request *rpc.GetCommitDivergencesRequest) (*rpc.GetCommitDivergencesResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) // map to gitea requests requests := request.GetRequests() diff --git a/gitrpc/internal/service/diff.go b/gitrpc/internal/service/diff.go index f756e3dd1..5885f143f 100644 --- a/gitrpc/internal/service/diff.go +++ b/gitrpc/internal/service/diff.go @@ -30,21 +30,22 @@ func NewDiffService(adapter GitAdapter, reposRoot string) (*DiffService, error) }, nil } -func (s DiffService) RawDiff(req *rpc.RawDiffRequest, stream rpc.DiffService_RawDiffServer) error { - err := validateDiffRequest(req) +func (s DiffService) RawDiff(request *rpc.RawDiffRequest, stream rpc.DiffService_RawDiffServer) error { + err := validateDiffRequest(request) if err != nil { return err } ctx := stream.Context() + base := request.GetBase() sw := streamio.NewWriter(func(p []byte) error { return stream.Send(&rpc.RawDiffResponse{Data: p}) }) - repoPath := getFullPathForRepo(s.reposRoot, req.GetRepoId()) + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) - cmd := git.NewCommand(ctx, "diff", "--full-index", req.LeftCommitId, req.RightCommitId) + cmd := git.NewCommand(ctx, "diff", "--full-index", request.LeftCommitId, request.RightCommitId) cmd.SetDescription(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath)) return cmd.Run(&git.RunOpts{ Timeout: time.Duration(setting.Git.Timeout.Default) * time.Second, @@ -54,12 +55,10 @@ func (s DiffService) RawDiff(req *rpc.RawDiffRequest, stream rpc.DiffService_Raw }) } -type requestWithLeftRightCommitIds interface { - GetLeftCommitId() string - GetRightCommitId() string -} - -func validateDiffRequest(in requestWithLeftRightCommitIds) error { +func validateDiffRequest(in *rpc.RawDiffRequest) error { + if in.GetBase() == nil { + return types.ErrBaseCannotBeEmpty + } if in.GetLeftCommitId() == "" { return types.ErrEmptyLeftCommitID } diff --git a/gitrpc/internal/service/env.go b/gitrpc/internal/service/env.go index 82df20cf3..77163cf8a 100644 --- a/gitrpc/internal/service/env.go +++ b/gitrpc/internal/service/env.go @@ -5,11 +5,8 @@ package service const ( - EnvRepoUID = "GITNESS_REPO_UID" - EnvRepoName = "GITNESS_REPO_NAME" - EnvRepoID = "GITNESS_REPO_UID" - EnvPusherName = "GITNESS_PUSHER_NAME" - EnvPusherID = "GITNESS_PUSHER_ID" - EnvAppURL = "GITNESS_ROOT_URL" // base url for Gitness server - EnvPusherEmail = "GITNESS_PUSHER_EMAIL" + EnvPusherName = "GITRPC_PUSHER_NAME" + EnvPusherEmail = "GITRPC_PUSHER_EMAIL" + EnvRepoUID = "GITRPC_REPO_UID" + EnvRequestID = "GITRPC_REQUEST_ID" ) diff --git a/gitrpc/internal/service/http.go b/gitrpc/internal/service/http.go index 3fdc84be8..a6bad6d60 100644 --- a/gitrpc/internal/service/http.go +++ b/gitrpc/internal/service/http.go @@ -9,12 +9,12 @@ import ( "context" "fmt" "io" - "os" "regexp" "strconv" "strings" "github.com/harness/gitness/gitrpc/internal/streamio" + "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" "code.gitea.io/gitea/modules/git" @@ -23,10 +23,6 @@ import ( "google.golang.org/grpc/status" ) -const ( - receivePack = "receive-pack" -) - var safeGitProtocolHeader = regexp.MustCompile(`^[0-9a-zA-Z]+=[0-9a-zA-Z]+(:[0-9a-zA-Z]+=[0-9a-zA-Z]+)*$`) type SmartHTTPService struct { @@ -43,23 +39,29 @@ func NewHTTPService(adapter GitAdapter, reposRoot string) (*SmartHTTPService, er } func (s *SmartHTTPService) InfoRefs( - r *rpc.InfoRefsRequest, + request *rpc.InfoRefsRequest, stream rpc.SmartHTTPService_InfoRefsServer, ) error { - environ := make([]string, 0) - environ = append(os.Environ(), environ...) - if r.GitProtocol != "" { - environ = append(environ, "GIT_PROTOCOL="+r.GitProtocol) + ctx := stream.Context() + base := request.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty } - repoPath := getFullPathForRepo(s.reposRoot, r.GetRepoUid()) + // NOTE: Don't include os.Environ() as we don't have control over it - define everything explicitly + environ := []string{} + if request.GitProtocol != "" { + environ = append(environ, "GIT_PROTOCOL="+request.GitProtocol) + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) w := streamio.NewWriter(func(p []byte) error { return stream.Send(&rpc.InfoRefsResponse{Data: p}) }) cmd := &bytes.Buffer{} - if err := git.NewCommand(stream.Context(), r.GetService(), "--stateless-rpc", "--advertise-refs", "."). + if err := git.NewCommand(ctx, request.GetService(), "--stateless-rpc", "--advertise-refs", "."). Run(&git.RunOpts{ Env: environ, Dir: repoPath, @@ -67,7 +69,7 @@ func (s *SmartHTTPService) InfoRefs( }); err != nil { return status.Errorf(codes.Internal, "InfoRefsUploadPack: cmd: %v", err) } - if _, err := w.Write(packetWrite("# service=git-" + r.GetService() + "\n")); err != nil { + if _, err := w.Write(packetWrite("# service=git-" + request.GetService() + "\n")); err != nil { return status.Errorf(codes.Internal, "InfoRefsUploadPack: pktLine: %v", err) } @@ -84,20 +86,33 @@ func (s *SmartHTTPService) InfoRefs( func (s *SmartHTTPService) ServicePack(stream rpc.SmartHTTPService_ServicePackServer) error { ctx := stream.Context() // Get basic repo data - req, err := stream.Recv() + request, err := stream.Recv() if err != nil { return err } // if client sends data as []byte raise error, needs reader - if req.Data != nil { - return status.Errorf(codes.InvalidArgument, "PostUploadPack(): non-empty Data") + if request.GetData() != nil { + return status.Errorf(codes.InvalidArgument, "ServicePack(): non-empty Data") } - if req.RepoUid == "" { - return status.Errorf(codes.InvalidArgument, "PostUploadPack(): repository UID is missing") + // ensure we have the correct base type that matches the services to be triggered + var repoUID string + switch request.GetService() { + case rpc.ServiceUploadPack: + if request.GetReadBase() == nil { + return status.Errorf(codes.InvalidArgument, "ServicePack(): read base is missing for upload-pack") + } + repoUID = request.GetReadBase().GetRepoUid() + case rpc.ServiceReceivePack: + if request.GetWriteBase() == nil { + return status.Errorf(codes.InvalidArgument, "ServicePack(): write base is missing for receive-pack") + } + repoUID = request.GetWriteBase().GetRepoUid() + default: + return status.Errorf(codes.InvalidArgument, "ServicePack(): unsupported service '%s'", request.GetService()) } - repoPath := getFullPathForRepo(s.reposRoot, req.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, repoUID) stdin := streamio.NewReader(func() ([]byte, error) { resp, streamErr := stream.Recv() @@ -108,21 +123,19 @@ func (s *SmartHTTPService) ServicePack(stream rpc.SmartHTTPService_ServicePackSe return stream.Send(&rpc.ServicePackResponse{Data: p}) }) - return serviceRPC(ctx, stdin, stdout, req, repoPath) + return serviceRPC(ctx, stdin, stdout, request, repoPath) } -func serviceRPC(ctx context.Context, stdin io.Reader, stdout io.Writer, req *rpc.ServicePackRequest, dir string) error { - protocol := req.GetGitProtocol() - service := req.GetService() - principalID := req.GetPrincipalId() - repoUID := req.GetRepoUid() +func serviceRPC(ctx context.Context, stdin io.Reader, stdout io.Writer, + request *rpc.ServicePackRequest, dir string) error { + protocol := request.GetGitProtocol() + service := request.GetService() - environ := make([]string, 0) - if service == receivePack && principalID != "" { - environ = []string{ - EnvRepoUID + "=" + repoUID, - EnvPusherID + "=" + principalID, - } + // NOTE: Don't include os.Environ() as we don't have control over it - define everything explicitly + environ := []string{} + if request.GetWriteBase() != nil { + // in case of a write operation inject the provided environment variables + environ = CreateEnvironmentForPush(ctx, request.GetWriteBase()) } // set this for allow pre-receive and post-receive execute environ = append(environ, "SSH_ORIGINAL_COMMAND="+service) @@ -138,7 +151,7 @@ func serviceRPC(ctx context.Context, stdin io.Reader, stdout io.Writer, req *rpc cmd.SetDescription(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", dir)) err := cmd.Run(&git.RunOpts{ Dir: dir, - Env: append(os.Environ(), environ...), + Env: environ, Stdout: stdout, Stdin: stdin, Stderr: &stderr, diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index 0e34643bc..4e73edfe3 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -33,6 +33,7 @@ type GitAdapter interface { GetAnnotatedTag(ctx context.Context, repoPath string, sha string) (*types.Tag, error) GetAnnotatedTags(ctx context.Context, repoPath string, shas []string) ([]types.Tag, error) CreateBranch(ctx context.Context, repoPath string, branchName string, target string) (*types.Branch, error) + GetBranch(ctx context.Context, repoPath string, branchName string) (*types.Branch, error) DeleteBranch(ctx context.Context, repoPath string, branchName string, force bool) (string, error) GetCommitDivergences(ctx context.Context, repoPath string, requests []types.CommitDivergenceRequest, max int32) ([]types.CommitDivergence, error) diff --git a/gitrpc/internal/service/operations.go b/gitrpc/internal/service/operations.go index 3624d903d..16c4a5265 100644 --- a/gitrpc/internal/service/operations.go +++ b/gitrpc/internal/service/operations.go @@ -48,6 +48,7 @@ func NewCommitFilesService(adapter GitAdapter, reposRoot, reposTempDir string) ( }, nil } +//nolint:funlen // needs refactoring func (s *CommitFilesService) CommitFiles(stream rpc.CommitFilesService_CommitFilesServer) error { ctx := stream.Context() headerRequest, err := stream.Recv() @@ -60,9 +61,21 @@ func (s *CommitFilesService) CommitFiles(stream rpc.CommitFilesService_CommitFil return types.ErrHeaderCannotBeEmpty } - author, committer := GetAuthorAndCommitter(header.Author, header.Committer) + base := header.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty + } - repoPath := getFullPathForRepo(s.reposRoot, header.GetRepoUid()) + committer := base.GetActor() + author := header.GetAuthor() + // in case no explicit author is provided use actor as author. + if author == nil { + author = committer + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) + + // TODO: why are we using the giteat operations here? repo, err := git.OpenRepository(ctx, repoPath) if err != nil { return err @@ -78,7 +91,7 @@ func (s *CommitFilesService) CommitFiles(stream rpc.CommitFilesService_CommitFil } // create a shared repo - shared, err := NewSharedRepo(s.reposTempDir, header.GetRepoUid(), repo) + shared, err := NewSharedRepo(s.reposTempDir, base.GetRepoUid(), repo) if err != nil { return err } @@ -117,7 +130,7 @@ func (s *CommitFilesService) CommitFiles(stream rpc.CommitFilesService_CommitFil return err } - if err = shared.Push(ctx, author, commitHash, header.GetNewBranchName()); err != nil { + if err = shared.Push(ctx, base, commitHash, header.GetNewBranchName()); err != nil { return err } @@ -444,20 +457,3 @@ func parsePayload(payload io.Reader, content io.Writer) (string, error) { _, err := io.Copy(content, reader) return newPath, err } - -// GetAuthorAndCommitter Gets the author and committer user objects from the Identity. -func GetAuthorAndCommitter(author, committer *rpc.Identity) (authorUser, committerUser *rpc.Identity) { - authorUser = author - committerUser = committer - if author == nil && committer == nil { - authorUser = SystemIdentity - committer = SystemIdentity - } - if author == nil && committer != nil { - authorUser = committer - } - if committer == nil && author != nil { - committerUser = author - } - return authorUser, committerUser -} diff --git a/gitrpc/internal/service/ref.go b/gitrpc/internal/service/ref.go index b178f63ce..c9949d433 100644 --- a/gitrpc/internal/service/ref.go +++ b/gitrpc/internal/service/ref.go @@ -10,7 +10,6 @@ import ( "math" "strings" - "github.com/harness/gitness/gitrpc/events" "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" @@ -20,17 +19,17 @@ import ( type ReferenceService struct { rpc.UnimplementedReferenceServiceServer - adapter GitAdapter - eventReporter *events.Reporter - reposRoot string + adapter GitAdapter + reposRoot string + tmpDir string } -func NewReferenceService(adapter GitAdapter, eventReporter *events.Reporter, - reposRoot string) (*ReferenceService, error) { +func NewReferenceService(adapter GitAdapter, + reposRoot string, tmpDir string) (*ReferenceService, error) { return &ReferenceService{ - adapter: adapter, - reposRoot: reposRoot, - eventReporter: eventReporter, + adapter: adapter, + reposRoot: reposRoot, + tmpDir: tmpDir, }, nil } @@ -180,7 +179,12 @@ func wrapInstructorWithOptionalPagination(inner types.WalkReferencesInstructor, func (s ReferenceService) GetRef(ctx context.Context, request *rpc.GetRefRequest) (*rpc.GetRefResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) var refType types.RefType switch request.RefType { diff --git a/gitrpc/internal/service/repo.go b/gitrpc/internal/service/repo.go index f64c4854e..d9b78e3d0 100644 --- a/gitrpc/internal/service/repo.go +++ b/gitrpc/internal/service/repo.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "os" + "path" "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" @@ -26,14 +27,18 @@ const ( gitReferenceNamePrefixBranch = "refs/heads/" gitReferenceNamePrefixTag = "refs/tags/" + + gitHooksDir = "hooks" ) var ( - // TODO: Should be matching the sytem identity from config. + // TODO: should be coming from caller ALWAYS. SystemIdentity = &rpc.Identity{ Name: "gitness", Email: "system@gitness", } + + gitServerHookNames = []string{"pre-receive", "update", "post-receive"} ) type Storage interface { @@ -42,37 +47,45 @@ type Storage interface { type RepositoryService struct { rpc.UnimplementedRepositoryServiceServer - adapter GitAdapter - store Storage - reposRoot string + adapter GitAdapter + store Storage + reposRoot string + serverHookPath string } -func NewRepositoryService(adapter GitAdapter, store Storage, reposRoot string) (*RepositoryService, error) { +func NewRepositoryService(adapter GitAdapter, store Storage, reposRoot string, + serverHookPath string) (*RepositoryService, error) { return &RepositoryService{ - adapter: adapter, - store: store, - reposRoot: reposRoot, + adapter: adapter, + store: store, + reposRoot: reposRoot, + serverHookPath: serverHookPath, }, nil } -//nolint:gocognit // need to refactor this code +//nolint:gocognit,funlen // need to refactor this code func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateRepositoryServer) error { ctx := stream.Context() log := log.Ctx(ctx) // first get repo params from stream - req, err := stream.Recv() + request, err := stream.Recv() if err != nil { return status.Errorf(codes.Internal, "cannot receive create repository data") } - header := req.GetHeader() + header := request.GetHeader() if header == nil { return status.Errorf(codes.Internal, "expected header to be first message in stream") } log.Info().Msgf("received a create repository request %v", header) - repoPath := getFullPathForRepo(s.reposRoot, header.GetUid()) + base := header.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) if _, err = os.Stat(repoPath); !os.IsNotExist(err) { return status.Errorf(codes.AlreadyExists, "repository exists already: %v", repoPath) } @@ -92,13 +105,13 @@ func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateR // update default branch (currently set to non-existent branch) err = s.adapter.SetDefaultBranch(ctx, repoPath, header.GetDefaultBranch(), true) if err != nil { - return processGitErrorf(err, "error updating default branch for repo '%s'", header.GetUid()) + return processGitErrorf(err, "error updating default branch for repo '%s'", base.GetRepoUid()) } // we need temp dir for cloning - tempDir, err := os.MkdirTemp("", "*-"+header.GetUid()) + tempDir, err := os.MkdirTemp("", "*-"+base.GetRepoUid()) if err != nil { - return fmt.Errorf("error creating temp dir for repo %s: %w", header.GetUid(), err) + return fmt.Errorf("error creating temp dir for repo %s: %w", base.GetRepoUid(), err) } defer func(path string) { // when repo is successfully created remove temp dir @@ -144,6 +157,16 @@ func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateR } } + // setup server hook symlinks pointing to configured server hook binary + for _, hook := range gitServerHookNames { + hookPath := path.Join(repoPath, gitHooksDir, hook) + err = os.Symlink(s.serverHookPath, hookPath) + if err != nil { + return status.Errorf(codes.Internal, + "failed to setup symlink for hook '%s' ('%s' -> '%s'): %s", hook, hookPath, s.serverHookPath, err) + } + } + res := &rpc.CreateRepositoryResponse{} err = stream.SendAndClose(res) if err != nil { diff --git a/gitrpc/internal/service/shared_repo.go b/gitrpc/internal/service/shared_repo.go index e69defbb7..0cb35d8bb 100644 --- a/gitrpc/internal/service/shared_repo.go +++ b/gitrpc/internal/service/shared_repo.go @@ -10,11 +10,11 @@ import ( "errors" "fmt" "io" - "os" "regexp" "strings" "time" + "github.com/harness/gitness/gitrpc/internal/middleware" "github.com/harness/gitness/gitrpc/internal/tempdir" "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" @@ -25,23 +25,22 @@ import ( // SharedRepo is a type to wrap our upload repositories as a shallow clone. type SharedRepo struct { - repoUID string - repo *git.Repository - remoteRepo *git.Repository - TempBaseDir string - basePath string + repoUID string + repo *git.Repository + remoteRepo *git.Repository + tmpPath string } // NewSharedRepo creates a new temporary upload repository. -func NewSharedRepo(tempDir, repoUID string, remoteRepo *git.Repository) (*SharedRepo, error) { - basePath, err := tempdir.CreateTemporaryPath(tempDir, repoUID) +func NewSharedRepo(baseTmpDir, repoUID string, remoteRepo *git.Repository) (*SharedRepo, error) { + tmpPath, err := tempdir.CreateTemporaryPath(baseTmpDir, repoUID) if err != nil { return nil, err } t := &SharedRepo{ repoUID: repoUID, remoteRepo: remoteRepo, - basePath: basePath, + tmpPath: tmpPath, } return t, nil } @@ -49,15 +48,15 @@ func NewSharedRepo(tempDir, repoUID string, remoteRepo *git.Repository) (*Shared // Close the repository cleaning up all files. func (r *SharedRepo) Close(ctx context.Context) { defer r.repo.Close() - if err := tempdir.RemoveTemporaryPath(r.basePath); err != nil { - log.Ctx(ctx).Err(err).Msgf("Failed to remove temporary path %s", r.basePath) + if err := tempdir.RemoveTemporaryPath(r.tmpPath); err != nil { + log.Ctx(ctx).Err(err).Msgf("Failed to remove temporary path %s", r.tmpPath) } } // Clone the base repository to our path and set branch as the HEAD. func (r *SharedRepo) Clone(ctx context.Context, branch string) error { if _, _, err := git.NewCommand(ctx, "clone", "-s", "--bare", "-b", - branch, r.remoteRepo.Path, r.basePath).RunStdString(nil); err != nil { + branch, r.remoteRepo.Path, r.tmpPath).RunStdString(nil); err != nil { stderr := err.Error() if matched, _ := regexp.MatchString(".*Remote branch .* not found in upstream origin.*", stderr); matched { return git.ErrBranchNotExist{ @@ -69,7 +68,7 @@ func (r *SharedRepo) Clone(ctx context.Context, branch string) error { return fmt.Errorf("Clone: %w %s", err, stderr) } } - gitRepo, err := git.OpenRepository(ctx, r.basePath) + gitRepo, err := git.OpenRepository(ctx, r.tmpPath) if err != nil { return err } @@ -79,10 +78,10 @@ func (r *SharedRepo) Clone(ctx context.Context, branch string) error { // Init the repository. func (r *SharedRepo) Init(ctx context.Context) error { - if err := git.InitRepository(ctx, r.basePath, false); err != nil { + if err := git.InitRepository(ctx, r.tmpPath, false); err != nil { return err } - gitRepo, err := git.OpenRepository(ctx, r.basePath) + gitRepo, err := git.OpenRepository(ctx, r.tmpPath) if err != nil { return err } @@ -92,7 +91,7 @@ func (r *SharedRepo) Init(ctx context.Context) error { // SetDefaultIndex sets the git index to our HEAD. func (r *SharedRepo) SetDefaultIndex(ctx context.Context) error { - if _, _, err := git.NewCommand(ctx, "read-tree", "HEAD").RunStdString(&git.RunOpts{Dir: r.basePath}); err != nil { + if _, _, err := git.NewCommand(ctx, "read-tree", "HEAD").RunStdString(&git.RunOpts{Dir: r.tmpPath}); err != nil { return fmt.Errorf("SetDefaultIndex: %w", err) } return nil @@ -112,7 +111,7 @@ func (r *SharedRepo) LsFiles(ctx context.Context, filenames ...string) ([]string if err := git.NewCommand(ctx, cmdArgs...). Run(&git.RunOpts{ - Dir: r.basePath, + Dir: r.tmpPath, Stdout: stdOut, Stderr: stdErr, }); err != nil { @@ -144,7 +143,7 @@ func (r *SharedRepo) RemoveFilesFromIndex(ctx context.Context, filenames ...stri if err := git.NewCommand(ctx, "update-index", "--remove", "-z", "--index-info"). Run(&git.RunOpts{ - Dir: r.basePath, + Dir: r.tmpPath, Stdin: stdIn, Stdout: stdOut, Stderr: stdErr, @@ -162,7 +161,7 @@ func (r *SharedRepo) HashObject(ctx context.Context, content io.Reader) (string, if err := git.NewCommand(ctx, "hash-object", "-w", "--stdin"). Run(&git.RunOpts{ - Dir: r.basePath, + Dir: r.tmpPath, Stdin: content, Stdout: stdOut, Stderr: stdErr, @@ -192,7 +191,7 @@ func (r *SharedRepo) ShowFile(ctx context.Context, filePath, commitHash string, // AddObjectToIndex adds the provided object hash to the index with the provided mode and path. func (r *SharedRepo) AddObjectToIndex(ctx context.Context, mode, objectHash, objectPath string) error { if _, _, err := git.NewCommand(ctx, "update-index", "--add", "--replace", "--cacheinfo", mode, objectHash, - objectPath).RunStdString(&git.RunOpts{Dir: r.basePath}); err != nil { + objectPath).RunStdString(&git.RunOpts{Dir: r.tmpPath}); err != nil { if matched, _ := regexp.MatchString(".*Invalid path '.*", err.Error()); matched { return types.ErrInvalidPath } @@ -204,7 +203,7 @@ func (r *SharedRepo) AddObjectToIndex(ctx context.Context, mode, objectHash, obj // WriteTree writes the current index as a tree to the object db and returns its hash. func (r *SharedRepo) WriteTree(ctx context.Context) (string, error) { - stdout, _, err := git.NewCommand(ctx, "write-tree").RunStdString(&git.RunOpts{Dir: r.basePath}) + stdout, _, err := git.NewCommand(ctx, "write-tree").RunStdString(&git.RunOpts{Dir: r.tmpPath}) if err != nil { return "", fmt.Errorf("unable to write-tree in temporary repo for: %s Error: %w", r.repoUID, err) @@ -222,7 +221,7 @@ func (r *SharedRepo) GetLastCommitByRef(ctx context.Context, ref string) (string if ref == "" { ref = "HEAD" } - stdout, _, err := git.NewCommand(ctx, "rev-parse", ref).RunStdString(&git.RunOpts{Dir: r.basePath}) + stdout, _, err := git.NewCommand(ctx, "rev-parse", ref).RunStdString(&git.RunOpts{Dir: r.tmpPath}) if err != nil { return "", fmt.Errorf("unable to rev-parse %s in temporary repo for: %s Error: %w", ref, r.repoUID, err) @@ -245,20 +244,16 @@ func (r *SharedRepo) CommitTreeWithDate( signoff bool, authorDate, committerDate time.Time, ) (string, error) { - committerSig := &git.Signature{ - Name: committer.Name, - Email: committer.Email, - When: time.Now(), + // setup environment variables used by git-commit-tree + // See https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables + env := []string{ + "GIT_AUTHOR_NAME=" + author.Name, + "GIT_AUTHOR_EMAIL=" + author.Email, + "GIT_AUTHOR_DATE=" + authorDate.Format(time.RFC3339), + "GIT_COMMITTER_NAME=" + committer.Name, + "GIT_COMMITTER_EMAIL=" + committer.Email, + "GIT_COMMITTER_DATE=" + committerDate.Format(time.RFC3339), } - - // Because this may call hooks we should pass in the environment - env := append(os.Environ(), - "GIT_AUTHOR_NAME="+author.Name, - "GIT_AUTHOR_EMAIL="+author.Email, - "GIT_AUTHOR_DATE="+authorDate.Format(time.RFC3339), - "GIT_COMMITTER_DATE="+committerDate.Format(time.RFC3339), - ) - messageBytes := new(bytes.Buffer) _, _ = messageBytes.WriteString(message) _, _ = messageBytes.WriteString("\n") @@ -274,23 +269,23 @@ func (r *SharedRepo) CommitTreeWithDate( args = append(args, "--no-gpg-sign") if signoff { + giteaSignature := &git.Signature{ + Name: committer.Name, + Email: committer.Email, + When: committerDate, + } // Signed-off-by _, _ = messageBytes.WriteString("\n") _, _ = messageBytes.WriteString("Signed-off-by: ") - _, _ = messageBytes.WriteString(committerSig.String()) + _, _ = messageBytes.WriteString(giteaSignature.String()) } - env = append(env, - "GIT_COMMITTER_NAME="+committerSig.Name, - "GIT_COMMITTER_EMAIL="+committerSig.Email, - ) - stdout := new(bytes.Buffer) stderr := new(bytes.Buffer) if err := git.NewCommand(ctx, args...). Run(&git.RunOpts{ Env: env, - Dir: r.basePath, + Dir: r.tmpPath, Stdin: messageBytes, Stdout: stdout, Stderr: stderr, @@ -302,13 +297,12 @@ func (r *SharedRepo) CommitTreeWithDate( } // Push the provided commitHash to the repository branch by the provided user. -func (r *SharedRepo) Push(ctx context.Context, doer *rpc.Identity, commitHash, branch string) error { +func (r *SharedRepo) Push(ctx context.Context, writeRequest *rpc.WriteRequest, sourceRef, branch string) error { // Because calls hooks we need to pass in the environment - author, committer := doer, doer - env := PushingEnvironment(author, committer, r.repoUID) - if err := git.Push(ctx, r.basePath, git.PushOptions{ + env := CreateEnvironmentForPush(ctx, writeRequest) + if err := git.Push(ctx, r.tmpPath, git.PushOptions{ Remote: r.remoteRepo.Path, - Branch: strings.TrimSpace(commitHash) + ":" + git.BranchPrefix + strings.TrimSpace(branch), + Branch: strings.TrimSpace(sourceRef) + ":" + gitReferenceNamePrefixBranch + strings.TrimSpace(branch), Env: env, }); err != nil { if git.IsErrPushOutOfDate(err) { @@ -318,12 +312,12 @@ func (r *SharedRepo) Push(ctx context.Context, doer *rpc.Identity, commitHash, b if errors.As(err, &rejectErr) { log.Ctx(ctx).Info().Msgf("Unable to push back to repo from temporary repo due to rejection:"+ " %s (%s)\nStdout: %s\nStderr: %s\nError: %v", - r.repoUID, r.basePath, rejectErr.StdOut, rejectErr.StdErr, rejectErr.Err) + r.repoUID, r.tmpPath, rejectErr.StdOut, rejectErr.StdErr, rejectErr.Err) } return err } return fmt.Errorf("unable to push back to repo from temporary repo: %s (%s) Error: %w", - r.repoUID, r.basePath, err) + r.repoUID, r.tmpPath, err) } return nil } @@ -344,32 +338,24 @@ func (r *SharedRepo) GetCommit(commitID string) (*git.Commit, error) { return r.repo.GetCommit(commitID) } -// PushingEnvironment returns an os environment to allow hooks to work on push. -func PushingEnvironment( - author, - committer *rpc.Identity, - repoUID string, -) []string { - authorSig := &git.Signature{ - Name: author.Name, - Email: author.Email, - } - committerSig := &git.Signature{ - Name: committer.Name, - Email: committer.Email, +// ASSUMPTION: writeRequst and writeRequst.Actor is never nil. +func CreateEnvironmentForPush(ctx context.Context, writeRequest *rpc.WriteRequest) []string { + // don't send existing environment variables (os.Environ()), only send what's explicitly necessary. + // Otherwise we create implicit dependencies that are easy to break. + environ := []string{ + // request id to use for hooks + EnvRequestID + "=" + middleware.RequestIDFrom(ctx), + // repo related info + EnvRepoUID + "=" + writeRequest.RepoUid, + // pusher related info + EnvPusherName + "=" + writeRequest.Actor.Name, + EnvPusherEmail + "=" + writeRequest.Actor.Email, } - environ := append(os.Environ(), - "GIT_AUTHOR_NAME="+authorSig.Name, - "GIT_AUTHOR_EMAIL="+authorSig.Email, - "GIT_COMMITTER_NAME="+committerSig.Name, - "GIT_COMMITTER_EMAIL="+committerSig.Email, - // important env vars for hooks - EnvPusherName+"="+committer.Name, - // EnvPusherID+"="+fmt.Sprintf("%d", committer.ID), - EnvRepoID+"="+repoUID, - EnvAppURL+"=", // app url - ) + // add all environment variables coming from client + for _, envVar := range writeRequest.EnvVars { + environ = append(environ, fmt.Sprintf("%s=%s", envVar.Name, envVar.Value)) + } return environ } diff --git a/gitrpc/internal/service/submodule.go b/gitrpc/internal/service/submodule.go index dfdc1bf90..73459cb0d 100644 --- a/gitrpc/internal/service/submodule.go +++ b/gitrpc/internal/service/submodule.go @@ -7,12 +7,18 @@ package service import ( "context" + "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" ) func (s RepositoryService) GetSubmodule(ctx context.Context, request *rpc.GetSubmoduleRequest) (*rpc.GetSubmoduleResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) // TODO: do we need to validate request for nil? gitSubmodule, err := s.adapter.GetSubmodule(ctx, repoPath, request.GetGitRef(), request.GetPath()) if err != nil { diff --git a/gitrpc/internal/service/tag.go b/gitrpc/internal/service/tag.go index acc046933..2c1909391 100644 --- a/gitrpc/internal/service/tag.go +++ b/gitrpc/internal/service/tag.go @@ -20,7 +20,12 @@ import ( func (s ReferenceService) ListCommitTags(request *rpc.ListCommitTagsRequest, stream rpc.ReferenceService_ListCommitTagsServer) error { ctx := stream.Context() - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) // get all required information from git references tags, err := s.listCommitTagsLoadReferenceData(ctx, repoPath, request) diff --git a/gitrpc/internal/service/tree.go b/gitrpc/internal/service/tree.go index 12e1faef8..2fa1a9078 100644 --- a/gitrpc/internal/service/tree.go +++ b/gitrpc/internal/service/tree.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" @@ -17,7 +18,12 @@ import ( func (s RepositoryService) ListTreeNodes(request *rpc.ListTreeNodesRequest, stream rpc.RepositoryService_ListTreeNodesServer) error { ctx := stream.Context() - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) gitNodes, err := s.adapter.ListTreeNodes(ctx, repoPath, request.GetGitRef(), request.GetPath(), request.GetRecursive(), request.GetIncludeLatestCommit()) @@ -56,7 +62,12 @@ func (s RepositoryService) ListTreeNodes(request *rpc.ListTreeNodesRequest, func (s RepositoryService) GetTreeNode(ctx context.Context, request *rpc.GetTreeNodeRequest) (*rpc.GetTreeNodeResponse, error) { - repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) + base := request.GetBase() + if base == nil { + return nil, types.ErrBaseCannotBeEmpty + } + + repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) // TODO: do we need to validate request for nil? gitNode, err := s.adapter.GetTreeNode(ctx, repoPath, request.GetGitRef(), request.GetPath()) if err != nil { diff --git a/gitrpc/internal/types/errors.go b/gitrpc/internal/types/errors.go index 066df7c69..e4a0237a4 100644 --- a/gitrpc/internal/types/errors.go +++ b/gitrpc/internal/types/errors.go @@ -15,6 +15,7 @@ var ( ErrContentSentBeforeAction = errors.New("content sent before action") ErrActionListEmpty = errors.New("no commit actions to perform on repository") ErrHeaderCannotBeEmpty = errors.New("header field cannot be empty") + ErrBaseCannotBeEmpty = errors.New("base field cannot be empty") ErrSHADoesNotMatch = errors.New("sha does not match") ErrEmptyLeftCommitID = errors.New("empty LeftCommitId") ErrEmptyRightCommitID = errors.New("empty RightCommitId") diff --git a/gitrpc/log_interceptor.go b/gitrpc/log_interceptor.go index 7efe4b857..ce59f524e 100644 --- a/gitrpc/log_interceptor.go +++ b/gitrpc/log_interceptor.go @@ -9,11 +9,12 @@ import ( "github.com/harness/gitness/gitrpc/rpc" - "github.com/rs/zerolog/hlog" "google.golang.org/grpc" "google.golang.org/grpc/metadata" ) +type requestIDKey struct{} + // ClientLogInterceptor injects the zerlog request ID into the metadata. // That allows the gitrpc server to log with the same request ID as the client. type ClientLogInterceptor struct { @@ -39,10 +40,23 @@ func (i ClientLogInterceptor) StreamClientInterceptor() grpc.StreamClientInterce } } +// WithRequestID returns a copy of parent in which the request id value is set. +// This can be used by external entities to pass request IDs to gitrpc. +func WithRequestID(parent context.Context, v string) context.Context { + return context.WithValue(parent, requestIDKey{}, v) +} + +// RequestIDFrom returns the value of the request ID key on the +// context - ok is true iff a non-empty value existed. +func RequestIDFrom(ctx context.Context) (string, bool) { + v, ok := ctx.Value(requestIDKey{}).(string) + return v, ok && v != "" +} + // appendLoggingRequestIDToOutgoingMetadata appends the zerolog request ID to the outgoing grpc metadata, if available. func appendLoggingRequestIDToOutgoingMetadata(ctx context.Context) context.Context { - if id, ok := hlog.IDFromCtx(ctx); ok { - ctx = metadata.AppendToOutgoingContext(ctx, rpc.MetadataKeyRequestID, id.String()) + if id, ok := RequestIDFrom(ctx); ok { + ctx = metadata.AppendToOutgoingContext(ctx, rpc.MetadataKeyRequestID, id) } return ctx } diff --git a/gitrpc/operations.go b/gitrpc/operations.go index 3db6ad6fc..9342ae62d 100644 --- a/gitrpc/operations.go +++ b/gitrpc/operations.go @@ -19,8 +19,7 @@ import ( ) type ListCommitsParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams // GitREF is a git reference (branch / tag / commit SHA) GitREF string // After is a git reference (branch / tag / commit SHA) @@ -57,11 +56,11 @@ func (c *Client) ListCommits(ctx context.Context, params *ListCommitsParams) (*L return nil, ErrNoParamsProvided } stream, err := c.repoService.ListCommits(ctx, &rpc.ListCommitsRequest{ - RepoUid: params.RepoUID, - GitRef: params.GitREF, - After: params.After, - Page: params.Page, - Limit: params.Limit, + Base: mapToRPCReadRequest(params.ReadParams), + GitRef: params.GitREF, + After: params.After, + Page: params.Page, + Limit: params.Limit, }) if err != nil { return nil, fmt.Errorf("failed to start stream for commits: %w", err) @@ -98,8 +97,7 @@ func (c *Client) ListCommits(ctx context.Context, params *ListCommitsParams) (*L } type GetCommitDivergencesParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams MaxCount int32 Requests []CommitDivergenceRequest } @@ -132,7 +130,7 @@ func (c *Client) GetCommitDivergences(ctx context.Context, // build rpc request req := &rpc.GetCommitDivergencesRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), MaxCount: params.MaxCount, Requests: make([]*rpc.CommitDivergenceRequest, len(params.Requests)), } @@ -192,9 +190,9 @@ type CommitFileAction struct { SHA string } -// CommitFilesOptions holds the data for file operations. -type CommitFilesOptions struct { - RepoID string +// CommitFilesParams holds the data for file operations. +type CommitFilesParams struct { + WriteParams Title string Message string Branch string @@ -208,7 +206,7 @@ type CommitFilesResponse struct { CommitID string } -func (c *Client) CommitFiles(ctx context.Context, params *CommitFilesOptions) (CommitFilesResponse, error) { +func (c *Client) CommitFiles(ctx context.Context, params *CommitFilesParams) (CommitFilesResponse, error) { stream, err := c.commitFilesService.CommitFiles(ctx) if err != nil { return CommitFilesResponse{}, err @@ -217,7 +215,7 @@ func (c *Client) CommitFiles(ctx context.Context, params *CommitFilesOptions) (C if err = stream.Send(&rpc.CommitFilesRequest{ Payload: &rpc.CommitFilesRequest_Header{ Header: &rpc.CommitFilesRequestHeader{ - RepoUid: params.RepoID, + Base: mapToRPCWriteRequest(params.WriteParams), BranchName: params.Branch, NewBranchName: params.NewBranch, Title: params.Title, diff --git a/gitrpc/proto/diff.proto b/gitrpc/proto/diff.proto index b26cabb15..0896d55a8 100644 --- a/gitrpc/proto/diff.proto +++ b/gitrpc/proto/diff.proto @@ -3,6 +3,8 @@ package rpc; option go_package = "github.com/harness/gitness/gitrpc/rpc"; +import "shared.proto"; + // DiffService is a service which provides RPCs to inspect differences // introduced between a set of commits. service DiffService { @@ -10,9 +12,9 @@ service DiffService { } message RawDiffRequest { - string repo_id = 1; - string left_commit_id = 2; - string right_commit_id = 3; + ReadRequest base = 1; + string left_commit_id = 2; + string right_commit_id = 3; } message RawDiffResponse { diff --git a/gitrpc/proto/http.proto b/gitrpc/proto/http.proto index e34f57823..140dc8f31 100644 --- a/gitrpc/proto/http.proto +++ b/gitrpc/proto/http.proto @@ -3,6 +3,8 @@ package rpc; option go_package = "github.com/harness/gitness/gitrpc/rpc"; +import "shared.proto"; + // SmartHTTPService is a service that provides RPCs required for HTTP-based Git // clones via the smart HTTP protocol. service SmartHTTPService { @@ -16,7 +18,8 @@ service SmartHTTPService { } message InfoRefsRequest { - string repo_uid = 1; + // Base specifies the base read parameters + ReadRequest base = 1; // Service can be: upload-pack or receive-pack string service = 2; // Parameters to use with git -c (key=value pairs) @@ -31,21 +34,21 @@ message InfoRefsResponse { } message ServicePackRequest { - // repository should only be present only in the first message of the stream - string repo_uid = 1; + // Base specifies the base parameters. + // Depending on the service the matching base type has to be passed + oneof base { + ReadRequest read_base = 1; + WriteRequest write_base = 2; + }; + // Service can be: upload-pack or receive-pack - string service = 2; + string service = 3; // Raw data to be copied to stdin of 'git upload-pack' - bytes data = 3; + bytes data = 4; // Parameters to use with git -c (key=value pairs) - repeated string git_config_options = 4; - + repeated string git_config_options = 5; // Git protocol version - string git_protocol = 5; - - // user_id become env variable, used by the Git {pre,post}-receive - // hooks. They should only be present in the first message of the stream. - string principal_id = 6; + string git_protocol = 6; } message ServicePackResponse { diff --git a/gitrpc/proto/operations.proto b/gitrpc/proto/operations.proto index 0b3e298c8..8217c0aa7 100644 --- a/gitrpc/proto/operations.proto +++ b/gitrpc/proto/operations.proto @@ -14,14 +14,12 @@ service CommitFilesService { // CommitFilesRequestHeader is the header of the UserCommitFiles that defines the commit details, // parent and other information related to the call. message CommitFilesRequestHeader { - // repository is the target repository where to apply the commit. - string repo_uid = 1; + WriteRequest base = 1; string branch_name = 2; string new_branch_name = 3; string title = 4; string message = 5; Identity author = 6; - Identity committer = 7; } // CommitFilesActionHeader contains the details of the action to be performed. diff --git a/gitrpc/proto/ref.proto b/gitrpc/proto/ref.proto index cdfc9abfe..3785b78c9 100644 --- a/gitrpc/proto/ref.proto +++ b/gitrpc/proto/ref.proto @@ -14,9 +14,9 @@ service ReferenceService { } message CreateBranchRequest { - string repo_uid = 1; - string branch_name = 2; - string target = 3; + WriteRequest base = 1; + string branch_name = 2; + string target = 3; } message CreateBranchResponse { @@ -24,12 +24,13 @@ message CreateBranchResponse { } message DeleteBranchRequest { - string repo_uid = 1; - string branch_name = 2; - bool force = 3; + WriteRequest base = 1; + string branch_name = 2; + bool force = 3; } message DeleteBranchResponse { + string sha = 1; } message ListBranchesRequest { @@ -39,7 +40,7 @@ message ListBranchesRequest { Date = 2; } - string repo_uid = 1; + ReadRequest base = 1; bool include_commit = 2; string query = 3; SortOption sort = 4; @@ -65,7 +66,7 @@ message ListCommitTagsRequest { Date = 2; } - string repo_uid = 1; + ReadRequest base = 1; bool include_commit = 2; string query = 3; SortOption sort = 4; @@ -93,8 +94,9 @@ message GetRefRequest { Branch = 0; Tag = 1; } - string repo_uid = 1; - string ref_name = 2; + + ReadRequest base = 1; + string ref_name = 2; RefType ref_type = 3; } diff --git a/gitrpc/proto/repo.proto b/gitrpc/proto/repo.proto index f9628ed19..2bbb90ecd 100644 --- a/gitrpc/proto/repo.proto +++ b/gitrpc/proto/repo.proto @@ -24,17 +24,17 @@ message CreateRepositoryRequest { } message CreateRepositoryRequestHeader { - string uid = 1; + WriteRequest base = 1; string default_branch = 2; } message CreateRepositoryResponse { } message GetTreeNodeRequest { - string repo_uid = 1; - string git_ref = 2; - string path = 3; - bool include_latest_commit = 4; + ReadRequest base = 1; + string git_ref = 2; + string path = 3; + bool include_latest_commit = 4; } message GetTreeNodeResponse { @@ -43,7 +43,7 @@ message GetTreeNodeResponse { } message ListTreeNodesRequest { - string repo_uid = 1; + ReadRequest base = 1; string git_ref = 2; string path = 3; bool include_latest_commit = 4; @@ -78,11 +78,11 @@ enum TreeNodeMode { } message ListCommitsRequest { - string repo_uid = 1; - string git_ref = 2; - string after = 3; - int32 page = 4; - int32 limit = 5; + ReadRequest base = 1; + string git_ref = 2; + string after = 3; + int32 page = 4; + int32 limit = 5; } message ListCommitsResponse { @@ -91,9 +91,9 @@ message ListCommitsResponse { message GetBlobRequest { - string repo_uid = 1; - string sha = 2; - int64 sizeLimit = 3; + ReadRequest base = 1; + string sha = 2; + int64 sizeLimit = 3; } message GetBlobResponse { @@ -107,9 +107,9 @@ message Blob { } message GetSubmoduleRequest { - string repo_uid = 1; - string git_ref = 2; - string path = 3; + ReadRequest base = 1; + string git_ref = 2; + string path = 3; } message GetSubmoduleResponse { @@ -122,8 +122,8 @@ message Submodule { } message GetCommitDivergencesRequest { - string repo_uid = 1; - int32 max_count = 2; + ReadRequest base = 1; + int32 max_count = 2; repeated CommitDivergenceRequest requests = 3; } diff --git a/gitrpc/proto/shared.proto b/gitrpc/proto/shared.proto index 14abf95b3..6c5c53bb8 100644 --- a/gitrpc/proto/shared.proto +++ b/gitrpc/proto/shared.proto @@ -3,7 +3,22 @@ package rpc; option go_package = "github.com/harness/gitness/gitrpc/rpc"; -message FileUpload{ +message ReadRequest { + string repo_uid = 1; +} + +message WriteRequest { + string repo_uid = 1; + repeated EnvVar env_vars = 2; + Identity actor = 3; +} + +message EnvVar { + string name = 1; + string value = 2; +} + +message FileUpload { oneof data { FileUploadHeader header = 1; Chunk chunk = 2; diff --git a/gitrpc/ref.go b/gitrpc/ref.go index 40dfdde4e..9454231b1 100644 --- a/gitrpc/ref.go +++ b/gitrpc/ref.go @@ -21,9 +21,9 @@ const ( ) type GetRefParams struct { - RepoUID string - Name string - Type RefType + ReadParams + Name string + Type RefType } type GetRefResponse struct { @@ -46,7 +46,7 @@ func (c *Client) GetRef(ctx context.Context, params *GetRefParams) (*GetRefRespo } result, err := c.refService.GetRef(ctx, &rpc.GetRefRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), RefName: params.Name, RefType: refType, }) diff --git a/gitrpc/repo.go b/gitrpc/repo.go index 5a85342e0..ced8737ac 100644 --- a/gitrpc/repo.go +++ b/gitrpc/repo.go @@ -25,6 +25,9 @@ const ( ) type CreateRepositoryParams struct { + // Create operation is different from all (from user side), as UID doesn't exist yet. + // Only take actor as input and create WriteParams manually + Actor Identity DefaultBranch string Files []File } @@ -57,10 +60,16 @@ func (c *Client) CreateRepository(ctx context.Context, log.Info().Msgf("Send header") + writeParams := WriteParams{ + RepoUID: uid, + Actor: params.Actor, + EnvVars: map[string]string{}, // (no githook triggered for repo creation) + } + req := &rpc.CreateRepositoryRequest{ Data: &rpc.CreateRepositoryRequest_Header{ Header: &rpc.CreateRepositoryRequestHeader{ - Uid: uid, + Base: mapToRPCWriteRequest(writeParams), DefaultBranch: params.DefaultBranch, }, }, diff --git a/gitrpc/rpc/constants.go b/gitrpc/rpc/constants.go new file mode 100644 index 000000000..625de2219 --- /dev/null +++ b/gitrpc/rpc/constants.go @@ -0,0 +1,16 @@ +// 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 rpc + +const ( + // MetadataKeyRequestID is the key used to store the request ID in the metadata. + MetadataKeyRequestID = "request-id" + + // ServiceUploadPack is the service constant used for triggering the upload pack operation. + ServiceUploadPack = "upload-pack" + + // ServiceReceivePack is the service constant used for triggering the receive pack operation. + ServiceReceivePack = "receive-pack" +) diff --git a/gitrpc/rpc/diff.pb.go b/gitrpc/rpc/diff.pb.go index 2067e5be3..cb18a426f 100644 --- a/gitrpc/rpc/diff.pb.go +++ b/gitrpc/rpc/diff.pb.go @@ -25,9 +25,9 @@ type RawDiffRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoId string `protobuf:"bytes,1,opt,name=repo_id,json=repoId,proto3" json:"repo_id,omitempty"` - LeftCommitId string `protobuf:"bytes,2,opt,name=left_commit_id,json=leftCommitId,proto3" json:"left_commit_id,omitempty"` - RightCommitId string `protobuf:"bytes,3,opt,name=right_commit_id,json=rightCommitId,proto3" json:"right_commit_id,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + LeftCommitId string `protobuf:"bytes,2,opt,name=left_commit_id,json=leftCommitId,proto3" json:"left_commit_id,omitempty"` + RightCommitId string `protobuf:"bytes,3,opt,name=right_commit_id,json=rightCommitId,proto3" json:"right_commit_id,omitempty"` } func (x *RawDiffRequest) Reset() { @@ -62,11 +62,11 @@ func (*RawDiffRequest) Descriptor() ([]byte, []int) { return file_diff_proto_rawDescGZIP(), []int{0} } -func (x *RawDiffRequest) GetRepoId() string { +func (x *RawDiffRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoId + return x.Base } - return "" + return nil } func (x *RawDiffRequest) GetLeftCommitId() string { @@ -134,24 +134,26 @@ var File_diff_proto protoreflect.FileDescriptor var file_diff_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, - 0x63, 0x22, 0x77, 0x0a, 0x0e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, - 0x6c, 0x65, 0x66, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x65, 0x66, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x72, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x69, 0x67, - 0x68, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x61, - 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x32, 0x47, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x38, 0x0a, 0x07, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x12, 0x13, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 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, + 0x63, 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x84, 0x01, 0x0a, 0x0e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 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, 0x24, 0x0a, 0x0e, 0x6c, 0x65, 0x66, 0x74, + 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x6c, 0x65, 0x66, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 0x12, 0x26, + 0x0a, 0x0f, 0x72, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, + 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x47, 0x0a, + 0x0b, 0x44, 0x69, 0x66, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x07, + 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x61, + 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 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 ( @@ -170,15 +172,17 @@ var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_diff_proto_goTypes = []interface{}{ (*RawDiffRequest)(nil), // 0: rpc.RawDiffRequest (*RawDiffResponse)(nil), // 1: rpc.RawDiffResponse + (*ReadRequest)(nil), // 2: rpc.ReadRequest } var file_diff_proto_depIdxs = []int32{ - 0, // 0: rpc.DiffService.RawDiff:input_type -> rpc.RawDiffRequest - 1, // 1: rpc.DiffService.RawDiff:output_type -> rpc.RawDiffResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 2, // 0: rpc.RawDiffRequest.base:type_name -> rpc.ReadRequest + 0, // 1: rpc.DiffService.RawDiff:input_type -> rpc.RawDiffRequest + 1, // 2: rpc.DiffService.RawDiff:output_type -> rpc.RawDiffResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_diff_proto_init() } @@ -186,6 +190,7 @@ func file_diff_proto_init() { if File_diff_proto != nil { return } + file_shared_proto_init() if !protoimpl.UnsafeEnabled { file_diff_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RawDiffRequest); i { diff --git a/gitrpc/rpc/http.pb.go b/gitrpc/rpc/http.pb.go index f1b6b057b..9afe821bf 100644 --- a/gitrpc/rpc/http.pb.go +++ b/gitrpc/rpc/http.pb.go @@ -25,7 +25,8 @@ type InfoRefsRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` + // Base specifies the base read parameters + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` // Service can be: upload-pack or receive-pack Service string `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // Parameters to use with git -c (key=value pairs) @@ -66,11 +67,11 @@ func (*InfoRefsRequest) Descriptor() ([]byte, []int) { return file_http_proto_rawDescGZIP(), []int{0} } -func (x *InfoRefsRequest) GetRepoUid() string { +func (x *InfoRefsRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *InfoRefsRequest) GetService() string { @@ -146,19 +147,21 @@ type ServicePackRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // repository should only be present only in the first message of the stream - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` + // Base specifies the base parameters. + // Depending on the service the matching base type has to be passed + // + // Types that are assignable to Base: + // *ServicePackRequest_ReadBase + // *ServicePackRequest_WriteBase + Base isServicePackRequest_Base `protobuf_oneof:"base"` // Service can be: upload-pack or receive-pack - Service string `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` + Service string `protobuf:"bytes,3,opt,name=service,proto3" json:"service,omitempty"` // Raw data to be copied to stdin of 'git upload-pack' - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` // Parameters to use with git -c (key=value pairs) - GitConfigOptions []string `protobuf:"bytes,4,rep,name=git_config_options,json=gitConfigOptions,proto3" json:"git_config_options,omitempty"` + GitConfigOptions []string `protobuf:"bytes,5,rep,name=git_config_options,json=gitConfigOptions,proto3" json:"git_config_options,omitempty"` // Git protocol version - GitProtocol string `protobuf:"bytes,5,opt,name=git_protocol,json=gitProtocol,proto3" json:"git_protocol,omitempty"` - // user_id become env variable, used by the Git {pre,post}-receive - // hooks. They should only be present in the first message of the stream. - PrincipalId string `protobuf:"bytes,6,opt,name=principal_id,json=principalId,proto3" json:"principal_id,omitempty"` + GitProtocol string `protobuf:"bytes,6,opt,name=git_protocol,json=gitProtocol,proto3" json:"git_protocol,omitempty"` } func (x *ServicePackRequest) Reset() { @@ -193,11 +196,25 @@ func (*ServicePackRequest) Descriptor() ([]byte, []int) { return file_http_proto_rawDescGZIP(), []int{2} } -func (x *ServicePackRequest) GetRepoUid() string { - if x != nil { - return x.RepoUid +func (m *ServicePackRequest) GetBase() isServicePackRequest_Base { + if m != nil { + return m.Base } - return "" + return nil +} + +func (x *ServicePackRequest) GetReadBase() *ReadRequest { + if x, ok := x.GetBase().(*ServicePackRequest_ReadBase); ok { + return x.ReadBase + } + return nil +} + +func (x *ServicePackRequest) GetWriteBase() *WriteRequest { + if x, ok := x.GetBase().(*ServicePackRequest_WriteBase); ok { + return x.WriteBase + } + return nil } func (x *ServicePackRequest) GetService() string { @@ -228,13 +245,22 @@ func (x *ServicePackRequest) GetGitProtocol() string { return "" } -func (x *ServicePackRequest) GetPrincipalId() string { - if x != nil { - return x.PrincipalId - } - return "" +type isServicePackRequest_Base interface { + isServicePackRequest_Base() } +type ServicePackRequest_ReadBase struct { + ReadBase *ReadRequest `protobuf:"bytes,1,opt,name=read_base,json=readBase,proto3,oneof"` +} + +type ServicePackRequest_WriteBase struct { + WriteBase *WriteRequest `protobuf:"bytes,2,opt,name=write_base,json=writeBase,proto3,oneof"` +} + +func (*ServicePackRequest_ReadBase) isServicePackRequest_Base() {} + +func (*ServicePackRequest_WriteBase) isServicePackRequest_Base() {} + type ServicePackResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -287,47 +313,52 @@ var File_http_proto protoreflect.FileDescriptor var file_http_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, - 0x63, 0x22, 0x97, 0x01, 0x0a, 0x0f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 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, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, - 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x67, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x26, 0x0a, 0x10, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x22, 0xd1, 0x01, 0x0a, 0x12, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, - 0x61, 0x63, 0x6b, 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, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x63, 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xa2, 0x01, 0x0a, 0x0f, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 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, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, - 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x6e, - 0x63, 0x69, 0x70, 0x61, 0x6c, 0x49, 0x64, 0x22, 0x29, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x32, 0x97, 0x01, 0x0a, 0x10, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x48, 0x54, 0x54, 0x50, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x65, 0x66, 0x73, 0x12, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, - 0x61, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 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, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x26, 0x0a, 0x10, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x80, 0x02, 0x0a, + 0x12, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 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, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, + 0x42, 0x61, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x0a, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x62, 0x61, + 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x57, + 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x09, 0x77, + 0x72, 0x69, 0x74, 0x65, 0x42, 0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x42, 0x06, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x22, + 0x29, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x97, 0x01, 0x0a, 0x10, 0x53, + 0x6d, 0x61, 0x72, 0x74, 0x48, 0x54, 0x54, 0x50, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x3b, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x12, 0x14, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x0b, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x28, 0x01, 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, } var ( @@ -348,17 +379,22 @@ var file_http_proto_goTypes = []interface{}{ (*InfoRefsResponse)(nil), // 1: rpc.InfoRefsResponse (*ServicePackRequest)(nil), // 2: rpc.ServicePackRequest (*ServicePackResponse)(nil), // 3: rpc.ServicePackResponse + (*ReadRequest)(nil), // 4: rpc.ReadRequest + (*WriteRequest)(nil), // 5: rpc.WriteRequest } var file_http_proto_depIdxs = []int32{ - 0, // 0: rpc.SmartHTTPService.InfoRefs:input_type -> rpc.InfoRefsRequest - 2, // 1: rpc.SmartHTTPService.ServicePack:input_type -> rpc.ServicePackRequest - 1, // 2: rpc.SmartHTTPService.InfoRefs:output_type -> rpc.InfoRefsResponse - 3, // 3: rpc.SmartHTTPService.ServicePack:output_type -> rpc.ServicePackResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 4, // 0: rpc.InfoRefsRequest.base:type_name -> rpc.ReadRequest + 4, // 1: rpc.ServicePackRequest.read_base:type_name -> rpc.ReadRequest + 5, // 2: rpc.ServicePackRequest.write_base:type_name -> rpc.WriteRequest + 0, // 3: rpc.SmartHTTPService.InfoRefs:input_type -> rpc.InfoRefsRequest + 2, // 4: rpc.SmartHTTPService.ServicePack:input_type -> rpc.ServicePackRequest + 1, // 5: rpc.SmartHTTPService.InfoRefs:output_type -> rpc.InfoRefsResponse + 3, // 6: rpc.SmartHTTPService.ServicePack:output_type -> rpc.ServicePackResponse + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_http_proto_init() } @@ -366,6 +402,7 @@ func file_http_proto_init() { if File_http_proto != nil { return } + file_shared_proto_init() if !protoimpl.UnsafeEnabled { file_http_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InfoRefsRequest); i { @@ -416,6 +453,10 @@ func file_http_proto_init() { } } } + file_http_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*ServicePackRequest_ReadBase)(nil), + (*ServicePackRequest_WriteBase)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/gitrpc/rpc/operations.pb.go b/gitrpc/rpc/operations.pb.go index 34e06ba4f..75f202086 100644 --- a/gitrpc/rpc/operations.pb.go +++ b/gitrpc/rpc/operations.pb.go @@ -83,14 +83,12 @@ type CommitFilesRequestHeader struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // repository is the target repository where to apply the commit. - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - BranchName string `protobuf:"bytes,2,opt,name=branch_name,json=branchName,proto3" json:"branch_name,omitempty"` - NewBranchName string `protobuf:"bytes,3,opt,name=new_branch_name,json=newBranchName,proto3" json:"new_branch_name,omitempty"` - Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` - Message string `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"` - Author *Identity `protobuf:"bytes,6,opt,name=author,proto3" json:"author,omitempty"` - Committer *Identity `protobuf:"bytes,7,opt,name=committer,proto3" json:"committer,omitempty"` + Base *WriteRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + BranchName string `protobuf:"bytes,2,opt,name=branch_name,json=branchName,proto3" json:"branch_name,omitempty"` + NewBranchName string `protobuf:"bytes,3,opt,name=new_branch_name,json=newBranchName,proto3" json:"new_branch_name,omitempty"` + Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` + Message string `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"` + Author *Identity `protobuf:"bytes,6,opt,name=author,proto3" json:"author,omitempty"` } func (x *CommitFilesRequestHeader) Reset() { @@ -125,11 +123,11 @@ func (*CommitFilesRequestHeader) Descriptor() ([]byte, []int) { return file_operations_proto_rawDescGZIP(), []int{0} } -func (x *CommitFilesRequestHeader) GetRepoUid() string { +func (x *CommitFilesRequestHeader) GetBase() *WriteRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *CommitFilesRequestHeader) GetBranchName() string { @@ -167,13 +165,6 @@ func (x *CommitFilesRequestHeader) GetAuthor() *Identity { return nil } -func (x *CommitFilesRequestHeader) GetCommitter() *Identity { - if x != nil { - return x.Committer - } - return nil -} - // CommitFilesActionHeader contains the details of the action to be performed. type CommitFilesActionHeader struct { state protoimpl.MessageState @@ -468,65 +459,62 @@ var File_operations_proto protoreflect.FileDescriptor var file_operations_proto_rawDesc = []byte{ 0x0a, 0x10, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, 0x63, 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x82, 0x02, 0x0a, 0x18, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe1, 0x01, 0x0a, 0x18, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 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, 0x1f, 0x0a, - 0x0b, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, - 0x0a, 0x0f, 0x6e, 0x65, 0x77, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x77, 0x42, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x2b, 0x0a, - 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, - 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x22, 0xbc, 0x01, 0x0a, 0x17, 0x43, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x3f, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, - 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x73, - 0x68, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x22, 0x3a, 0x0a, - 0x0a, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x43, - 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, - 0x45, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x02, 0x12, - 0x08, 0x0a, 0x04, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x03, 0x22, 0x72, 0x0a, 0x11, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x36, - 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, - 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 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, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x8a, 0x01, - 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x30, 0x0a, - 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, + 0x65, 0x72, 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, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x72, 0x61, + 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, + 0x77, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x77, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x22, 0xbc, 0x01, 0x0a, 0x17, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x3f, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x06, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x22, 0x3a, 0x0a, 0x0a, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x52, + 0x45, 0x41, 0x54, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x03, 0x22, 0x72, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, + 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, - 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x4a, 0x0a, 0x13, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 0x12, 0x16, - 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x32, 0x58, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x46, 0x69, 0x6c, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x42, 0x0a, 0x0b, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 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, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 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, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x8a, 0x01, 0x0a, + 0x12, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x06, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, + 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x4a, 0x0a, 0x13, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, + 0x72, 0x61, 0x6e, 0x63, 0x68, 0x32, 0x58, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, + 0x69, 0x6c, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 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, } var ( @@ -550,11 +538,12 @@ var file_operations_proto_goTypes = []interface{}{ (*CommitFilesAction)(nil), // 3: rpc.CommitFilesAction (*CommitFilesRequest)(nil), // 4: rpc.CommitFilesRequest (*CommitFilesResponse)(nil), // 5: rpc.CommitFilesResponse - (*Identity)(nil), // 6: rpc.Identity + (*WriteRequest)(nil), // 6: rpc.WriteRequest + (*Identity)(nil), // 7: rpc.Identity } var file_operations_proto_depIdxs = []int32{ - 6, // 0: rpc.CommitFilesRequestHeader.author:type_name -> rpc.Identity - 6, // 1: rpc.CommitFilesRequestHeader.committer:type_name -> rpc.Identity + 6, // 0: rpc.CommitFilesRequestHeader.base:type_name -> rpc.WriteRequest + 7, // 1: rpc.CommitFilesRequestHeader.author:type_name -> rpc.Identity 0, // 2: rpc.CommitFilesActionHeader.action:type_name -> rpc.CommitFilesActionHeader.ActionType 2, // 3: rpc.CommitFilesAction.header:type_name -> rpc.CommitFilesActionHeader 1, // 4: rpc.CommitFilesRequest.header:type_name -> rpc.CommitFilesRequestHeader diff --git a/gitrpc/rpc/ref.pb.go b/gitrpc/rpc/ref.pb.go index 3225cea92..6c6c2fa7a 100644 --- a/gitrpc/rpc/ref.pb.go +++ b/gitrpc/rpc/ref.pb.go @@ -169,9 +169,9 @@ type CreateBranchRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - BranchName string `protobuf:"bytes,2,opt,name=branch_name,json=branchName,proto3" json:"branch_name,omitempty"` - Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"` + Base *WriteRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + BranchName string `protobuf:"bytes,2,opt,name=branch_name,json=branchName,proto3" json:"branch_name,omitempty"` + Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"` } func (x *CreateBranchRequest) Reset() { @@ -206,11 +206,11 @@ func (*CreateBranchRequest) Descriptor() ([]byte, []int) { return file_ref_proto_rawDescGZIP(), []int{0} } -func (x *CreateBranchRequest) GetRepoUid() string { +func (x *CreateBranchRequest) GetBase() *WriteRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *CreateBranchRequest) GetBranchName() string { @@ -279,9 +279,9 @@ type DeleteBranchRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - BranchName string `protobuf:"bytes,2,opt,name=branch_name,json=branchName,proto3" json:"branch_name,omitempty"` - Force bool `protobuf:"varint,3,opt,name=force,proto3" json:"force,omitempty"` + Base *WriteRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + BranchName string `protobuf:"bytes,2,opt,name=branch_name,json=branchName,proto3" json:"branch_name,omitempty"` + Force bool `protobuf:"varint,3,opt,name=force,proto3" json:"force,omitempty"` } func (x *DeleteBranchRequest) Reset() { @@ -316,11 +316,11 @@ func (*DeleteBranchRequest) Descriptor() ([]byte, []int) { return file_ref_proto_rawDescGZIP(), []int{2} } -func (x *DeleteBranchRequest) GetRepoUid() string { +func (x *DeleteBranchRequest) GetBase() *WriteRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *DeleteBranchRequest) GetBranchName() string { @@ -341,6 +341,8 @@ type DeleteBranchResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Sha string `protobuf:"bytes,1,opt,name=sha,proto3" json:"sha,omitempty"` } func (x *DeleteBranchResponse) Reset() { @@ -375,12 +377,19 @@ func (*DeleteBranchResponse) Descriptor() ([]byte, []int) { return file_ref_proto_rawDescGZIP(), []int{3} } +func (x *DeleteBranchResponse) GetSha() string { + if x != nil { + return x.Sha + } + return "" +} + type ListBranchesRequest 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"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` IncludeCommit bool `protobuf:"varint,2,opt,name=include_commit,json=includeCommit,proto3" json:"include_commit,omitempty"` Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"` Sort ListBranchesRequest_SortOption `protobuf:"varint,4,opt,name=sort,proto3,enum=rpc.ListBranchesRequest_SortOption" json:"sort,omitempty"` @@ -421,11 +430,11 @@ func (*ListBranchesRequest) Descriptor() ([]byte, []int) { return file_ref_proto_rawDescGZIP(), []int{4} } -func (x *ListBranchesRequest) GetRepoUid() string { +func (x *ListBranchesRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *ListBranchesRequest) GetIncludeCommit() bool { @@ -585,7 +594,7 @@ type ListCommitTagsRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` IncludeCommit bool `protobuf:"varint,2,opt,name=include_commit,json=includeCommit,proto3" json:"include_commit,omitempty"` Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"` Sort ListCommitTagsRequest_SortOption `protobuf:"varint,4,opt,name=sort,proto3,enum=rpc.ListCommitTagsRequest_SortOption" json:"sort,omitempty"` @@ -626,11 +635,11 @@ func (*ListCommitTagsRequest) Descriptor() ([]byte, []int) { return file_ref_proto_rawDescGZIP(), []int{7} } -func (x *ListCommitTagsRequest) GetRepoUid() string { +func (x *ListCommitTagsRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *ListCommitTagsRequest) GetIncludeCommit() bool { @@ -822,7 +831,7 @@ type GetRefRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` RefName string `protobuf:"bytes,2,opt,name=ref_name,json=refName,proto3" json:"ref_name,omitempty"` RefType GetRefRequest_RefType `protobuf:"varint,3,opt,name=ref_type,json=refType,proto3,enum=rpc.GetRefRequest_RefType" json:"ref_type,omitempty"` } @@ -859,11 +868,11 @@ func (*GetRefRequest) Descriptor() ([]byte, []int) { return file_ref_proto_rawDescGZIP(), []int{10} } -func (x *GetRefRequest) GetRepoUid() string { +func (x *GetRefRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *GetRefRequest) GetRefName() string { @@ -931,57 +940,61 @@ var File_ref_proto protoreflect.FileDescriptor var file_ref_proto_rawDesc = []byte{ 0x0a, 0x09, 0x72, 0x65, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, 0x63, - 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x69, + 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x75, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 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, 0x1f, 0x0a, 0x0b, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x3b, 0x0a, 0x14, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x23, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x06, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x22, 0x67, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 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, 0x1f, 0x0a, 0x0b, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, - 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x22, - 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xab, 0x02, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 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, 0x25, 0x0a, 0x0e, 0x69, 0x6e, - 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x37, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, - 0x53, 0x6f, 0x72, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, - 0x12, 0x24, 0x0a, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, - 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, - 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, - 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x2d, 0x0a, 0x0a, 0x53, 0x6f, 0x72, 0x74, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x10, - 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, - 0x61, 0x74, 0x65, 0x10, 0x02, 0x22, 0x3b, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, - 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, + 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, 0x12, 0x1f, 0x0a, 0x0b, + 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x3b, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, + 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x06, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x22, 0x53, 0x0a, 0x06, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, - 0x68, 0x61, 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x03, 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, 0xaf, 0x02, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 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, 0x25, 0x0a, 0x0e, + 0x63, 0x68, 0x22, 0x73, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, + 0x63, 0x68, 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, + 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x22, 0x28, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, + 0x61, 0x22, 0xb6, 0x02, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, + 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, + 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x37, 0x0a, 0x04, + 0x73, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x04, 0x73, 0x6f, 0x72, 0x74, 0x12, 0x24, 0x0a, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x4f, + 0x72, 0x64, 0x65, 0x72, 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, + 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x2d, 0x0a, 0x0a, 0x53, + 0x6f, 0x72, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x66, + 0x61, 0x75, 0x6c, 0x74, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x10, 0x01, + 0x12, 0x08, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x65, 0x10, 0x02, 0x22, 0x3b, 0x0a, 0x14, 0x4c, 0x69, + 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, + 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x22, 0x53, 0x0a, 0x06, 0x42, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x18, 0x03, 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, 0xba, 0x02, 0x0a, + 0x15, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 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, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, @@ -1014,45 +1027,45 @@ var file_ref_proto_rawDesc = []byte{ 0x70, 0x63, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x06, 0x74, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x07, 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, 0x9c, 0x01, 0x0a, 0x0d, 0x47, 0x65, - 0x74, 0x52, 0x65, 0x66, 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, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x66, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x35, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x52, - 0x07, 0x72, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x22, 0x1e, 0x0a, 0x07, 0x52, 0x65, 0x66, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x10, 0x00, 0x12, - 0x07, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x10, 0x01, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, - 0x65, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x32, 0xe3, 0x02, 0x0a, - 0x10, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, - 0x68, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, + 0x74, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x22, 0xa7, 0x01, 0x0a, 0x0d, 0x47, 0x65, + 0x74, 0x52, 0x65, 0x66, 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, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x66, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x08, + 0x72, 0x65, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x2e, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x72, 0x65, 0x66, 0x54, + 0x79, 0x70, 0x65, 0x22, 0x1e, 0x0a, 0x07, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, + 0x0a, 0x06, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x61, + 0x67, 0x10, 0x01, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x32, 0xe3, 0x02, 0x0a, 0x10, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0c, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x18, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, - 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x4c, - 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x30, 0x01, 0x12, 0x4b, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x54, 0x61, 0x67, 0x73, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, - 0x31, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x12, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 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, + 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x4b, 0x0a, + 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, + 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x06, 0x47, 0x65, + 0x74, 0x52, 0x65, 0x66, 0x12, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x66, 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 ( @@ -1085,37 +1098,44 @@ var file_ref_proto_goTypes = []interface{}{ (*CommitTag)(nil), // 12: rpc.CommitTag (*GetRefRequest)(nil), // 13: rpc.GetRefRequest (*GetRefResponse)(nil), // 14: rpc.GetRefResponse - (SortOrder)(0), // 15: rpc.SortOrder - (*Commit)(nil), // 16: rpc.Commit - (*Signature)(nil), // 17: rpc.Signature + (*WriteRequest)(nil), // 15: rpc.WriteRequest + (*ReadRequest)(nil), // 16: rpc.ReadRequest + (SortOrder)(0), // 17: rpc.SortOrder + (*Commit)(nil), // 18: rpc.Commit + (*Signature)(nil), // 19: rpc.Signature } var file_ref_proto_depIdxs = []int32{ - 9, // 0: rpc.CreateBranchResponse.branch:type_name -> rpc.Branch - 0, // 1: rpc.ListBranchesRequest.sort:type_name -> rpc.ListBranchesRequest.SortOption - 15, // 2: rpc.ListBranchesRequest.order:type_name -> rpc.SortOrder - 9, // 3: rpc.ListBranchesResponse.branch:type_name -> rpc.Branch - 16, // 4: rpc.Branch.commit:type_name -> rpc.Commit - 1, // 5: rpc.ListCommitTagsRequest.sort:type_name -> rpc.ListCommitTagsRequest.SortOption - 15, // 6: rpc.ListCommitTagsRequest.order:type_name -> rpc.SortOrder - 12, // 7: rpc.ListCommitTagsResponse.tag:type_name -> rpc.CommitTag - 17, // 8: rpc.CommitTag.tagger:type_name -> rpc.Signature - 16, // 9: rpc.CommitTag.commit:type_name -> rpc.Commit - 2, // 10: rpc.GetRefRequest.ref_type:type_name -> rpc.GetRefRequest.RefType - 3, // 11: rpc.ReferenceService.CreateBranch:input_type -> rpc.CreateBranchRequest - 5, // 12: rpc.ReferenceService.DeleteBranch:input_type -> rpc.DeleteBranchRequest - 7, // 13: rpc.ReferenceService.ListBranches:input_type -> rpc.ListBranchesRequest - 10, // 14: rpc.ReferenceService.ListCommitTags:input_type -> rpc.ListCommitTagsRequest - 13, // 15: rpc.ReferenceService.GetRef:input_type -> rpc.GetRefRequest - 4, // 16: rpc.ReferenceService.CreateBranch:output_type -> rpc.CreateBranchResponse - 6, // 17: rpc.ReferenceService.DeleteBranch:output_type -> rpc.DeleteBranchResponse - 8, // 18: rpc.ReferenceService.ListBranches:output_type -> rpc.ListBranchesResponse - 11, // 19: rpc.ReferenceService.ListCommitTags:output_type -> rpc.ListCommitTagsResponse - 14, // 20: rpc.ReferenceService.GetRef:output_type -> rpc.GetRefResponse - 16, // [16:21] is the sub-list for method output_type - 11, // [11:16] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 15, // 0: rpc.CreateBranchRequest.base:type_name -> rpc.WriteRequest + 9, // 1: rpc.CreateBranchResponse.branch:type_name -> rpc.Branch + 15, // 2: rpc.DeleteBranchRequest.base:type_name -> rpc.WriteRequest + 16, // 3: rpc.ListBranchesRequest.base:type_name -> rpc.ReadRequest + 0, // 4: rpc.ListBranchesRequest.sort:type_name -> rpc.ListBranchesRequest.SortOption + 17, // 5: rpc.ListBranchesRequest.order:type_name -> rpc.SortOrder + 9, // 6: rpc.ListBranchesResponse.branch:type_name -> rpc.Branch + 18, // 7: rpc.Branch.commit:type_name -> rpc.Commit + 16, // 8: rpc.ListCommitTagsRequest.base:type_name -> rpc.ReadRequest + 1, // 9: rpc.ListCommitTagsRequest.sort:type_name -> rpc.ListCommitTagsRequest.SortOption + 17, // 10: rpc.ListCommitTagsRequest.order:type_name -> rpc.SortOrder + 12, // 11: rpc.ListCommitTagsResponse.tag:type_name -> rpc.CommitTag + 19, // 12: rpc.CommitTag.tagger:type_name -> rpc.Signature + 18, // 13: rpc.CommitTag.commit:type_name -> rpc.Commit + 16, // 14: rpc.GetRefRequest.base:type_name -> rpc.ReadRequest + 2, // 15: rpc.GetRefRequest.ref_type:type_name -> rpc.GetRefRequest.RefType + 3, // 16: rpc.ReferenceService.CreateBranch:input_type -> rpc.CreateBranchRequest + 5, // 17: rpc.ReferenceService.DeleteBranch:input_type -> rpc.DeleteBranchRequest + 7, // 18: rpc.ReferenceService.ListBranches:input_type -> rpc.ListBranchesRequest + 10, // 19: rpc.ReferenceService.ListCommitTags:input_type -> rpc.ListCommitTagsRequest + 13, // 20: rpc.ReferenceService.GetRef:input_type -> rpc.GetRefRequest + 4, // 21: rpc.ReferenceService.CreateBranch:output_type -> rpc.CreateBranchResponse + 6, // 22: rpc.ReferenceService.DeleteBranch:output_type -> rpc.DeleteBranchResponse + 8, // 23: rpc.ReferenceService.ListBranches:output_type -> rpc.ListBranchesResponse + 11, // 24: rpc.ReferenceService.ListCommitTags:output_type -> rpc.ListCommitTagsResponse + 14, // 25: rpc.ReferenceService.GetRef:output_type -> rpc.GetRefResponse + 21, // [21:26] is the sub-list for method output_type + 16, // [16:21] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_ref_proto_init() } diff --git a/gitrpc/rpc/repo.pb.go b/gitrpc/rpc/repo.pb.go index fd64f0836..8eee8a043 100644 --- a/gitrpc/rpc/repo.pb.go +++ b/gitrpc/rpc/repo.pb.go @@ -209,8 +209,8 @@ type CreateRepositoryRequestHeader struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` - DefaultBranch string `protobuf:"bytes,2,opt,name=default_branch,json=defaultBranch,proto3" json:"default_branch,omitempty"` + Base *WriteRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + DefaultBranch string `protobuf:"bytes,2,opt,name=default_branch,json=defaultBranch,proto3" json:"default_branch,omitempty"` } func (x *CreateRepositoryRequestHeader) Reset() { @@ -245,11 +245,11 @@ func (*CreateRepositoryRequestHeader) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{1} } -func (x *CreateRepositoryRequestHeader) GetUid() string { +func (x *CreateRepositoryRequestHeader) GetBase() *WriteRequest { if x != nil { - return x.Uid + return x.Base } - return "" + return nil } func (x *CreateRepositoryRequestHeader) GetDefaultBranch() string { @@ -302,10 +302,10 @@ type GetTreeNodeRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - IncludeLatestCommit bool `protobuf:"varint,4,opt,name=include_latest_commit,json=includeLatestCommit,proto3" json:"include_latest_commit,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` + Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` + IncludeLatestCommit bool `protobuf:"varint,4,opt,name=include_latest_commit,json=includeLatestCommit,proto3" json:"include_latest_commit,omitempty"` } func (x *GetTreeNodeRequest) Reset() { @@ -340,11 +340,11 @@ func (*GetTreeNodeRequest) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{3} } -func (x *GetTreeNodeRequest) GetRepoUid() string { +func (x *GetTreeNodeRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *GetTreeNodeRequest) GetGitRef() string { @@ -428,11 +428,11 @@ type ListTreeNodesRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - IncludeLatestCommit bool `protobuf:"varint,4,opt,name=include_latest_commit,json=includeLatestCommit,proto3" json:"include_latest_commit,omitempty"` - Recursive bool `protobuf:"varint,5,opt,name=recursive,proto3" json:"recursive,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` + Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` + IncludeLatestCommit bool `protobuf:"varint,4,opt,name=include_latest_commit,json=includeLatestCommit,proto3" json:"include_latest_commit,omitempty"` + Recursive bool `protobuf:"varint,5,opt,name=recursive,proto3" json:"recursive,omitempty"` } func (x *ListTreeNodesRequest) Reset() { @@ -467,11 +467,11 @@ func (*ListTreeNodesRequest) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{5} } -func (x *ListTreeNodesRequest) GetRepoUid() string { +func (x *ListTreeNodesRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *ListTreeNodesRequest) GetGitRef() string { @@ -641,11 +641,11 @@ type ListCommitsRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` - After string `protobuf:"bytes,3,opt,name=after,proto3" json:"after,omitempty"` - Page int32 `protobuf:"varint,4,opt,name=page,proto3" json:"page,omitempty"` - Limit int32 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` + After string `protobuf:"bytes,3,opt,name=after,proto3" json:"after,omitempty"` + Page int32 `protobuf:"varint,4,opt,name=page,proto3" json:"page,omitempty"` + Limit int32 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"` } func (x *ListCommitsRequest) Reset() { @@ -680,11 +680,11 @@ func (*ListCommitsRequest) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{8} } -func (x *ListCommitsRequest) GetRepoUid() string { +func (x *ListCommitsRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *ListCommitsRequest) GetGitRef() string { @@ -767,9 +767,9 @@ type GetBlobRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - Sha string `protobuf:"bytes,2,opt,name=sha,proto3" json:"sha,omitempty"` - SizeLimit int64 `protobuf:"varint,3,opt,name=sizeLimit,proto3" json:"sizeLimit,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + Sha string `protobuf:"bytes,2,opt,name=sha,proto3" json:"sha,omitempty"` + SizeLimit int64 `protobuf:"varint,3,opt,name=sizeLimit,proto3" json:"sizeLimit,omitempty"` } func (x *GetBlobRequest) Reset() { @@ -804,11 +804,11 @@ func (*GetBlobRequest) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{10} } -func (x *GetBlobRequest) GetRepoUid() string { +func (x *GetBlobRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *GetBlobRequest) GetSha() string { @@ -940,9 +940,9 @@ type GetSubmoduleRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` - GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` + GitRef string `protobuf:"bytes,2,opt,name=git_ref,json=gitRef,proto3" json:"git_ref,omitempty"` + Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` } func (x *GetSubmoduleRequest) Reset() { @@ -977,11 +977,11 @@ func (*GetSubmoduleRequest) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{13} } -func (x *GetSubmoduleRequest) GetRepoUid() string { +func (x *GetSubmoduleRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *GetSubmoduleRequest) GetGitRef() string { @@ -1105,7 +1105,7 @@ type GetCommitDivergencesRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RepoUid string `protobuf:"bytes,1,opt,name=repo_uid,json=repoUid,proto3" json:"repo_uid,omitempty"` + Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,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"` } @@ -1142,11 +1142,11 @@ func (*GetCommitDivergencesRequest) Descriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{16} } -func (x *GetCommitDivergencesRequest) GetRepoUid() string { +func (x *GetCommitDivergencesRequest) GetBase() *ReadRequest { if x != nil { - return x.RepoUid + return x.Base } - return "" + return nil } func (x *GetCommitDivergencesRequest) GetMaxCount() int32 { @@ -1333,17 +1333,19 @@ var file_repo_proto_rawDesc = []byte{ 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x00, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, - 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x58, 0x0a, 0x1d, 0x43, 0x72, 0x65, 0x61, + 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x6d, 0x0a, 0x1d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x22, 0x1a, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x90, - 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 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, + 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 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, + 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x22, 0x1a, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x9b, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, + 0x6f, 0x64, 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, 0x12, 0x32, 0x0a, @@ -1356,145 +1358,148 @@ var file_repo_proto_rawDesc = []byte{ 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 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, 0xb0, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, - 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, 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, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x6c, 0x61, 0x74, - 0x65, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, - 0x76, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, - 0x69, 0x76, 0x65, 0x22, 0x5f, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, - 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x04, - 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, - 0x2e, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x12, - 0x23, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 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, 0x92, 0x01, 0x0a, 0x08, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, - 0x65, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x72, 0x65, - 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, - 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, - 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x88, 0x01, 0x0a, 0x12, 0x4c, 0x69, - 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 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, 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, 0x14, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, 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, 0x22, 0x3a, 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, - 0x22, 0x5b, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 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, 0x10, 0x0a, - 0x03, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, - 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x30, 0x0a, - 0x0f, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1d, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x22, - 0x46, 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x62, 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, 0x18, 0x0a, - 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x53, 0x75, - 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 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, 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, - 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, + 0x22, 0xbb, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 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, + 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, 0x12, 0x32, 0x0a, 0x15, + 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, 0x63, + 0x6c, 0x75, 0x64, 0x65, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x09, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x22, 0x5f, + 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x72, 0x65, 0x65, + 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 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, + 0x92, 0x01, 0x0a, 0x08, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x11, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x22, 0x93, 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, 0x67, 0x69, 0x74, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x67, 0x69, 0x74, 0x52, 0x65, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x66, + 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x70, 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, 0x22, 0x3a, 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, 0x22, 0x66, 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, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x30, + 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1d, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x09, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x62, + 0x22, 0x46, 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x62, 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, 0x18, + 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 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, 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, 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, - 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, + 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 ( @@ -1535,41 +1540,50 @@ var file_repo_proto_goTypes = []interface{}{ (*GetCommitDivergencesResponse)(nil), // 20: rpc.GetCommitDivergencesResponse (*CommitDivergence)(nil), // 21: rpc.CommitDivergence (*FileUpload)(nil), // 22: rpc.FileUpload - (*Commit)(nil), // 23: rpc.Commit + (*WriteRequest)(nil), // 23: rpc.WriteRequest + (*ReadRequest)(nil), // 24: rpc.ReadRequest + (*Commit)(nil), // 25: rpc.Commit } var file_repo_proto_depIdxs = []int32{ 3, // 0: rpc.CreateRepositoryRequest.header:type_name -> rpc.CreateRepositoryRequestHeader 22, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload - 9, // 2: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode - 23, // 3: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit - 9, // 4: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode - 23, // 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 - 23, // 8: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit - 14, // 9: rpc.GetBlobResponse.blob:type_name -> rpc.Blob - 17, // 10: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule - 19, // 11: rpc.GetCommitDivergencesRequest.requests:type_name -> rpc.CommitDivergenceRequest - 21, // 12: rpc.GetCommitDivergencesResponse.divergences:type_name -> rpc.CommitDivergence - 2, // 13: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest - 5, // 14: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest - 7, // 15: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest - 15, // 16: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest - 12, // 17: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest - 10, // 18: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest - 18, // 19: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest - 4, // 20: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse - 6, // 21: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse - 8, // 22: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse - 16, // 23: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse - 13, // 24: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse - 11, // 25: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse - 20, // 26: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse - 20, // [20:27] is the sub-list for method output_type - 13, // [13:20] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 23, // 2: rpc.CreateRepositoryRequestHeader.base:type_name -> rpc.WriteRequest + 24, // 3: rpc.GetTreeNodeRequest.base:type_name -> rpc.ReadRequest + 9, // 4: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode + 25, // 5: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit + 24, // 6: rpc.ListTreeNodesRequest.base:type_name -> rpc.ReadRequest + 9, // 7: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode + 25, // 8: rpc.ListTreeNodesResponse.commit:type_name -> rpc.Commit + 0, // 9: rpc.TreeNode.type:type_name -> rpc.TreeNodeType + 1, // 10: rpc.TreeNode.mode:type_name -> rpc.TreeNodeMode + 24, // 11: rpc.ListCommitsRequest.base:type_name -> rpc.ReadRequest + 25, // 12: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit + 24, // 13: rpc.GetBlobRequest.base:type_name -> rpc.ReadRequest + 14, // 14: rpc.GetBlobResponse.blob:type_name -> rpc.Blob + 24, // 15: rpc.GetSubmoduleRequest.base:type_name -> rpc.ReadRequest + 17, // 16: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule + 24, // 17: rpc.GetCommitDivergencesRequest.base:type_name -> rpc.ReadRequest + 19, // 18: rpc.GetCommitDivergencesRequest.requests:type_name -> rpc.CommitDivergenceRequest + 21, // 19: rpc.GetCommitDivergencesResponse.divergences:type_name -> rpc.CommitDivergence + 2, // 20: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest + 5, // 21: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest + 7, // 22: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest + 15, // 23: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest + 12, // 24: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest + 10, // 25: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest + 18, // 26: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest + 4, // 27: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse + 6, // 28: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse + 8, // 29: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse + 16, // 30: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse + 13, // 31: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse + 11, // 32: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse + 20, // 33: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse + 27, // [27:34] is the sub-list for method output_type + 20, // [20:27] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name } func init() { file_repo_proto_init() } diff --git a/gitrpc/rpc/shared.pb.go b/gitrpc/rpc/shared.pb.go index 28264ddf7..c1db0cbbc 100644 --- a/gitrpc/rpc/shared.pb.go +++ b/gitrpc/rpc/shared.pb.go @@ -69,6 +69,171 @@ func (SortOrder) EnumDescriptor() ([]byte, []int) { return file_shared_proto_rawDescGZIP(), []int{0} } +type ReadRequest 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"` +} + +func (x *ReadRequest) Reset() { + *x = ReadRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_shared_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadRequest) ProtoMessage() {} + +func (x *ReadRequest) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[0] + 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 ReadRequest.ProtoReflect.Descriptor instead. +func (*ReadRequest) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{0} +} + +func (x *ReadRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +type WriteRequest 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"` + EnvVars []*EnvVar `protobuf:"bytes,2,rep,name=env_vars,json=envVars,proto3" json:"env_vars,omitempty"` + Actor *Identity `protobuf:"bytes,3,opt,name=actor,proto3" json:"actor,omitempty"` +} + +func (x *WriteRequest) Reset() { + *x = WriteRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_shared_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WriteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteRequest) ProtoMessage() {} + +func (x *WriteRequest) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[1] + 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 WriteRequest.ProtoReflect.Descriptor instead. +func (*WriteRequest) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{1} +} + +func (x *WriteRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +func (x *WriteRequest) GetEnvVars() []*EnvVar { + if x != nil { + return x.EnvVars + } + return nil +} + +func (x *WriteRequest) GetActor() *Identity { + if x != nil { + return x.Actor + } + return nil +} + +type EnvVar struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *EnvVar) Reset() { + *x = EnvVar{} + if protoimpl.UnsafeEnabled { + mi := &file_shared_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EnvVar) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnvVar) ProtoMessage() {} + +func (x *EnvVar) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[2] + 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 EnvVar.ProtoReflect.Descriptor instead. +func (*EnvVar) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{2} +} + +func (x *EnvVar) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *EnvVar) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + type FileUpload struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -83,7 +248,7 @@ type FileUpload struct { func (x *FileUpload) Reset() { *x = FileUpload{} if protoimpl.UnsafeEnabled { - mi := &file_shared_proto_msgTypes[0] + mi := &file_shared_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -96,7 +261,7 @@ func (x *FileUpload) String() string { func (*FileUpload) ProtoMessage() {} func (x *FileUpload) ProtoReflect() protoreflect.Message { - mi := &file_shared_proto_msgTypes[0] + mi := &file_shared_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -109,7 +274,7 @@ func (x *FileUpload) ProtoReflect() protoreflect.Message { // Deprecated: Use FileUpload.ProtoReflect.Descriptor instead. func (*FileUpload) Descriptor() ([]byte, []int) { - return file_shared_proto_rawDescGZIP(), []int{0} + return file_shared_proto_rawDescGZIP(), []int{3} } func (m *FileUpload) GetData() isFileUpload_Data { @@ -160,7 +325,7 @@ type FileUploadHeader struct { func (x *FileUploadHeader) Reset() { *x = FileUploadHeader{} if protoimpl.UnsafeEnabled { - mi := &file_shared_proto_msgTypes[1] + mi := &file_shared_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -173,7 +338,7 @@ func (x *FileUploadHeader) String() string { func (*FileUploadHeader) ProtoMessage() {} func (x *FileUploadHeader) ProtoReflect() protoreflect.Message { - mi := &file_shared_proto_msgTypes[1] + mi := &file_shared_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -186,7 +351,7 @@ func (x *FileUploadHeader) ProtoReflect() protoreflect.Message { // Deprecated: Use FileUploadHeader.ProtoReflect.Descriptor instead. func (*FileUploadHeader) Descriptor() ([]byte, []int) { - return file_shared_proto_rawDescGZIP(), []int{1} + return file_shared_proto_rawDescGZIP(), []int{4} } func (x *FileUploadHeader) GetPath() string { @@ -208,7 +373,7 @@ type Chunk struct { func (x *Chunk) Reset() { *x = Chunk{} if protoimpl.UnsafeEnabled { - mi := &file_shared_proto_msgTypes[2] + mi := &file_shared_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -221,7 +386,7 @@ func (x *Chunk) String() string { func (*Chunk) ProtoMessage() {} func (x *Chunk) ProtoReflect() protoreflect.Message { - mi := &file_shared_proto_msgTypes[2] + mi := &file_shared_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -234,7 +399,7 @@ func (x *Chunk) ProtoReflect() protoreflect.Message { // Deprecated: Use Chunk.ProtoReflect.Descriptor instead. func (*Chunk) Descriptor() ([]byte, []int) { - return file_shared_proto_rawDescGZIP(), []int{2} + return file_shared_proto_rawDescGZIP(), []int{5} } func (x *Chunk) GetEof() bool { @@ -266,7 +431,7 @@ type Commit struct { func (x *Commit) Reset() { *x = Commit{} if protoimpl.UnsafeEnabled { - mi := &file_shared_proto_msgTypes[3] + mi := &file_shared_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -279,7 +444,7 @@ func (x *Commit) String() string { func (*Commit) ProtoMessage() {} func (x *Commit) ProtoReflect() protoreflect.Message { - mi := &file_shared_proto_msgTypes[3] + mi := &file_shared_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -292,7 +457,7 @@ func (x *Commit) ProtoReflect() protoreflect.Message { // Deprecated: Use Commit.ProtoReflect.Descriptor instead. func (*Commit) Descriptor() ([]byte, []int) { - return file_shared_proto_rawDescGZIP(), []int{3} + return file_shared_proto_rawDescGZIP(), []int{6} } func (x *Commit) GetSha() string { @@ -342,7 +507,7 @@ type Signature struct { func (x *Signature) Reset() { *x = Signature{} if protoimpl.UnsafeEnabled { - mi := &file_shared_proto_msgTypes[4] + mi := &file_shared_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -355,7 +520,7 @@ func (x *Signature) String() string { func (*Signature) ProtoMessage() {} func (x *Signature) ProtoReflect() protoreflect.Message { - mi := &file_shared_proto_msgTypes[4] + mi := &file_shared_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -368,7 +533,7 @@ func (x *Signature) ProtoReflect() protoreflect.Message { // Deprecated: Use Signature.ProtoReflect.Descriptor instead. func (*Signature) Descriptor() ([]byte, []int) { - return file_shared_proto_rawDescGZIP(), []int{4} + return file_shared_proto_rawDescGZIP(), []int{7} } func (x *Signature) GetIdentity() *Identity { @@ -397,7 +562,7 @@ type Identity struct { func (x *Identity) Reset() { *x = Identity{} if protoimpl.UnsafeEnabled { - mi := &file_shared_proto_msgTypes[5] + mi := &file_shared_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -410,7 +575,7 @@ func (x *Identity) String() string { func (*Identity) ProtoMessage() {} func (x *Identity) ProtoReflect() protoreflect.Message { - mi := &file_shared_proto_msgTypes[5] + mi := &file_shared_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -423,7 +588,7 @@ func (x *Identity) ProtoReflect() protoreflect.Message { // Deprecated: Use Identity.ProtoReflect.Descriptor instead. func (*Identity) Descriptor() ([]byte, []int) { - return file_shared_proto_rawDescGZIP(), []int{5} + return file_shared_proto_rawDescGZIP(), []int{8} } func (x *Identity) GetName() string { @@ -444,43 +609,56 @@ var File_shared_proto protoreflect.FileDescriptor var file_shared_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, - 0x72, 0x70, 0x63, 0x22, 0x69, 0x0a, 0x0a, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, - 0x64, 0x12, 0x2f, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, - 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x12, 0x22, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x00, 0x52, - 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x26, - 0x0a, 0x10, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x2d, 0x0a, 0x05, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, - 0x10, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x65, 0x6f, - 0x66, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa0, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, - 0x68, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x72, 0x70, 0x63, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x63, - 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x22, 0x4a, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x12, 0x12, 0x0a, 0x04, 0x77, 0x68, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, - 0x77, 0x68, 0x65, 0x6e, 0x22, 0x34, 0x0a, 0x08, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2a, 0x2b, 0x0a, 0x09, 0x53, 0x6f, - 0x72, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x73, 0x63, 0x10, 0x01, 0x12, 0x08, 0x0a, - 0x04, 0x44, 0x65, 0x73, 0x63, 0x10, 0x02, 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, + 0x72, 0x70, 0x63, 0x22, 0x28, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 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, 0x22, 0x76, 0x0a, + 0x0c, 0x57, 0x72, 0x69, 0x74, 0x65, 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, 0x26, 0x0a, 0x08, 0x65, 0x6e, 0x76, 0x5f, + 0x76, 0x61, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, + 0x12, 0x23, 0x0a, 0x05, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x05, + 0x61, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x32, 0x0a, 0x06, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x69, 0x0a, 0x0a, 0x46, 0x69, 0x6c, + 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x2f, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, + 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, + 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, + 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, + 0x75, 0x6e, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x42, 0x06, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x22, 0x26, 0x0a, 0x10, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x2d, 0x0a, 0x05, + 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x03, 0x65, 0x6f, 0x66, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa0, 0x01, 0x0a, 0x06, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, + 0x12, 0x2c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x72, 0x22, 0x4a, + 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x08, 0x69, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x77, 0x68, 0x65, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x77, 0x68, 0x65, 0x6e, 0x22, 0x34, 0x0a, 0x08, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, + 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x2a, 0x2b, 0x0a, 0x09, 0x53, 0x6f, 0x72, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x0b, 0x0a, + 0x07, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x73, + 0x63, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x65, 0x73, 0x63, 0x10, 0x02, 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 ( @@ -496,27 +674,32 @@ func file_shared_proto_rawDescGZIP() []byte { } var file_shared_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_shared_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_shared_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_shared_proto_goTypes = []interface{}{ (SortOrder)(0), // 0: rpc.SortOrder - (*FileUpload)(nil), // 1: rpc.FileUpload - (*FileUploadHeader)(nil), // 2: rpc.FileUploadHeader - (*Chunk)(nil), // 3: rpc.Chunk - (*Commit)(nil), // 4: rpc.Commit - (*Signature)(nil), // 5: rpc.Signature - (*Identity)(nil), // 6: rpc.Identity + (*ReadRequest)(nil), // 1: rpc.ReadRequest + (*WriteRequest)(nil), // 2: rpc.WriteRequest + (*EnvVar)(nil), // 3: rpc.EnvVar + (*FileUpload)(nil), // 4: rpc.FileUpload + (*FileUploadHeader)(nil), // 5: rpc.FileUploadHeader + (*Chunk)(nil), // 6: rpc.Chunk + (*Commit)(nil), // 7: rpc.Commit + (*Signature)(nil), // 8: rpc.Signature + (*Identity)(nil), // 9: rpc.Identity } var file_shared_proto_depIdxs = []int32{ - 2, // 0: rpc.FileUpload.header:type_name -> rpc.FileUploadHeader - 3, // 1: rpc.FileUpload.chunk:type_name -> rpc.Chunk - 5, // 2: rpc.Commit.author:type_name -> rpc.Signature - 5, // 3: rpc.Commit.committer:type_name -> rpc.Signature - 6, // 4: rpc.Signature.identity:type_name -> rpc.Identity - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 3, // 0: rpc.WriteRequest.env_vars:type_name -> rpc.EnvVar + 9, // 1: rpc.WriteRequest.actor:type_name -> rpc.Identity + 5, // 2: rpc.FileUpload.header:type_name -> rpc.FileUploadHeader + 6, // 3: rpc.FileUpload.chunk:type_name -> rpc.Chunk + 8, // 4: rpc.Commit.author:type_name -> rpc.Signature + 8, // 5: rpc.Commit.committer:type_name -> rpc.Signature + 9, // 6: rpc.Signature.identity:type_name -> rpc.Identity + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_shared_proto_init() } @@ -526,7 +709,7 @@ func file_shared_proto_init() { } if !protoimpl.UnsafeEnabled { file_shared_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FileUpload); i { + switch v := v.(*ReadRequest); i { case 0: return &v.state case 1: @@ -538,7 +721,7 @@ func file_shared_proto_init() { } } file_shared_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FileUploadHeader); i { + switch v := v.(*WriteRequest); i { case 0: return &v.state case 1: @@ -550,7 +733,7 @@ func file_shared_proto_init() { } } file_shared_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Chunk); i { + switch v := v.(*EnvVar); i { case 0: return &v.state case 1: @@ -562,7 +745,7 @@ func file_shared_proto_init() { } } file_shared_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Commit); i { + switch v := v.(*FileUpload); i { case 0: return &v.state case 1: @@ -574,7 +757,7 @@ func file_shared_proto_init() { } } file_shared_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Signature); i { + switch v := v.(*FileUploadHeader); i { case 0: return &v.state case 1: @@ -586,6 +769,42 @@ func file_shared_proto_init() { } } file_shared_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Chunk); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shared_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Commit); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shared_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Signature); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shared_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Identity); i { case 0: return &v.state @@ -598,7 +817,7 @@ func file_shared_proto_init() { } } } - file_shared_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_shared_proto_msgTypes[3].OneofWrappers = []interface{}{ (*FileUpload_Header)(nil), (*FileUpload_Chunk)(nil), } @@ -608,7 +827,7 @@ func file_shared_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_shared_proto_rawDesc, NumEnums: 1, - NumMessages: 6, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/gitrpc/server/config.go b/gitrpc/server/config.go index 08fecbe01..733c15b30 100644 --- a/gitrpc/server/config.go +++ b/gitrpc/server/config.go @@ -6,7 +6,8 @@ package server // Config represents the configuration for the gitrpc server. type Config struct { - GitRoot string - ReposTempPath string - Bind string + GitRoot string + TmpDir string + Bind string + ServerHookPath string } diff --git a/gitrpc/server/server.go b/gitrpc/server/server.go index 0b30358c3..49e84ac70 100644 --- a/gitrpc/server/server.go +++ b/gitrpc/server/server.go @@ -6,13 +6,10 @@ package server import ( "errors" - "fmt" "net" "os" "path/filepath" - "github.com/harness/gitness/events" - git_events "github.com/harness/gitness/gitrpc/events" "github.com/harness/gitness/gitrpc/internal/gitea" "github.com/harness/gitness/gitrpc/internal/middleware" "github.com/harness/gitness/gitrpc/internal/service" @@ -34,7 +31,7 @@ type Server struct { Bind string } -func NewServer(config Config, eventsSystem *events.System) (*Server, error) { +func NewServer(config Config) (*Server, error) { // Create repos folder reposRoot := filepath.Join(config.GitRoot, repoSubdirName) if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) { @@ -67,17 +64,13 @@ func NewServer(config Config, eventsSystem *events.System) (*Server, error) { )), ) store := storage.NewLocalStore() - eventReporter, err := git_events.NewReporter(eventsSystem) - if err != nil { - return nil, fmt.Errorf("faield to create new event reporter: %w", err) - } // initialize services - repoService, err := service.NewRepositoryService(adapter, store, reposRoot) + repoService, err := service.NewRepositoryService(adapter, store, reposRoot, config.ServerHookPath) if err != nil { return nil, err } - refService, err := service.NewReferenceService(adapter, eventReporter, reposRoot) + refService, err := service.NewReferenceService(adapter, reposRoot, config.TmpDir) if err != nil { return nil, err } @@ -85,7 +78,7 @@ func NewServer(config Config, eventsSystem *events.System) (*Server, error) { if err != nil { return nil, err } - commitFilesService, err := service.NewCommitFilesService(adapter, reposRoot, config.ReposTempPath) + commitFilesService, err := service.NewCommitFilesService(adapter, reposRoot, config.TmpDir) if err != nil { return nil, err } diff --git a/gitrpc/server/wire.go b/gitrpc/server/wire.go index 8bffa19f6..3cf44a470 100644 --- a/gitrpc/server/wire.go +++ b/gitrpc/server/wire.go @@ -5,8 +5,6 @@ package server import ( - "github.com/harness/gitness/events" - "github.com/google/wire" ) @@ -15,6 +13,6 @@ var WireSet = wire.NewSet( ProvideServer, ) -func ProvideServer(config Config, eventsSystem *events.System) (*Server, error) { - return NewServer(config, eventsSystem) +func ProvideServer(config Config) (*Server, error) { + return NewServer(config) } diff --git a/gitrpc/smarthttp.go b/gitrpc/smarthttp.go index 69805e008..267e40050 100644 --- a/gitrpc/smarthttp.go +++ b/gitrpc/smarthttp.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "io" - "strconv" "github.com/harness/gitness/gitrpc/internal/streamio" "github.com/harness/gitness/gitrpc/rpc" @@ -18,8 +17,7 @@ import ( ) type InfoRefsParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams Service string Options []string // (key, value) pair GitProtocol string @@ -33,7 +31,7 @@ func (c *Client) GetInfoRefs(ctx context.Context, w io.Writer, params *InfoRefsP return ErrNoParamsProvided } stream, err := c.httpService.InfoRefs(ctx, &rpc.InfoRefsRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), Service: params.Service, GitConfigOptions: params.Options, GitProtocol: params.GitProtocol, @@ -63,12 +61,10 @@ func (c *Client) GetInfoRefs(ctx context.Context, w io.Writer, params *InfoRefsP } type ServicePackParams struct { - // RepoUID is the uid of the git repository - RepoUID string + *ReadParams + *WriteParams Service string GitProtocol string - // PrincipalID used for git hooks in receive-pack service - PrincipalID int64 Data io.ReadCloser Options []string // (key, value) pair } @@ -83,6 +79,32 @@ func (c *Client) ServicePack(ctx context.Context, w io.Writer, params *ServicePa log := log.Ctx(ctx) + // create request (depends on service whether we need readparams or writeparams) + // TODO: can we solve this nicer? expose two methods instead? + request := &rpc.ServicePackRequest{ + Service: params.Service, + GitConfigOptions: params.Options, + GitProtocol: params.GitProtocol, + } + switch params.Service { + case rpc.ServiceUploadPack: + if params.ReadParams == nil { + return errors.New("upload-pack requires ReadParams") + } + request.Base = &rpc.ServicePackRequest_ReadBase{ + ReadBase: mapToRPCReadRequest(*params.ReadParams), + } + case rpc.ServiceReceivePack: + if params.WriteParams == nil { + return errors.New("receive-pack requires WriteParams") + } + request.Base = &rpc.ServicePackRequest_WriteBase{ + WriteBase: mapToRPCWriteRequest(*params.WriteParams), + } + default: + return fmt.Errorf("unsupported service provided: %s", params.Service) + } + stream, err := c.httpService.ServicePack(ctx) if err != nil { return err @@ -92,13 +114,7 @@ func (c *Client) ServicePack(ctx context.Context, w io.Writer, params *ServicePa params.Service, params.Options) // send basic information - if err = stream.Send(&rpc.ServicePackRequest{ - RepoUid: params.RepoUID, - Service: params.Service, - GitConfigOptions: params.Options, - GitProtocol: params.GitProtocol, - PrincipalId: strconv.FormatInt(params.PrincipalID, 10), - }); err != nil { + if err = stream.Send(request); err != nil { return err } diff --git a/gitrpc/submodule.go b/gitrpc/submodule.go index 2c47a4e75..b1a20ad0f 100644 --- a/gitrpc/submodule.go +++ b/gitrpc/submodule.go @@ -12,8 +12,7 @@ import ( ) type GetSubmoduleParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams // GitREF is a git reference (branch / tag / commit SHA) GitREF string Path string @@ -32,9 +31,9 @@ func (c *Client) GetSubmodule(ctx context.Context, params *GetSubmoduleParams) ( return nil, ErrNoParamsProvided } resp, err := c.repoService.GetSubmodule(ctx, &rpc.GetSubmoduleRequest{ - RepoUid: params.RepoUID, - GitRef: params.GitREF, - Path: params.Path, + Base: mapToRPCReadRequest(params.ReadParams), + GitRef: params.GitREF, + Path: params.Path, }) if err != nil { return nil, processRPCErrorf(err, "failed to get submodule from server") diff --git a/gitrpc/tag.go b/gitrpc/tag.go index f8cf8fd4f..05f985a05 100644 --- a/gitrpc/tag.go +++ b/gitrpc/tag.go @@ -24,8 +24,7 @@ const ( ) type ListCommitTagsParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams IncludeCommit bool Query string Sort TagSortOption @@ -54,7 +53,7 @@ func (c *Client) ListCommitTags(ctx context.Context, params *ListCommitTagsParam } stream, err := c.refService.ListCommitTags(ctx, &rpc.ListCommitTagsRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), IncludeCommit: params.IncludeCommit, Query: params.Query, Sort: mapToRPCListCommitTagsSortOption(params.Sort), diff --git a/gitrpc/tree.go b/gitrpc/tree.go index e28879df0..03e51886e 100644 --- a/gitrpc/tree.go +++ b/gitrpc/tree.go @@ -46,8 +46,7 @@ type TreeNode struct { } type ListTreeNodeParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams // GitREF is a git reference (branch / tag / commit SHA) GitREF string Path string @@ -65,8 +64,7 @@ type TreeNodeWithCommit struct { } type GetTreeNodeParams struct { - // RepoUID is the uid of the git repository - RepoUID string + ReadParams // GitREF is a git reference (branch / tag / commit SHA) GitREF string Path string @@ -83,7 +81,7 @@ func (c *Client) GetTreeNode(ctx context.Context, params *GetTreeNodeParams) (*G return nil, ErrNoParamsProvided } resp, err := c.repoService.GetTreeNode(ctx, &rpc.GetTreeNodeRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), GitRef: params.GitREF, Path: params.Path, IncludeLatestCommit: params.IncludeLatestCommit, @@ -115,7 +113,7 @@ func (c *Client) ListTreeNodes(ctx context.Context, params *ListTreeNodeParams) return nil, ErrNoParamsProvided } stream, err := c.repoService.ListTreeNodes(ctx, &rpc.ListTreeNodesRequest{ - RepoUid: params.RepoUID, + Base: mapToRPCReadRequest(params.ReadParams), GitRef: params.GitREF, Path: params.Path, IncludeLatestCommit: params.IncludeLatestCommit, diff --git a/internal/api/controller/pullreq/controller.go b/internal/api/controller/pullreq/controller.go index 3d142fe9c..09266918c 100644 --- a/internal/api/controller/pullreq/controller.go +++ b/internal/api/controller/pullreq/controller.go @@ -11,6 +11,7 @@ import ( "github.com/harness/gitness/gitrpc" apiauth "github.com/harness/gitness/internal/api/auth" + repoctrl "github.com/harness/gitness/internal/api/controller/repo" "github.com/harness/gitness/internal/api/usererror" "github.com/harness/gitness/internal/auth" "github.com/harness/gitness/internal/auth/authz" @@ -51,13 +52,17 @@ func NewController( } } -func (c *Controller) verifyBranchExistence(ctx context.Context, repo *types.Repository, branch string) error { +func (c *Controller) verifyBranchExistence(ctx context.Context, + repo *types.Repository, branch string) error { if branch == "" { return usererror.BadRequest("branch name can't be empty") } _, err := c.gitRPCClient.GetRef(ctx, - &gitrpc.GetRefParams{RepoUID: repo.GitUID, Name: branch, Type: gitrpc.RefTypeBranch}) + &gitrpc.GetRefParams{ + ReadParams: repoctrl.CreateRPCReadParams(repo), + Name: branch, + Type: gitrpc.RefTypeBranch}) if errors.Is(err, gitrpc.ErrNotFound) { return usererror.BadRequest( fmt.Sprintf("branch %s does not exist in the repository %s", branch, repo.UID)) diff --git a/internal/api/controller/repo/commit.go b/internal/api/controller/repo/commit.go index edbbbc600..0f44b8070 100644 --- a/internal/api/controller/repo/commit.go +++ b/internal/api/controller/repo/commit.go @@ -58,12 +58,12 @@ func (c *Controller) CommitFiles(ctx context.Context, session *auth.Session, } } - commit, err := c.gitRPCClient.CommitFiles(ctx, &gitrpc.CommitFilesOptions{ - RepoID: repo.GitUID, - Title: in.Title, - Message: in.Message, - Branch: in.Branch, - NewBranch: in.NewBranch, + commit, err := c.gitRPCClient.CommitFiles(ctx, &gitrpc.CommitFilesParams{ + WriteParams: CreateRPCWriteParams(session, repo), + Title: in.Title, + Message: in.Message, + Branch: in.Branch, + NewBranch: in.NewBranch, Author: gitrpc.Identity{ Name: session.Principal.DisplayName, Email: session.Principal.Email, diff --git a/internal/api/controller/repo/controller.go b/internal/api/controller/repo/controller.go index b33973edd..496566e01 100644 --- a/internal/api/controller/repo/controller.go +++ b/internal/api/controller/repo/controller.go @@ -6,8 +6,10 @@ package repo import ( "github.com/harness/gitness/gitrpc" + "github.com/harness/gitness/internal/auth" "github.com/harness/gitness/internal/auth/authz" "github.com/harness/gitness/internal/store" + "github.com/harness/gitness/types" "github.com/harness/gitness/types/check" ) @@ -43,3 +45,28 @@ func NewController( gitRPCClient: gitRPCClient, } } + +// CreateRPCWriteParams creates base write parameters for gitrpc write operations. +// IMPORTANT: session & repo are assumed to be not nil! +func CreateRPCWriteParams(session *auth.Session, repo *types.Repository) gitrpc.WriteParams { + // generate envars (add everything githook CLI needs for execution) + // TODO: envVars := githook.GenerateGitHookEnvironmentVariables(repo, session.Principal) + envVars := map[string]string{} + + return gitrpc.WriteParams{ + Actor: gitrpc.Identity{ + Name: session.Principal.DisplayName, + Email: session.Principal.Email, + }, + RepoUID: repo.GitUID, + EnvVars: envVars, + } +} + +// CreateRPCReadParams creates base read parameters for gitrpc read operations. +// IMPORTANT: repo is assumed to be not nil! +func CreateRPCReadParams(repo *types.Repository) gitrpc.ReadParams { + return gitrpc.ReadParams{ + RepoUID: repo.GitUID, + } +} diff --git a/internal/api/controller/repo/create_branch.go b/internal/api/controller/repo/create_branch.go index b7222c3a0..0a56fb379 100644 --- a/internal/api/controller/repo/create_branch.go +++ b/internal/api/controller/repo/create_branch.go @@ -48,9 +48,9 @@ func (c *Controller) CreateBranch(ctx context.Context, session *auth.Session, } rpcOut, err := c.gitRPCClient.CreateBranch(ctx, &gitrpc.CreateBranchParams{ - RepoUID: repo.GitUID, - BranchName: in.Name, - Target: *in.Target, + WriteParams: CreateRPCWriteParams(session, repo), + BranchName: in.Name, + Target: *in.Target, }) if err != nil { return nil, err diff --git a/internal/api/controller/repo/delete_branch.go b/internal/api/controller/repo/delete_branch.go index 0b1bc2d20..75677cb8b 100644 --- a/internal/api/controller/repo/delete_branch.go +++ b/internal/api/controller/repo/delete_branch.go @@ -34,8 +34,8 @@ func (c *Controller) DeleteBranch(ctx context.Context, session *auth.Session, re } err = c.gitRPCClient.DeleteBranch(ctx, &gitrpc.DeleteBranchParams{ - RepoUID: repo.GitUID, - BranchName: branchName, + WriteParams: CreateRPCWriteParams(session, repo), + BranchName: branchName, }) if err != nil { return err diff --git a/internal/api/controller/repo/diff.go b/internal/api/controller/repo/diff.go index 45278ffc1..af3cb5a42 100644 --- a/internal/api/controller/repo/diff.go +++ b/internal/api/controller/repo/diff.go @@ -33,8 +33,8 @@ func (c *Controller) RawDiff( info := parseDiffPath(path) - return c.gitRPCClient.RawDiff(ctx, &gitrpc.RawDiffRequest{ - RepoID: repo.GitUID, + return c.gitRPCClient.RawDiff(ctx, &gitrpc.RawDiffParams{ + ReadParams: CreateRPCReadParams(repo), LeftCommitID: info.Left, RightCommitID: info.Right, }, w) diff --git a/internal/api/controller/repo/get_commit_divergences.go b/internal/api/controller/repo/get_commit_divergences.go index 7510d3182..11c1df405 100644 --- a/internal/api/controller/repo/get_commit_divergences.go +++ b/internal/api/controller/repo/get_commit_divergences.go @@ -65,9 +65,9 @@ func (c *Controller) GetCommitDivergences(ctx context.Context, session *auth.Ses // map to rpc params options := &gitrpc.GetCommitDivergencesParams{ - RepoUID: repo.GitUID, - MaxCount: in.MaxCount, - Requests: make([]gitrpc.CommitDivergenceRequest, len(in.Requests)), + ReadParams: CreateRPCReadParams(repo), + MaxCount: in.MaxCount, + Requests: make([]gitrpc.CommitDivergenceRequest, len(in.Requests)), } for i := range in.Requests { options.Requests[i].From = in.Requests[i].From diff --git a/internal/api/controller/repo/get_content.go b/internal/api/controller/repo/get_content.go index a61ac3977..9e839e1b1 100644 --- a/internal/api/controller/repo/get_content.go +++ b/internal/api/controller/repo/get_content.go @@ -122,8 +122,11 @@ func (c *Controller) GetContent(ctx context.Context, session *auth.Session, repo gitRef = repo.DefaultBranch } + // create read params once + readParams := CreateRPCReadParams(repo) + treeNodeOutput, err := c.gitRPCClient.GetTreeNode(ctx, &gitrpc.GetTreeNodeParams{ - RepoUID: repo.GitUID, + ReadParams: readParams, GitREF: gitRef, Path: repoPath, IncludeLatestCommit: includeLatestCommit, @@ -141,13 +144,13 @@ func (c *Controller) GetContent(ctx context.Context, session *auth.Session, repo switch info.Type { case ContentTypeDir: // for getContent we don't want any recursiveness for dir content. - content, err = c.getDirContent(ctx, repo.GitUID, gitRef, repoPath, includeLatestCommit, false) + content, err = c.getDirContent(ctx, readParams, gitRef, repoPath, includeLatestCommit, false) case ContentTypeFile: - content, err = c.getFileContent(ctx, repo.GitUID, info.SHA) + content, err = c.getFileContent(ctx, readParams, info.SHA) case ContentTypeSymlink: - content, err = c.getSymlinkContent(ctx, repo.GitUID, info.SHA) + content, err = c.getSymlinkContent(ctx, readParams, info.SHA) case ContentTypeSubmodule: - content, err = c.getSubmoduleContent(ctx, repo.GitUID, gitRef, repoPath, info.SHA) + content, err = c.getSubmoduleContent(ctx, readParams, gitRef, repoPath, info.SHA) default: err = fmt.Errorf("unknown tree node type '%s'", treeNodeOutput.Node.Type) } @@ -162,12 +165,12 @@ func (c *Controller) GetContent(ctx context.Context, session *auth.Session, repo }, nil } -func (c *Controller) getSubmoduleContent(ctx context.Context, gitRepoUID string, gitRef string, +func (c *Controller) getSubmoduleContent(ctx context.Context, readParams gitrpc.ReadParams, gitRef string, repoPath string, commitSHA string) (*SubmoduleContent, error) { output, err := c.gitRPCClient.GetSubmodule(ctx, &gitrpc.GetSubmoduleParams{ - RepoUID: gitRepoUID, - GitREF: gitRef, - Path: repoPath, + ReadParams: readParams, + GitREF: gitRef, + Path: repoPath, }) if err != nil { // TODO: handle not found error @@ -181,11 +184,12 @@ func (c *Controller) getSubmoduleContent(ctx context.Context, gitRepoUID string, }, nil } -func (c *Controller) getFileContent(ctx context.Context, gitRepoUID string, blobSHA string) (*FileContent, error) { +func (c *Controller) getFileContent(ctx context.Context, readParams gitrpc.ReadParams, + blobSHA string) (*FileContent, error) { output, err := c.gitRPCClient.GetBlob(ctx, &gitrpc.GetBlobParams{ - RepoUID: gitRepoUID, - SHA: blobSHA, - SizeLimit: maxGetContentFileSize, + ReadParams: readParams, + SHA: blobSHA, + SizeLimit: maxGetContentFileSize, }) if err != nil { // TODO: handle not found error @@ -200,12 +204,12 @@ func (c *Controller) getFileContent(ctx context.Context, gitRepoUID string, blob }, nil } -func (c *Controller) getSymlinkContent(ctx context.Context, gitRepoUID string, +func (c *Controller) getSymlinkContent(ctx context.Context, readParams gitrpc.ReadParams, blobSHA string) (*SymlinkContent, error) { output, err := c.gitRPCClient.GetBlob(ctx, &gitrpc.GetBlobParams{ - RepoUID: gitRepoUID, - SHA: blobSHA, - SizeLimit: maxGetContentFileSize, + ReadParams: readParams, + SHA: blobSHA, + SizeLimit: maxGetContentFileSize, }) if err != nil { // TODO: handle not found error @@ -219,10 +223,10 @@ func (c *Controller) getSymlinkContent(ctx context.Context, gitRepoUID string, }, nil } -func (c *Controller) getDirContent(ctx context.Context, gitRepoUID string, gitRef string, +func (c *Controller) getDirContent(ctx context.Context, readParams gitrpc.ReadParams, gitRef string, repoPath string, includeLatestCommit bool, recursive bool) (*DirContent, error) { output, err := c.gitRPCClient.ListTreeNodes(ctx, &gitrpc.ListTreeNodeParams{ - RepoUID: gitRepoUID, + ReadParams: readParams, GitREF: gitRef, Path: repoPath, IncludeLatestCommit: includeLatestCommit, diff --git a/internal/api/controller/repo/list_branches.go b/internal/api/controller/repo/list_branches.go index bfe5d0836..1c426d87d 100644 --- a/internal/api/controller/repo/list_branches.go +++ b/internal/api/controller/repo/list_branches.go @@ -36,7 +36,7 @@ func (c *Controller) ListBranches(ctx context.Context, session *auth.Session, } rpcOut, err := c.gitRPCClient.ListBranches(ctx, &gitrpc.ListBranchesParams{ - RepoUID: repo.GitUID, + ReadParams: CreateRPCReadParams(repo), IncludeCommit: includeCommit, Query: filter.Query, Sort: mapToRPCBranchSortOption(filter.Sort), diff --git a/internal/api/controller/repo/list_commit_tags.go b/internal/api/controller/repo/list_commit_tags.go index e2ae96f79..2bd1c3ed1 100644 --- a/internal/api/controller/repo/list_commit_tags.go +++ b/internal/api/controller/repo/list_commit_tags.go @@ -40,7 +40,7 @@ func (c *Controller) ListCommitTags(ctx context.Context, session *auth.Session, } rpcOut, err := c.gitRPCClient.ListCommitTags(ctx, &gitrpc.ListCommitTagsParams{ - RepoUID: repo.GitUID, + ReadParams: CreateRPCReadParams(repo), IncludeCommit: includeCommit, Query: filter.Query, Sort: mapToRPCTagSortOption(filter.Sort), diff --git a/internal/api/controller/repo/list_commits.go b/internal/api/controller/repo/list_commits.go index 71e308244..32eae5cce 100644 --- a/internal/api/controller/repo/list_commits.go +++ b/internal/api/controller/repo/list_commits.go @@ -35,11 +35,11 @@ func (c *Controller) ListCommits(ctx context.Context, session *auth.Session, } rpcOut, err := c.gitRPCClient.ListCommits(ctx, &gitrpc.ListCommitsParams{ - RepoUID: repo.GitUID, - GitREF: gitRef, - After: filter.After, - Page: int32(filter.Page), - Limit: int32(filter.Limit), + ReadParams: CreateRPCReadParams(repo), + GitREF: gitRef, + After: filter.After, + Page: int32(filter.Page), + Limit: int32(filter.Limit), }) if err != nil { return nil, err diff --git a/internal/api/handler/repo/http_git.go b/internal/api/handler/repo/http_git.go index 1996f649b..7efbed4f6 100644 --- a/internal/api/handler/repo/http_git.go +++ b/internal/api/handler/repo/http_git.go @@ -13,6 +13,7 @@ import ( "github.com/harness/gitness/gitrpc" apiauth "github.com/harness/gitness/internal/api/auth" + repoctrl "github.com/harness/gitness/internal/api/controller/repo" "github.com/harness/gitness/internal/api/request" "github.com/harness/gitness/internal/api/usererror" "github.com/harness/gitness/internal/auth/authz" @@ -74,7 +75,7 @@ func GetInfoRefs(client gitrpc.Interface, repoStore store.RepoStore, authorizer w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-advertisement", service)) if err = client.GetInfoRefs(ctx, w, &gitrpc.InfoRefsParams{ - RepoUID: repo.GitUID, + ReadParams: repoctrl.CreateRPCReadParams(repo), Service: service, Options: nil, GitProtocol: r.Header.Get("Git-Protocol"), @@ -91,7 +92,8 @@ func GetUploadPack(client gitrpc.Interface, repoStore store.RepoStore, authorize return func(w http.ResponseWriter, r *http.Request) { const service = "upload-pack" - if err := serviceRPC(w, r, client, repoStore, authorizer, service, enum.PermissionRepoView, true); err != nil { + if err := serviceRPC(w, r, client, repoStore, authorizer, service, false, + enum.PermissionRepoView, true); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -101,7 +103,8 @@ func GetUploadPack(client gitrpc.Interface, repoStore store.RepoStore, authorize func PostReceivePack(client gitrpc.Interface, repoStore store.RepoStore, authorizer authz.Authorizer) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { const service = "receive-pack" - if err := serviceRPC(w, r, client, repoStore, authorizer, service, enum.PermissionRepoEdit, false); err != nil { + if err := serviceRPC(w, r, client, repoStore, authorizer, service, true, + enum.PermissionRepoEdit, false); err != nil { var authError *GitAuthError if errors.As(err, &authError) { basicAuth(w, authError.AccountID) @@ -120,6 +123,7 @@ func serviceRPC( repoStore store.RepoStore, authorizer authz.Authorizer, service string, + isWriteOperation bool, permission enum.Permission, orPublic bool, ) error { @@ -168,15 +172,21 @@ func serviceRPC( } } params := &gitrpc.ServicePackParams{ - RepoUID: repo.GitUID, Service: service, Data: reqBody, Options: nil, GitProtocol: r.Header.Get("Git-Protocol"), } - if session != nil { - params.PrincipalID = session.Principal.ID + + // setup read/writeparams depending on whether it's a write operation + if isWriteOperation { + writeParams := repoctrl.CreateRPCWriteParams(session, repo) + params.WriteParams = &writeParams + } else { + readParams := repoctrl.CreateRPCReadParams(repo) + params.ReadParams = &readParams } + return client.ServicePack(ctx, w, params) } diff --git a/internal/api/middleware/accesslog/accesslog.go b/internal/api/middleware/accesslog/accesslog.go deleted file mode 100644 index 00f809ea9..000000000 --- a/internal/api/middleware/accesslog/accesslog.go +++ /dev/null @@ -1,27 +0,0 @@ -// 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 accesslog - -import ( - "net/http" - "time" - - "github.com/rs/zerolog/hlog" -) - -/* - * A simple middleware that logs completed requests using the default hlog access handler. - */ -func HlogHandler() func(http.Handler) http.Handler { - return hlog.AccessHandler( - func(r *http.Request, status, size int, duration time.Duration) { - hlog.FromRequest(r).Info(). - Int("http.status_code", status). - Int("http.response_size_bytes", size). - Dur("http.elapsed_ms", duration). - Msg("request completed.") - }, - ) -} diff --git a/internal/api/middleware/logging/logging.go b/internal/api/middleware/logging/logging.go new file mode 100644 index 000000000..820f19843 --- /dev/null +++ b/internal/api/middleware/logging/logging.go @@ -0,0 +1,69 @@ +// 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 logging + +import ( + "net/http" + "time" + + "github.com/harness/gitness/gitrpc" + "github.com/harness/gitness/internal/api/request" + + "github.com/rs/xid" + "github.com/rs/zerolog" + "github.com/rs/zerolog/hlog" +) + +const ( + requestIDHeader = "X-Request-Id" +) + +// HLogRequestIDHandler provides a middleware that injects request_id into the logging and execution context. +// It prefers the X-Request-Id header, if that doesn't exist it creates a new request id similar to zerolog. +func HLogRequestIDHandler() func(http.Handler) http.Handler { + return func(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + // read requestID from header (or create new one if none exists) + var reqID string + if reqIDs, ok := r.Header[requestIDHeader]; ok && len(reqIDs) > 0 && len(reqIDs[0]) > 0 { + reqID = reqIDs[0] + } else { + // similar to zerolog requestID generation + reqID = xid.New().String() + } + + // add requestID to context for internal usage + gitrpc client! + ctx = request.WithRequestID(ctx, reqID) + ctx = gitrpc.WithRequestID(ctx, reqID) + + // update logging context with request ID + log := zerolog.Ctx(ctx) + log.UpdateContext(func(c zerolog.Context) zerolog.Context { + return c.Str("http.request_id", reqID) + }) + + // write request ID to response headers + w.Header().Set(requestIDHeader, reqID) + + // continue serving request + h.ServeHTTP(w, r.WithContext(ctx)) + }) + } +} + +// HLogAccessLogHandler provides an hlog based middleware that logs access logs. +func HLogAccessLogHandler() func(http.Handler) http.Handler { + return hlog.AccessHandler( + func(r *http.Request, status, size int, duration time.Duration) { + hlog.FromRequest(r).Info(). + Int("http.status_code", status). + Int("http.response_size_bytes", size). + Dur("http.elapsed_ms", duration). + Msg("http request completed.") + }, + ) +} diff --git a/internal/api/request/context.go b/internal/api/request/context.go index 3bfabfb5d..2641e119f 100644 --- a/internal/api/request/context.go +++ b/internal/api/request/context.go @@ -22,6 +22,7 @@ const ( userKey spaceKey repoKey + requestIDKey ) // WithAuthSession returns a copy of parent in which the principal @@ -94,3 +95,17 @@ func RepoFrom(ctx context.Context) (*types.Repository, bool) { v, ok := ctx.Value(repoKey).(*types.Repository) return v, ok && v != nil } + +// WithRequestID returns a copy of parent in which the request id value is set. +func WithRequestID(parent context.Context, v string) context.Context { + return context.WithValue(parent, requestIDKey, v) +} + +// RequestIDFrom returns the value of the request ID key on the +// context - ok is true iff a non-empty value existed. +// +//nolint:revive // need to emphasize that it's the request id we are retrieving. +func RequestIDFrom(ctx context.Context) (string, bool) { + v, ok := ctx.Value(requestIDKey).(string) + return v, ok && v != "" +} diff --git a/internal/auth/authz/unsafe.go b/internal/auth/authz/unsafe.go index 9bc8f380e..ad3861728 100644 --- a/internal/auth/authz/unsafe.go +++ b/internal/auth/authz/unsafe.go @@ -27,7 +27,7 @@ func NewUnsafeAuthorizer() *UnsafeAuthorizer { func (a *UnsafeAuthorizer) Check(ctx context.Context, session *auth.Session, scope *types.Scope, resource *types.Resource, permission enum.Permission) (bool, error) { - log.Info().Msgf( + log.Ctx(ctx).Info().Msgf( "[Authz] %s with id '%d' requests %s for %s '%s' in scope %#v with metadata %#v", session.Principal.Type, session.Principal.ID, diff --git a/internal/router/api.go b/internal/router/api.go index 719439de7..b15b3ff91 100644 --- a/internal/router/api.go +++ b/internal/router/api.go @@ -23,9 +23,9 @@ import ( "github.com/harness/gitness/internal/api/handler/system" handleruser "github.com/harness/gitness/internal/api/handler/user" handlerwebhook "github.com/harness/gitness/internal/api/handler/webhook" - "github.com/harness/gitness/internal/api/middleware/accesslog" middlewareauthn "github.com/harness/gitness/internal/api/middleware/authn" "github.com/harness/gitness/internal/api/middleware/encode" + "github.com/harness/gitness/internal/api/middleware/logging" "github.com/harness/gitness/internal/api/middleware/principal" "github.com/harness/gitness/internal/api/request" "github.com/harness/gitness/internal/auth/authn" @@ -68,8 +68,8 @@ func NewAPIHandler( // configure logging middleware. r.Use(hlog.URLHandler("http.url")) r.Use(hlog.MethodHandler("http.method")) - r.Use(hlog.RequestIDHandler("http.request", config.Server.HTTP.RequestIDResponseHeader)) - r.Use(accesslog.HlogHandler()) + r.Use(logging.HLogRequestIDHandler()) + r.Use(logging.HLogAccessLogHandler()) // configure cors middleware r.Use(corsHandler(config)) diff --git a/internal/router/git.go b/internal/router/git.go index 16b42baba..6dca8a973 100644 --- a/internal/router/git.go +++ b/internal/router/git.go @@ -10,9 +10,9 @@ import ( "github.com/harness/gitness/gitrpc" handlerrepo "github.com/harness/gitness/internal/api/handler/repo" - "github.com/harness/gitness/internal/api/middleware/accesslog" middlewareauthn "github.com/harness/gitness/internal/api/middleware/authn" "github.com/harness/gitness/internal/api/middleware/encode" + "github.com/harness/gitness/internal/api/middleware/logging" "github.com/harness/gitness/internal/api/request" "github.com/harness/gitness/internal/auth/authn" "github.com/harness/gitness/internal/auth/authz" @@ -47,8 +47,8 @@ func NewGitHandler( // configure logging middleware. r.Use(hlog.URLHandler("http.url")) r.Use(hlog.MethodHandler("http.method")) - r.Use(hlog.RequestIDHandler("http.request", config.Server.HTTP.RequestIDResponseHeader)) - r.Use(accesslog.HlogHandler()) + r.Use(logging.HLogRequestIDHandler()) + r.Use(logging.HLogAccessLogHandler()) r.Route(fmt.Sprintf("/{%s}", request.PathParamRepoRef), func(r chi.Router) { r.Use(middlewareauthn.Attempt(authenticator)) diff --git a/internal/webhook/branch.go b/internal/webhook/branch.go index 6e2783989..a201b7e8d 100644 --- a/internal/webhook/branch.go +++ b/internal/webhook/branch.go @@ -14,8 +14,6 @@ import ( "github.com/harness/gitness/types/enum" ) -const NilSHA = "0000000000000000000000000000000000000000" - // BranchBody describes the body of Branch related webhook triggers. // TODO: move in separate package for small import? type BranchBody struct { @@ -40,7 +38,7 @@ func getEventHandlerForBranchCreated(server *Server, GitURL: "", // TODO: GitURL has to be generated }, Ref: event.Payload.FullRef, - Before: NilSHA, + Before: types.NilSHA, After: event.Payload.SHA, } }) @@ -84,7 +82,7 @@ func getEventHandlerForBranchDeleted(server *Server, }, Ref: event.Payload.FullRef, Before: event.Payload.SHA, - After: NilSHA, + After: types.NilSHA, } }) } diff --git a/types/config.go b/types/config.go index b71b34d7a..81bec6f3e 100644 --- a/types/config.go +++ b/types/config.go @@ -18,20 +18,20 @@ type Config struct { // Git defines the git configuration parameters Git struct { - BaseURL string `envconfig:"GITNESS_GIT_BASE_URL" default:"http://localhost:3000"` // clone url - Root string `envconfig:"GITNESS_GIT_ROOT"` - ReposTempPath string `envconfig:"GITNESS_GIT_REPOS_TEMP_PATH"` // temp path where all repos will be cloned - DefaultBranch string `envconfig:"GITNESS_GIT_DEFAULTBRANCH" default:"main"` + BaseURL string `envconfig:"GITNESS_GIT_BASE_URL" default:"http://localhost:3000"` // clone url + Root string `envconfig:"GITNESS_GIT_ROOT"` + TmpDir string `envconfig:"GITNESS_GIT_TMP_DIR"` // directory for temporary data (repo clone) + ServerHookPath string `envconfig:"GITNESS_GIT_SERVER_HOOK_PATH"` // path to binary used as git server hook + DefaultBranch string `envconfig:"GITNESS_GIT_DEFAULTBRANCH" default:"main"` } // Server defines the server configuration parameters. Server struct { // HTTP defines the http configuration parameters HTTP struct { - Bind string `envconfig:"GITNESS_HTTP_BIND" default:":3000"` - Proto string `envconfig:"GITNESS_HTTP_PROTO"` - Host string `envconfig:"GITNESS_HTTP_HOST"` - RequestIDResponseHeader string `envconfig:"GITNESS_HTTP_REQUEST_ID_RESPONSE_HEADER" default:"request-id"` + Bind string `envconfig:"GITNESS_HTTP_BIND" default:":3000"` + Proto string `envconfig:"GITNESS_HTTP_PROTO"` + Host string `envconfig:"GITNESS_HTTP_HOST"` } // GRPC defines the grpc configuration parameters diff --git a/types/git.go b/types/git.go index 80a3605cc..8115d06fa 100644 --- a/types/git.go +++ b/types/git.go @@ -6,6 +6,8 @@ package types import "github.com/harness/gitness/types/enum" +const NilSHA = "0000000000000000000000000000000000000000" + // CommitFilter stores commit query parameters. type CommitFilter struct { After string `json:"after"`