From c55c53deabd58b43da5c6ae29e6613a3e58799e8 Mon Sep 17 00:00:00 2001 From: Johannes Batzill Date: Thu, 10 Nov 2022 20:57:31 -0800 Subject: [PATCH] [API] Add Create + Delete Branch API (+ Basic GIT Error Propagation) (#70) This change adds the following: - create / delete branch - basic error propagation from git to user (notfound, conflict, invalidinput) - create repo root folder in server instead of service constructor --- gitrpc/blob.go | 2 +- gitrpc/branch.go | 66 +- gitrpc/client.go | 2 + gitrpc/commit.go | 4 +- gitrpc/{error.go => errors.go} | 3 + gitrpc/interface.go | 2 + gitrpc/internal/gitea/blob.go | 4 +- gitrpc/internal/gitea/branch.go | 75 ++ gitrpc/internal/gitea/commit.go | 16 +- gitrpc/internal/gitea/mapping.go | 48 +- gitrpc/internal/gitea/ref.go | 2 +- gitrpc/internal/gitea/repo.go | 30 +- gitrpc/internal/gitea/submodule.go | 5 +- gitrpc/internal/gitea/tag.go | 9 +- gitrpc/internal/gitea/tree.go | 13 +- gitrpc/internal/service/blob.go | 4 +- gitrpc/internal/service/branch.go | 42 +- gitrpc/internal/service/commit.go | 6 +- gitrpc/internal/service/http.go | 25 +- gitrpc/internal/service/interface.go | 2 + gitrpc/internal/service/mapping.go | 48 +- gitrpc/internal/service/path.go | 22 + gitrpc/internal/service/ref.go | 14 + gitrpc/internal/service/repo.go | 33 +- gitrpc/internal/service/submodule.go | 4 +- gitrpc/internal/service/tag.go | 14 +- gitrpc/internal/service/tree.go | 10 +- gitrpc/internal/service/upload.go | 6 +- gitrpc/{ref.go => internal/types/errors.go} | 10 +- gitrpc/internal/types/types.go | 8 +- gitrpc/mapping.go | 30 + gitrpc/proto/ref.proto | 88 ++ gitrpc/proto/repo.proto | 78 +- gitrpc/proto/shared.proto | 20 +- gitrpc/repo.go | 2 +- gitrpc/rpc/ref.pb.go | 1090 +++++++++++++++ gitrpc/rpc/ref_grpc.pb.go | 268 ++++ gitrpc/rpc/repo.pb.go | 1190 ++--------------- gitrpc/rpc/repo_grpc.pb.go | 126 -- gitrpc/rpc/shared.pb.go | 277 +++- gitrpc/server/server.go | 26 +- gitrpc/smarthttp.go | 2 +- gitrpc/submodule.go | 2 +- gitrpc/tag.go | 5 +- gitrpc/tree.go | 4 +- internal/api/controller/repo/create_branch.go | 79 ++ internal/api/controller/repo/delete_branch.go | 47 + internal/api/controller/repo/get_content.go | 9 +- internal/api/handler/repo/create_branch.go | 44 + internal/api/handler/repo/delete_branch.go | 40 + internal/api/render/render.go | 1 + internal/api/request/util.go | 5 + internal/api/usererror/translate.go | 9 + internal/api/usererror/usererror.go | 5 +- internal/router/api.go | 2 + internal/store/database/util.go | 19 +- types/check/common.go | 21 +- 57 files changed, 2579 insertions(+), 1439 deletions(-) rename gitrpc/{error.go => errors.go} (65%) create mode 100644 gitrpc/internal/gitea/branch.go create mode 100644 gitrpc/internal/service/path.go rename gitrpc/{ref.go => internal/types/errors.go} (50%) create mode 100644 gitrpc/proto/ref.proto create mode 100644 gitrpc/rpc/ref.pb.go create mode 100644 gitrpc/rpc/ref_grpc.pb.go create mode 100644 internal/api/controller/repo/create_branch.go create mode 100644 internal/api/controller/repo/delete_branch.go create mode 100644 internal/api/handler/repo/create_branch.go create mode 100644 internal/api/handler/repo/delete_branch.go diff --git a/gitrpc/blob.go b/gitrpc/blob.go index cc4c70bb3..f9716e683 100644 --- a/gitrpc/blob.go +++ b/gitrpc/blob.go @@ -39,7 +39,7 @@ func (c *Client) GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobOu SizeLimit: params.SizeLimit, }) if err != nil { - return nil, err + return nil, processRPCErrorf(err, "failed to get blob from server") } blob := resp.GetBlob() diff --git a/gitrpc/branch.go b/gitrpc/branch.go index 3e4d421fa..2ca3bbe69 100644 --- a/gitrpc/branch.go +++ b/gitrpc/branch.go @@ -22,6 +22,26 @@ const ( BranchSortOptionDate ) +type CreateBranchParams struct { + // RepoUID is the uid of the git repository + RepoUID string + // BranchName is the name of the branch + BranchName string + // Target is a git reference (branch / tag / commit SHA) + Target string +} + +type CreateBranchOutput struct { + Branch Branch +} + +type DeleteBranchParams struct { + // RepoUID is the uid of the git repository + RepoUID string + // Name is the name of the branch + BranchName string +} + type ListBranchesParams struct { // RepoUID is the uid of the git repository RepoUID string @@ -43,12 +63,54 @@ type Branch struct { Commit *Commit } +func (c *Client) CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error) { + if params == nil { + return nil, ErrNoParamsProvided + } + resp, err := c.refService.CreateBranch(ctx, &rpc.CreateBranchRequest{ + RepoUid: params.RepoUID, + Target: params.Target, + BranchName: params.BranchName, + }) + if err != nil { + return nil, processRPCErrorf(err, "failed to create branch on server") + } + + var branch *Branch + branch, err = mapRPCBranch(resp.GetBranch()) + if err != nil { + return nil, fmt.Errorf("failed to map rpc branch: %w", err) + } + + return &CreateBranchOutput{ + Branch: *branch, + }, nil +} + +func (c *Client) DeleteBranch(ctx context.Context, params *DeleteBranchParams) error { + if params == nil { + return ErrNoParamsProvided + } + _, err := c.refService.DeleteBranch(ctx, &rpc.DeleteBranchRequest{ + RepoUid: params.RepoUID, + 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. + Force: true, + }) + if err != nil { + return processRPCErrorf(err, "failed to delete branch on server") + } + + return nil +} + func (c *Client) ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error) { if params == nil { return nil, ErrNoParamsProvided } - stream, err := c.repoService.ListBranches(ctx, &rpc.ListBranchesRequest{ + stream, err := c.refService.ListBranches(ctx, &rpc.ListBranchesRequest{ RepoUid: params.RepoUID, IncludeCommit: params.IncludeCommit, Query: params.Query, @@ -73,7 +135,7 @@ func (c *Client) ListBranches(ctx context.Context, params *ListBranchesParams) ( break } if err != nil { - return nil, fmt.Errorf("received unexpected error from rpc: %w", err) + return nil, processRPCErrorf(err, "received unexpected error from rpc") } if next.GetBranch() == nil { return nil, fmt.Errorf("expected branch message") diff --git a/gitrpc/client.go b/gitrpc/client.go index d60044ff2..0657dcd83 100644 --- a/gitrpc/client.go +++ b/gitrpc/client.go @@ -18,6 +18,7 @@ type Config struct { type Client struct { conn *grpc.ClientConn repoService rpc.RepositoryServiceClient + refService rpc.ReferenceServiceClient httpService rpc.SmartHTTPServiceClient } @@ -30,6 +31,7 @@ func New(remoteAddr string) (*Client, error) { return &Client{ conn: conn, repoService: rpc.NewRepositoryServiceClient(conn), + refService: rpc.NewReferenceServiceClient(conn), httpService: rpc.NewSmartHTTPServiceClient(conn), }, nil } diff --git a/gitrpc/commit.go b/gitrpc/commit.go index 0bc055cd0..b882909b8 100644 --- a/gitrpc/commit.go +++ b/gitrpc/commit.go @@ -64,7 +64,7 @@ func (c *Client) ListCommits(ctx context.Context, params *ListCommitsParams) (*L // get header first header, err := stream.Recv() if err != nil { - return nil, fmt.Errorf("error occured while receiving header: %w", err) + return nil, processRPCErrorf(err, "error occured while receiving header") } if header.GetHeader() == nil { return nil, fmt.Errorf("header missing") @@ -84,7 +84,7 @@ func (c *Client) ListCommits(ctx context.Context, params *ListCommitsParams) (*L break } if err != nil { - return nil, fmt.Errorf("received unexpected error from rpc: %w", err) + return nil, processRPCErrorf(err, "received unexpected error from server") } if next.GetCommit() == nil { return nil, fmt.Errorf("expected commit message") diff --git a/gitrpc/error.go b/gitrpc/errors.go similarity index 65% rename from gitrpc/error.go rename to gitrpc/errors.go index eb0f53750..39e7897d5 100644 --- a/gitrpc/error.go +++ b/gitrpc/errors.go @@ -7,3 +7,6 @@ package gitrpc import "errors" var ErrNoParamsProvided = errors.New("no params provided") +var ErrAlreadyExists = errors.New("already exists") +var ErrInvalidArgument = errors.New("invalid argument") +var ErrNotFound = errors.New("not found") diff --git a/gitrpc/interface.go b/gitrpc/interface.go index bcdf7df20..3500d62f5 100644 --- a/gitrpc/interface.go +++ b/gitrpc/interface.go @@ -16,6 +16,8 @@ type Interface interface { GetSubmodule(ctx context.Context, params *GetSubmoduleParams) (*GetSubmoduleOutput, error) GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobOutput, error) ListCommits(ctx context.Context, params *ListCommitsParams) (*ListCommitsOutput, error) + CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error) + DeleteBranch(ctx context.Context, params *DeleteBranchParams) error ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error) ListCommitTags(ctx context.Context, params *ListCommitTagsParams) (*ListCommitTagsOutput, error) diff --git a/gitrpc/internal/gitea/blob.go b/gitrpc/internal/gitea/blob.go index 39066269b..f09a0b9c3 100644 --- a/gitrpc/internal/gitea/blob.go +++ b/gitrpc/internal/gitea/blob.go @@ -24,12 +24,12 @@ func (g Adapter) GetBlob(ctx context.Context, repoPath string, sha string, sizeL giteaBlob, err := giteaRepo.GetBlob(sha) if err != nil { - return nil, fmt.Errorf("error getting blob '%s': %w", sha, err) + return nil, processGiteaErrorf(err, "error getting blob '%s'", sha) } reader, err := giteaBlob.DataAsync() if err != nil { - return nil, fmt.Errorf("error opening data for blob '%s': %w", sha, err) + return nil, processGiteaErrorf(err, "error opening data for blob '%s'", sha) } returnSize := giteaBlob.Size() diff --git a/gitrpc/internal/gitea/branch.go b/gitrpc/internal/gitea/branch.go new file mode 100644 index 000000000..43bbe2de9 --- /dev/null +++ b/gitrpc/internal/gitea/branch.go @@ -0,0 +1,75 @@ +// 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 gitea + +import ( + "context" + "fmt" + "strings" + + gitea "code.gitea.io/gitea/modules/git" + "github.com/harness/gitness/gitrpc/internal/types" +) + +// CreateBranch creates a new branch. +// Note: target is the commit (or points to the commit) the branch will be pointing to. +func (g Adapter) CreateBranch(ctx context.Context, repoPath string, + branchName string, target string) (*types.Branch, error) { + giteaRepo, err := gitea.OpenRepository(ctx, repoPath) + if err != nil { + return nil, err + } + defer giteaRepo.Close() + + // Get the commit object for the ref + giteaCommit, err := giteaRepo.GetCommit(target) + if err != nil { + return nil, processGiteaErrorf(err, "error getting commit for ref '%s'", target) + } + + // In case of target being an annotated tag, gitea is overwriting the commit message with the tag message. + // Reload the commit explicitly in case it's a tag (independent of whether it's annotated or not to simplify code) + // NOTE: we also allow passing refs/tags/tagName or tags/tagName, which is not covered by IsTagExist. + // Worst case we have a false positive and reload the same commit, we don't want false negatives though! + if strings.HasPrefix(target, gitea.TagPrefix) || strings.HasPrefix(target, "tags") || giteaRepo.IsTagExist(target) { + giteaCommit, err = giteaRepo.GetCommit(giteaCommit.ID.String()) + if err != nil { + return nil, processGiteaErrorf(err, "error getting commit for annotated tag '%s' (commitId '%s')", + target, giteaCommit.ID.String()) + } + } + + err = giteaRepo.CreateBranch(branchName, giteaCommit.ID.String()) + if err != nil { + return nil, processGiteaErrorf(err, "failed to create branch '%s'", branchName) + } + + commit, err := mapGiteaCommit(giteaCommit) + if err != nil { + return nil, fmt.Errorf("failed to map gitea commit: %w", err) + } + + return &types.Branch{ + Name: branchName, + 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) error { + giteaRepo, err := gitea.OpenRepository(ctx, repoPath) + if err != nil { + return err + } + defer giteaRepo.Close() + + err = giteaRepo.DeleteBranch(branchName, gitea.DeleteBranchOptions{Force: force}) + if err != nil { + return processGiteaErrorf(err, "failed to delete branch '%s'", branchName) + } + + return nil +} diff --git a/gitrpc/internal/gitea/commit.go b/gitrpc/internal/gitea/commit.go index 6ba3c52c2..365344752 100644 --- a/gitrpc/internal/gitea/commit.go +++ b/gitrpc/internal/gitea/commit.go @@ -31,7 +31,7 @@ func (g Adapter) GetLatestCommit(ctx context.Context, repoPath string, giteaCommit, err := giteaGetCommitByPath(giteaRepo, ref, treePath) if err != nil { - return nil, fmt.Errorf("error getting latest commit for '%s': %w", treePath, err) + return nil, processGiteaErrorf(err, "error getting latest commit for '%s'", treePath) } return mapGiteaCommit(giteaCommit) @@ -47,7 +47,7 @@ func giteaGetCommitByPath(giteaRepo *gitea.Repository, ref string, treePath stri stdout, _, runErr := gitea.NewCommand(giteaRepo.Ctx, "log", ref, "-1", giteaPrettyLogFormat, "--", treePath). RunStdBytes(&gitea.RunOpts{Dir: giteaRepo.Path}) if runErr != nil { - return nil, runErr + return nil, fmt.Errorf("failed to trigger log command: %w", runErr) } giteaCommits, err := giteaParsePrettyFormatLogToList(giteaRepo, stdout) @@ -70,7 +70,7 @@ func giteaParsePrettyFormatLogToList(giteaRepo *gitea.Repository, logs []byte) ( for _, commitID := range parts { commit, err := giteaRepo.GetCommit(string(commitID)) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to get commit '%s': %w", string(commitID), err) } giteaCommits = append(giteaCommits, commit) } @@ -91,17 +91,17 @@ func (g Adapter) ListCommits(ctx context.Context, repoPath string, // Get the giteaTopCommit object for the ref giteaTopCommit, err := giteaRepo.GetCommit(ref) if err != nil { - return nil, 0, fmt.Errorf("error getting commit for ref '%s': %w", ref, err) + return nil, 0, processGiteaErrorf(err, "error getting commit top commit for ref '%s'", ref) } giteaCommits, err := giteaTopCommit.CommitsByRange(page, pageSize) if err != nil { - return nil, 0, fmt.Errorf("error getting commits: %w", err) + return nil, 0, processGiteaErrorf(err, "error getting commits") } totalCount, err := giteaTopCommit.CommitsCount() if err != nil { - return nil, 0, fmt.Errorf("error getting total commit count: %w", err) + return nil, 0, processGiteaErrorf(err, "error getting total commit count") } commits := make([]types.Commit, len(giteaCommits)) @@ -129,7 +129,7 @@ func (g Adapter) GetCommit(ctx context.Context, repoPath string, ref string) (*t commit, err := giteaRepo.GetCommit(ref) if err != nil { - return nil, err + return nil, processGiteaErrorf(err, "error getting commit for ref '%s'", ref) } return mapGiteaCommit(commit) @@ -149,7 +149,7 @@ func (g Adapter) GetCommits(ctx context.Context, repoPath string, refs []string) var giteaCommit *gitea.Commit giteaCommit, err = giteaRepo.GetCommit(sha) if err != nil { - return nil, err + return nil, processGiteaErrorf(err, "error getting commit '%s'", sha) } var commit *types.Commit diff --git a/gitrpc/internal/gitea/mapping.go b/gitrpc/internal/gitea/mapping.go index 5b2f0bfcd..fb2f7d33f 100644 --- a/gitrpc/internal/gitea/mapping.go +++ b/gitrpc/internal/gitea/mapping.go @@ -5,13 +5,59 @@ package gitea import ( + "errors" "fmt" "strings" gitea "code.gitea.io/gitea/modules/git" "github.com/harness/gitness/gitrpc/internal/types" + "github.com/rs/zerolog/log" ) +// Logs the error and message, returns either the provided message or a git equivalent if possible. +// Always logs the full message with error as warning. +func processGiteaErrorf(err error, format string, args ...interface{}) error { + // create fallback error returned if we can't map it + fallbackErr := fmt.Errorf(format, args...) + + // always log internal error together with message. + log.Warn().Msgf("%v: [GITEA] %v", fallbackErr, err) + + // check if it's a RunStdError error (contains raw git error) + var runStdErr gitea.RunStdError + if errors.As(err, &runStdErr) { + return mapGiteaRunStdError(runStdErr, fallbackErr) + } + + switch { + case gitea.IsErrNotExist(err): + return types.ErrNotFound + default: + return fallbackErr + } +} + +// TODO: Improve gitea error handling. +// Doubt this will work for all std errors, as git doesn't seem to have nice error codes. +func mapGiteaRunStdError(err gitea.RunStdError, fallback error) error { + switch { + // exit status 128 - fatal: A branch named 'mybranch' already exists. + // exit status 128 - fatal: cannot lock ref 'refs/heads/a': 'refs/heads/a/b' exists; cannot create 'refs/heads/a' + case err.IsExitCode(128) && strings.Contains(err.Stderr(), "exists"): + return types.ErrAlreadyExists + + // exit status 128 - fatal: 'a/bc/d/' is not a valid branch name. + case err.IsExitCode(128) && strings.Contains(err.Stderr(), "not a valid"): + return types.ErrInvalidArgument + + // exit status 1 - error: branch 'mybranch' not found. + case err.IsExitCode(1) && strings.Contains(err.Stderr(), "not found"): + return types.ErrNotFound + default: + return fallback + } +} + func mapGiteaRawRef(raw map[string]string) (map[types.GitReferenceField]string, error) { res := make(map[types.GitReferenceField]string, len(raw)) for k, v := range raw { @@ -57,7 +103,7 @@ func mapGiteaCommit(giteaCommit *gitea.Commit) (*types.Commit, error) { return nil, fmt.Errorf("failed to map gitea commiter: %w", err) } return &types.Commit{ - Sha: giteaCommit.ID.String(), + SHA: giteaCommit.ID.String(), Title: giteaCommit.Summary(), // remove potential tailing newlines from message Message: strings.TrimRight(giteaCommit.Message(), "\n"), diff --git a/gitrpc/internal/gitea/ref.go b/gitrpc/internal/gitea/ref.go index e37ef0ec1..266c1ce8d 100644 --- a/gitrpc/internal/gitea/ref.go +++ b/gitrpc/internal/gitea/ref.go @@ -119,7 +119,7 @@ func walkGiteaReferenceParser(parser *gitearef.Parser, handler types.WalkReferen } if err := parser.Err(); err != nil { - return fmt.Errorf("failed to parse output: %w", err) + return processGiteaErrorf(err, "failed to parse reference walk output") } return nil diff --git a/gitrpc/internal/gitea/repo.go b/gitrpc/internal/gitea/repo.go index e234aa481..d2ff14287 100644 --- a/gitrpc/internal/gitea/repo.go +++ b/gitrpc/internal/gitea/repo.go @@ -35,14 +35,14 @@ func (g Adapter) SetDefaultBranch(ctx context.Context, repoPath string, // change default branch err = giteaRepo.SetDefaultBranch(defaultBranch) if err != nil { - return fmt.Errorf("failed to set new default branch: %w", err) + return processGiteaErrorf(err, "failed to set new default branch") } return nil } func (g Adapter) Clone(ctx context.Context, from, to string, opts types.CloneRepoOptions) error { - return gitea.Clone(ctx, from, to, gitea.CloneRepoOptions{ + err := gitea.Clone(ctx, from, to, gitea.CloneRepoOptions{ Timeout: opts.Timeout, Mirror: opts.Mirror, Bare: opts.Bare, @@ -54,14 +54,24 @@ func (g Adapter) Clone(ctx context.Context, from, to string, opts types.CloneRep Filter: opts.Filter, SkipTLSVerify: opts.SkipTLSVerify, }) + if err != nil { + return processGiteaErrorf(err, "failed to clone repo") + } + + return nil } func (g Adapter) AddFiles(repoPath string, all bool, files ...string) error { - return gitea.AddChanges(repoPath, all, files...) + err := gitea.AddChanges(repoPath, all, files...) + if err != nil { + return processGiteaErrorf(err, "failed to add changes") + } + + return nil } func (g Adapter) Commit(repoPath string, opts types.CommitChangesOptions) error { - return gitea.CommitChanges(repoPath, gitea.CommitChangesOptions{ + err := gitea.CommitChanges(repoPath, gitea.CommitChangesOptions{ Committer: &gitea.Signature{ Name: opts.Committer.Identity.Name, Email: opts.Committer.Identity.Email, @@ -74,10 +84,15 @@ func (g Adapter) Commit(repoPath string, opts types.CommitChangesOptions) error }, Message: opts.Message, }) + if err != nil { + return processGiteaErrorf(err, "failed to commit changes") + } + + return nil } func (g Adapter) Push(ctx context.Context, repoPath string, opts types.PushOptions) error { - return gitea.Push(ctx, repoPath, gitea.PushOptions{ + err := gitea.Push(ctx, repoPath, gitea.PushOptions{ Remote: opts.Remote, Branch: opts.Branch, Force: opts.Force, @@ -85,4 +100,9 @@ func (g Adapter) Push(ctx context.Context, repoPath string, opts types.PushOptio Env: opts.Env, Timeout: opts.Timeout, }) + if err != nil { + return processGiteaErrorf(err, "failed to push changes") + } + + return nil } diff --git a/gitrpc/internal/gitea/submodule.go b/gitrpc/internal/gitea/submodule.go index d86f391da..d7e496841 100644 --- a/gitrpc/internal/gitea/submodule.go +++ b/gitrpc/internal/gitea/submodule.go @@ -6,7 +6,6 @@ package gitea import ( "context" - "fmt" gitea "code.gitea.io/gitea/modules/git" "github.com/harness/gitness/gitrpc/internal/types" @@ -27,12 +26,12 @@ func (g Adapter) GetSubmodule(ctx context.Context, repoPath string, // Get the giteaCommit object for the ref giteaCommit, err := giteaRepo.GetCommit(ref) if err != nil { - return nil, fmt.Errorf("error getting commit for ref '%s': %w", ref, err) + return nil, processGiteaErrorf(err, "error getting commit for ref '%s'", ref) } giteaSubmodule, err := giteaCommit.GetSubModule(treePath) if err != nil { - return nil, fmt.Errorf("error getting submodule '%s' from commit: %w", ref, err) + return nil, processGiteaErrorf(err, "error getting submodule '%s' from commit", treePath) } return &types.Submodule{ diff --git a/gitrpc/internal/gitea/tag.go b/gitrpc/internal/gitea/tag.go index ab3b4af1b..97940f1b9 100644 --- a/gitrpc/internal/gitea/tag.go +++ b/gitrpc/internal/gitea/tag.go @@ -31,7 +31,12 @@ func (g Adapter) GetAnnotatedTag(ctx context.Context, repoPath string, sha strin } defer giteaRepo.Close() - return giteaGetAnnotatedTag(giteaRepo, sha) + tag, err := giteaGetAnnotatedTag(giteaRepo, sha) + if err != nil { + return nil, processGiteaErrorf(err, "failed to get annotated tag with sha '%s'", sha) + } + + return tag, nil } // GetAnnotatedTags returns the tags for a specific list of tag sha. @@ -47,7 +52,7 @@ func (g Adapter) GetAnnotatedTags(ctx context.Context, repoPath string, shas []s var tag *types.Tag tag, err = giteaGetAnnotatedTag(giteaRepo, sha) if err != nil { - return nil, err + return nil, processGiteaErrorf(err, "failed to get annotated tag with sha '%s'", sha) } tags[i] = *tag diff --git a/gitrpc/internal/gitea/tree.go b/gitrpc/internal/gitea/tree.go index b6c98f839..4e96be291 100644 --- a/gitrpc/internal/gitea/tree.go +++ b/gitrpc/internal/gitea/tree.go @@ -34,13 +34,14 @@ func (g Adapter) GetTreeNode(ctx context.Context, repoPath string, // Get the giteaCommit object for the ref giteaCommit, err := giteaRepo.GetCommit(ref) if err != nil { - return nil, fmt.Errorf("error getting commit for ref '%s': %w", ref, err) + return nil, processGiteaErrorf(err, "error getting commit for ref '%s'", ref) } // TODO: handle ErrNotExist :) giteaTreeEntry, err := giteaCommit.GetTreeEntryByPath(treePath) if err != nil { - return nil, err + return nil, processGiteaErrorf(err, "failed to get tree entry for commit '%s' at path '%s'", + giteaCommit.ID.String(), treePath) } nodeType, mode, err := mapGiteaNodeToTreeNodeModeAndType(giteaTreeEntry.Mode()) @@ -83,13 +84,13 @@ func (g Adapter) ListTreeNodes(ctx context.Context, repoPath string, // Get the giteaCommit object for the ref giteaCommit, err := giteaRepo.GetCommit(ref) if err != nil { - return nil, fmt.Errorf("error getting commit for ref '%s': %w", ref, err) + return nil, processGiteaErrorf(err, "error getting commit for ref '%s'", ref) } // Get the giteaTree object for the ref giteaTree, err := giteaCommit.SubTree(treePath) if err != nil { - return nil, fmt.Errorf("error getting tree for '%s': %w", treePath, err) + return nil, processGiteaErrorf(err, "error getting tree for '%s'", treePath) } var giteaEntries gitea.Entries @@ -99,7 +100,7 @@ func (g Adapter) ListTreeNodes(ctx context.Context, repoPath string, giteaEntries, err = giteaTree.ListEntries() } if err != nil { - return nil, fmt.Errorf("failed to list entries for tree '%s': %w", treePath, err) + return nil, processGiteaErrorf(err, "failed to list entries for tree '%s'", treePath) } var latestCommits []gitea.CommitInfo @@ -107,7 +108,7 @@ func (g Adapter) ListTreeNodes(ctx context.Context, repoPath string, // TODO: can be speed up with latestCommitCache (currently nil) latestCommits, _, err = giteaEntries.GetCommitsInfo(ctx, giteaCommit, treePath, nil) if err != nil { - return nil, fmt.Errorf("failed to get latest commits for entries: %w", err) + return nil, processGiteaErrorf(err, "failed to get latest commits for entries") } if len(latestCommits) != len(giteaEntries) { diff --git a/gitrpc/internal/service/blob.go b/gitrpc/internal/service/blob.go index 45eed8848..d2417cce3 100644 --- a/gitrpc/internal/service/blob.go +++ b/gitrpc/internal/service/blob.go @@ -11,11 +11,11 @@ import ( ) func (s RepositoryService) GetBlob(ctx context.Context, request *rpc.GetBlobRequest) (*rpc.GetBlobResponse, error) { - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) // TODO: do we need to validate request for nil? gitBlob, err := s.adapter.GetBlob(ctx, repoPath, request.GetSha(), request.GetSizeLimit()) if err != nil { - return nil, err + return nil, processGitErrorf(err, "failed to get blob") } return &rpc.GetBlobResponse{ diff --git a/gitrpc/internal/service/branch.go b/gitrpc/internal/service/branch.go index 0ad0e378b..fa17ba88c 100644 --- a/gitrpc/internal/service/branch.go +++ b/gitrpc/internal/service/branch.go @@ -18,10 +18,42 @@ import ( var listBranchesRefFields = []types.GitReferenceField{types.GitReferenceFieldRefName, types.GitReferenceFieldObjectName} -func (s RepositoryService) ListBranches(request *rpc.ListBranchesRequest, - stream rpc.RepositoryService_ListBranchesServer) error { +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") + } + + branch, err := mapGitBranch(gitBranch) + if err != nil { + return nil, err + } + + return &rpc.CreateBranchResponse{ + Branch: branch, + }, nil +} + +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) + err := s.adapter.DeleteBranch(ctx, repoPath, request.GetBranchName(), request.GetForce()) + if err != nil { + return nil, processGitErrorf(err, "failed to delete branch") + } + + return &rpc.DeleteBranchResponse{}, nil +} + +func (s ReferenceService) ListBranches(request *rpc.ListBranchesRequest, + stream rpc.ReferenceService_ListBranchesServer) error { ctx := stream.Context() - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) // get all required information from git refrences branches, err := s.listBranchesLoadReferenceData(ctx, repoPath, request) @@ -63,7 +95,7 @@ func (s RepositoryService) ListBranches(request *rpc.ListBranchesRequest, return nil } -func (s RepositoryService) listBranchesLoadReferenceData(ctx context.Context, +func (s ReferenceService) listBranchesLoadReferenceData(ctx context.Context, repoPath string, request *rpc.ListBranchesRequest) ([]*rpc.Branch, error) { // TODO: can we be smarter with slice allocation branches := make([]*rpc.Branch, 0, 16) @@ -88,7 +120,7 @@ func (s RepositoryService) listBranchesLoadReferenceData(ctx context.Context, err = s.adapter.WalkReferences(ctx, repoPath, handler, opts) if err != nil { - return nil, status.Errorf(codes.Internal, "failed to get branch references: %v", err) + return nil, processGitErrorf(err, "failed to walk branch references") } log.Trace().Msgf("git adapter returned %d branches", len(branches)) diff --git a/gitrpc/internal/service/commit.go b/gitrpc/internal/service/commit.go index f9c242c75..a197fd6fd 100644 --- a/gitrpc/internal/service/commit.go +++ b/gitrpc/internal/service/commit.go @@ -15,12 +15,12 @@ import ( func (s RepositoryService) ListCommits(request *rpc.ListCommitsRequest, stream rpc.RepositoryService_ListCommitsServer) error { - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) gitCommits, totalCount, err := s.adapter.ListCommits(stream.Context(), repoPath, request.GetGitRef(), int(request.GetPage()), int(request.GetPageSize())) if err != nil { - return status.Errorf(codes.Internal, "failed to list commits: %v", err) + return processGitErrorf(err, "failed to get list of commits") } log.Trace().Msgf("git adapter returned %d commits (total: %d)", len(gitCommits), totalCount) @@ -61,7 +61,7 @@ func (s RepositoryService) getLatestCommit(ctx context.Context, repoPath string, ref string, path string) (*rpc.Commit, error) { gitCommit, err := s.adapter.GetLatestCommit(ctx, repoPath, ref, path) if err != nil { - return nil, err + return nil, processGitErrorf(err, "failed to get latest commit") } return mapGitCommit(gitCommit) diff --git a/gitrpc/internal/service/http.go b/gitrpc/internal/service/http.go index 7ded6bd7a..f5d26dc05 100644 --- a/gitrpc/internal/service/http.go +++ b/gitrpc/internal/service/http.go @@ -7,11 +7,9 @@ package service import ( "bytes" "context" - "errors" "fmt" "io" "os" - "path/filepath" "regexp" "strconv" "strings" @@ -38,30 +36,13 @@ type SmartHTTPService struct { reposRoot string } -func NewHTTPService(adapter GitAdapter, gitRoot string) (*SmartHTTPService, error) { - reposRoot := filepath.Join(gitRoot, repoSubdirName) - if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) { - if err = os.MkdirAll(reposRoot, 0o700); err != nil { - return nil, err - } - } - +func NewHTTPService(adapter GitAdapter, reposRoot string) (*SmartHTTPService, error) { return &SmartHTTPService{ adapter: adapter, reposRoot: reposRoot, }, nil } -func (s *SmartHTTPService) getFullPathForRepo(uid string) string { - // split repos into subfolders using their prefix to distribute repos accross a set of folders. - return filepath.Join( - s.reposRoot, // root folder - uid[0:2], // first subfolder - uid[2:4], // second subfolder - fmt.Sprintf("%s.%s", uid[4:], gitRepoSuffix), // remainder with .git - ) -} - func (s *SmartHTTPService) InfoRefs( r *rpc.InfoRefsRequest, stream rpc.SmartHTTPService_InfoRefsServer, @@ -72,7 +53,7 @@ func (s *SmartHTTPService) InfoRefs( environ = append(environ, "GIT_PROTOCOL="+r.GitProtocol) } - repoPath := s.getFullPathForRepo(r.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, r.GetRepoUid()) ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() @@ -120,7 +101,7 @@ func (s *SmartHTTPService) ServicePack(stream rpc.SmartHTTPService_ServicePackSe return status.Errorf(codes.InvalidArgument, "PostUploadPack(): repository UID is missing") } - repoPath := s.getFullPathForRepo(req.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, req.GetRepoUid()) stdin := streamio.NewReader(func() ([]byte, error) { resp, streamErr := stream.Recv() diff --git a/gitrpc/internal/service/interface.go b/gitrpc/internal/service/interface.go index 719cb1c79..9a0dac139 100644 --- a/gitrpc/internal/service/interface.go +++ b/gitrpc/internal/service/interface.go @@ -32,4 +32,6 @@ type GitAdapter interface { GetLatestCommit(ctx context.Context, repoPath string, ref string, treePath string) (*types.Commit, error) 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) + DeleteBranch(ctx context.Context, repoPath string, branchName string, force bool) error } diff --git a/gitrpc/internal/service/mapping.go b/gitrpc/internal/service/mapping.go index 6952792bb..e01b44c57 100644 --- a/gitrpc/internal/service/mapping.go +++ b/gitrpc/internal/service/mapping.go @@ -5,12 +5,37 @@ package service import ( + "errors" + "fmt" + "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" + "github.com/rs/zerolog/log" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) +// Logs the error and message, returns either the provided message or a rpc equivalent if possible. +// Always logs the full message with error as warning. +func processGitErrorf(err error, format string, args ...interface{}) error { + // create fallback error returned if we can't map it + message := fmt.Sprintf(format, args...) + + // always log internal error together with message. + log.Warn().Msgf("%s: [GIT] %v", message, err) + + switch { + case errors.Is(err, types.ErrNotFound): + return status.Error(codes.NotFound, message) + case errors.Is(err, types.ErrAlreadyExists): + return status.Errorf(codes.AlreadyExists, message) + case errors.Is(err, types.ErrInvalidArgument): + return status.Errorf(codes.InvalidArgument, message) + default: + return status.Errorf(codes.Unknown, message) + } +} + func mapSortOrder(s rpc.SortOrder) types.SortOrder { switch s { case rpc.SortOrder_Asc: @@ -63,13 +88,34 @@ func mapGitMode(m types.TreeNodeMode) rpc.TreeNodeMode { return rpc.TreeNodeMode(m) } +func mapGitBranch(gitBranch *types.Branch) (*rpc.Branch, error) { + if gitBranch == nil { + return nil, status.Errorf(codes.Internal, "git branch is nil") + } + + var commit *rpc.Commit + var err error + if gitBranch.Commit != nil { + commit, err = mapGitCommit(gitBranch.Commit) + if err != nil { + return nil, err + } + } + + return &rpc.Branch{ + Name: gitBranch.Name, + Sha: gitBranch.SHA, + Commit: commit, + }, nil +} + func mapGitCommit(gitCommit *types.Commit) (*rpc.Commit, error) { if gitCommit == nil { return nil, status.Errorf(codes.Internal, "git commit is nil") } return &rpc.Commit{ - Sha: gitCommit.Sha, + Sha: gitCommit.SHA, Title: gitCommit.Title, Message: gitCommit.Message, Author: mapGitSignature(gitCommit.Author), diff --git a/gitrpc/internal/service/path.go b/gitrpc/internal/service/path.go new file mode 100644 index 000000000..40d5b8428 --- /dev/null +++ b/gitrpc/internal/service/path.go @@ -0,0 +1,22 @@ +// 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 service + +import ( + "fmt" + "path/filepath" +) + +// getFullPathForRepo returns the full path of a repo given the root dir of repos and the uid of the repo. +// NOTE: Split repos into subfolders using their prefix to distribute repos accross a set of folders. +func getFullPathForRepo(reposRoot, uid string) string { + // ASSUMPTION: repoUID is of lenth at least 4 - otherwise we have trouble either way. + return filepath.Join( + reposRoot, // root folder + uid[0:2], // first subfolder + uid[2:4], // second subfolder + fmt.Sprintf("%s.%s", uid[4:], gitRepoSuffix), // remainder with .git + ) +} diff --git a/gitrpc/internal/service/ref.go b/gitrpc/internal/service/ref.go index 6d66ae8ef..3e899011e 100644 --- a/gitrpc/internal/service/ref.go +++ b/gitrpc/internal/service/ref.go @@ -10,8 +10,22 @@ import ( "strings" "github.com/harness/gitness/gitrpc/internal/types" + "github.com/harness/gitness/gitrpc/rpc" ) +type ReferenceService struct { + rpc.UnimplementedReferenceServiceServer + adapter GitAdapter + reposRoot string +} + +func NewReferenceService(adapter GitAdapter, reposRoot string) (*ReferenceService, error) { + return &ReferenceService{ + adapter: adapter, + reposRoot: reposRoot, + }, nil +} + // sanitizeReferenceQuery removes characters that aren't allowd in a branch name. // TODO: should we error out instead of ignore bad chars? func sanitizeReferenceQuery(query string) (string, bool, bool) { diff --git a/gitrpc/internal/service/repo.go b/gitrpc/internal/service/repo.go index 68bc739de..7547ec59e 100644 --- a/gitrpc/internal/service/repo.go +++ b/gitrpc/internal/service/repo.go @@ -11,7 +11,6 @@ import ( "fmt" "io" "os" - "path/filepath" "github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/rpc" @@ -21,9 +20,8 @@ import ( ) const ( - maxFileSize = 1 << 20 - repoSubdirName = "repos" - gitRepoSuffix = "git" + maxFileSize = 1 << 20 + gitRepoSuffix = "git" gitReferenceNamePrefixBranch = "refs/heads/" gitReferenceNamePrefixTag = "refs/tags/" @@ -48,14 +46,7 @@ type RepositoryService struct { reposRoot string } -func NewRepositoryService(adapter GitAdapter, store Storage, gitRoot string) (*RepositoryService, error) { - reposRoot := filepath.Join(gitRoot, repoSubdirName) - if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) { - if err = os.MkdirAll(reposRoot, 0o700); err != nil { - return nil, err - } - } - +func NewRepositoryService(adapter GitAdapter, store Storage, reposRoot string) (*RepositoryService, error) { return &RepositoryService{ adapter: adapter, store: store, @@ -63,16 +54,6 @@ func NewRepositoryService(adapter GitAdapter, store Storage, gitRoot string) (*R }, nil } -func (s RepositoryService) getFullPathForRepo(uid string) string { - // split repos into subfolders using their prefix to distribute repos accross a set of folders. - return filepath.Join( - s.reposRoot, // root folder - uid[0:2], // first subfolder - uid[2:4], // second subfolder - fmt.Sprintf("%s.%s", uid[4:], gitRepoSuffix), // remainder with .git - ) -} - //nolint:gocognit // need to refactor this code func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateRepositoryServer) error { // first get repo params from stream @@ -87,7 +68,7 @@ func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateR } log.Info().Msgf("received a create repository request %v", header) - repoPath := s.getFullPathForRepo(header.GetUid()) + repoPath := getFullPathForRepo(s.reposRoot, header.GetUid()) if _, err = os.Stat(repoPath); !os.IsNotExist(err) { return status.Errorf(codes.AlreadyExists, "repository exists already: %v", repoPath) } @@ -101,13 +82,13 @@ func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateR defer func(path string) { _ = os.RemoveAll(path) }(repoPath) - return fmt.Errorf("CreateRepository error: %w", err) + return processGitErrorf(err, "failed to initialize the repository") } // update default branch (currently set to non-existent branch) err = s.adapter.SetDefaultBranch(ctx, repoPath, header.GetDefaultBranch(), true) if err != nil { - return fmt.Errorf("error updating default branch for repo %s: %w", header.GetUid(), err) + return processGitErrorf(err, "error updating default branch for repo '%s'", header.GetUid()) } // we need temp dir for cloning @@ -125,7 +106,7 @@ func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateR // Clone repository to temp dir if err = s.adapter.Clone(ctx, repoPath, tempDir, types.CloneRepoOptions{}); err != nil { - return status.Errorf(codes.Internal, "failed to clone repo: %v", err) + return processGitErrorf(err, "failed to clone repo") } // logic for receiving files diff --git a/gitrpc/internal/service/submodule.go b/gitrpc/internal/service/submodule.go index 7e2ac62e7..dfdc1bf90 100644 --- a/gitrpc/internal/service/submodule.go +++ b/gitrpc/internal/service/submodule.go @@ -12,11 +12,11 @@ import ( func (s RepositoryService) GetSubmodule(ctx context.Context, request *rpc.GetSubmoduleRequest) (*rpc.GetSubmoduleResponse, error) { - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) // TODO: do we need to validate request for nil? gitSubmodule, err := s.adapter.GetSubmodule(ctx, repoPath, request.GetGitRef(), request.GetPath()) if err != nil { - return nil, err + return nil, processGitErrorf(err, "failed to get submodule") } return &rpc.GetSubmoduleResponse{ diff --git a/gitrpc/internal/service/tag.go b/gitrpc/internal/service/tag.go index ce68b9397..bd37b61c2 100644 --- a/gitrpc/internal/service/tag.go +++ b/gitrpc/internal/service/tag.go @@ -16,10 +16,10 @@ import ( ) //nolint:gocognit // need to refactor this code -func (s RepositoryService) ListCommitTags(request *rpc.ListCommitTagsRequest, - stream rpc.RepositoryService_ListCommitTagsServer) error { +func (s ReferenceService) ListCommitTags(request *rpc.ListCommitTagsRequest, + stream rpc.ReferenceService_ListCommitTagsServer) error { ctx := stream.Context() - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) // get all required information from git references tags, err := s.listCommitTagsLoadReferenceData(ctx, repoPath, request) @@ -43,7 +43,7 @@ func (s RepositoryService) ListCommitTags(request *rpc.ListCommitTagsRequest, var gitTags []types.Tag gitTags, err = s.adapter.GetAnnotatedTags(ctx, repoPath, annotatedTagSHAs) if err != nil { - return status.Errorf(codes.Internal, "failed to get annotated tag: %v", err) + return processGitErrorf(err, "failed to get annotated tag") } ai := 0 // since only some tags are annotated, we need second index @@ -71,7 +71,7 @@ func (s RepositoryService) ListCommitTags(request *rpc.ListCommitTagsRequest, var gitCommits []types.Commit gitCommits, err = s.adapter.GetCommits(ctx, repoPath, commitSHAs) if err != nil { - return status.Errorf(codes.Internal, "failed to get commits: %v", err) + return processGitErrorf(err, "failed to get commits") } for i := range gitCommits { @@ -118,7 +118,7 @@ var listCommitTagsRefFields = []types.GitReferenceField{types.GitReferenceFieldR types.GitReferenceFieldObjectType, types.GitReferenceFieldObjectName} var listCommitTagsObjectTypeFilter = []types.GitObjectType{types.GitObjectTypeCommit, types.GitObjectTypeTag} -func (s RepositoryService) listCommitTagsLoadReferenceData(ctx context.Context, +func (s ReferenceService) listCommitTagsLoadReferenceData(ctx context.Context, repoPath string, request *rpc.ListCommitTagsRequest) ([]*rpc.CommitTag, error) { // TODO: can we be smarter with slice allocation tags := make([]*rpc.CommitTag, 0, 16) @@ -143,7 +143,7 @@ func (s RepositoryService) listCommitTagsLoadReferenceData(ctx context.Context, err = s.adapter.WalkReferences(ctx, repoPath, handler, opts) if err != nil { - return nil, status.Errorf(codes.Internal, "failed to get tag references: %v", err) + return nil, processGitErrorf(err, "failed to walk tag references") } log.Trace().Msgf("git adapter returned %d tags", len(tags)) diff --git a/gitrpc/internal/service/tree.go b/gitrpc/internal/service/tree.go index 77e79c00b..932b6e8f2 100644 --- a/gitrpc/internal/service/tree.go +++ b/gitrpc/internal/service/tree.go @@ -15,12 +15,12 @@ import ( func (s RepositoryService) ListTreeNodes(request *rpc.ListTreeNodesRequest, stream rpc.RepositoryService_ListTreeNodesServer) error { - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) gitNodes, err := s.adapter.ListTreeNodes(stream.Context(), repoPath, request.GetGitRef(), request.GetPath(), request.GetRecursive(), request.GetIncludeLatestCommit()) if err != nil { - return status.Errorf(codes.Internal, "failed to list nodes: %v", err) + return processGitErrorf(err, "failed to list tree nodes") } log.Trace().Msgf("git adapter returned %d nodes", len(gitNodes)) @@ -54,11 +54,11 @@ func (s RepositoryService) ListTreeNodes(request *rpc.ListTreeNodesRequest, func (s RepositoryService) GetTreeNode(ctx context.Context, request *rpc.GetTreeNodeRequest) (*rpc.GetTreeNodeResponse, error) { - repoPath := s.getFullPathForRepo(request.GetRepoUid()) + repoPath := getFullPathForRepo(s.reposRoot, request.GetRepoUid()) // TODO: do we need to validate request for nil? gitNode, err := s.adapter.GetTreeNode(ctx, repoPath, request.GetGitRef(), request.GetPath()) if err != nil { - return nil, err + return nil, processGitErrorf(err, "failed to get tree node") } res := &rpc.GetTreeNodeResponse{ @@ -76,7 +76,7 @@ func (s RepositoryService) GetTreeNode(ctx context.Context, var commit *rpc.Commit commit, err = s.getLatestCommit(ctx, repoPath, request.GetGitRef(), request.GetPath()) if err != nil { - return nil, status.Errorf(codes.Internal, "failed to get latest commit: %v", err) + return nil, err } res.Commit = commit } diff --git a/gitrpc/internal/service/upload.go b/gitrpc/internal/service/upload.go index d10a42cd3..227babe08 100644 --- a/gitrpc/internal/service/upload.go +++ b/gitrpc/internal/service/upload.go @@ -37,7 +37,7 @@ func (s RepositoryService) AddFilesAndPush( err := s.adapter.AddFiles(repoPath, false, filePaths...) if err != nil { - return err + return processGitErrorf(err, "failed to add files") } now := time.Now() err = s.adapter.Commit(repoPath, types.CommitChangesOptions{ @@ -60,7 +60,7 @@ func (s RepositoryService) AddFilesAndPush( Message: message, }) if err != nil { - return err + return processGitErrorf(err, "failed to commit files") } err = s.adapter.Push(ctx, repoPath, types.PushOptions{ // TODO: Don't hard-code @@ -72,7 +72,7 @@ func (s RepositoryService) AddFilesAndPush( Timeout: 0, }) if err != nil { - return err + return processGitErrorf(err, "failed to push files") } return nil diff --git a/gitrpc/ref.go b/gitrpc/internal/types/errors.go similarity index 50% rename from gitrpc/ref.go rename to gitrpc/internal/types/errors.go index 3c5593b70..3ba386028 100644 --- a/gitrpc/ref.go +++ b/gitrpc/internal/types/errors.go @@ -2,4 +2,12 @@ // 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 +package types + +import "errors" + +var ( + ErrAlreadyExists = errors.New("already exists") + ErrInvalidArgument = errors.New("invalid argument") + ErrNotFound = errors.New("not found") +) diff --git a/gitrpc/internal/types/types.go b/gitrpc/internal/types/types.go index c19a035bc..9fe7bea54 100644 --- a/gitrpc/internal/types/types.go +++ b/gitrpc/internal/types/types.go @@ -126,13 +126,19 @@ type WalkReferencesOptions struct { } type Commit struct { - Sha string + SHA string Title string Message string Author Signature Committer Signature } +type Branch struct { + Name string + SHA string + Commit *Commit +} + type Tag struct { Sha string Name string diff --git a/gitrpc/mapping.go b/gitrpc/mapping.go index 5f45051d1..4f3b31df5 100644 --- a/gitrpc/mapping.go +++ b/gitrpc/mapping.go @@ -9,8 +9,38 @@ import ( "time" "github.com/harness/gitness/gitrpc/rpc" + "github.com/rs/zerolog/log" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) +// Logs the error and message, returns either the provided message or a gitrpc equivalent if possible. +// Always logs the full message with error as warning. +func processRPCErrorf(err error, format string, args ...interface{}) error { + // create fallback error returned if we can't map it + fallbackErr := fmt.Errorf(format, args...) + + // always log internal error together with message. + log.Warn().Msgf("%v: [RPC] %v", fallbackErr, err) + + // ensure it's an rpc error + rpcErr, ok := status.FromError(err) + if !ok { + return fallbackErr + } + + switch { + case rpcErr.Code() == codes.AlreadyExists: + return ErrAlreadyExists + case rpcErr.Code() == codes.NotFound: + return ErrNotFound + case rpcErr.Code() == codes.InvalidArgument: + return ErrInvalidArgument + default: + return fallbackErr + } +} + func mapToRPCSortOrder(o SortOrder) rpc.SortOrder { switch o { case SortOrderAsc: diff --git a/gitrpc/proto/ref.proto b/gitrpc/proto/ref.proto new file mode 100644 index 000000000..d35b39640 --- /dev/null +++ b/gitrpc/proto/ref.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; +package rpc; + +option go_package = "github.com/harness/gitness/gitrpc/rpc"; + +import "shared.proto"; + +service ReferenceService { + rpc CreateBranch(CreateBranchRequest) returns (CreateBranchResponse); + rpc DeleteBranch(DeleteBranchRequest) returns (DeleteBranchResponse); + rpc ListBranches(ListBranchesRequest) returns (stream ListBranchesResponse); + rpc ListCommitTags(ListCommitTagsRequest) returns (stream ListCommitTagsResponse); +} + +message CreateBranchRequest { + string repo_uid = 1; + string branch_name = 2; + string target = 3; +} + +message CreateBranchResponse { + Branch branch = 1; +} + +message DeleteBranchRequest { + string repo_uid = 1; + string branch_name = 2; + bool force = 3; +} + +message DeleteBranchResponse { +} + +message ListBranchesRequest { + enum SortOption { + Default = 0; + Name = 1; + Date = 2; + } + + string repo_uid = 1; + bool include_commit = 2; + string query = 3; + SortOption sort = 4; + SortOrder order = 5; + int32 page = 6; + int32 pageSize = 7; +} + +message ListBranchesResponse { + Branch branch = 1; +} + +message Branch { + string name = 1; + string sha = 2; + Commit commit = 3; +} + +message ListCommitTagsRequest { + enum SortOption { + Default = 0; + Name = 1; + Date = 2; + } + + string repo_uid = 1; + bool include_commit = 2; + string query = 3; + SortOption sort = 4; + SortOrder order = 5; + int32 page = 6; + int32 pageSize = 7; +} + +message ListCommitTagsResponse { + CommitTag tag = 1; +} + +message CommitTag { + string name = 1; + string sha = 2; + bool is_annotated = 3; + string title = 4; + string message = 5; + Signature tagger = 6; + Commit commit = 7; +} \ No newline at end of file diff --git a/gitrpc/proto/repo.proto b/gitrpc/proto/repo.proto index 9496c6793..5d8374994 100644 --- a/gitrpc/proto/repo.proto +++ b/gitrpc/proto/repo.proto @@ -13,8 +13,6 @@ service RepositoryService { rpc GetSubmodule(GetSubmoduleRequest) returns (GetSubmoduleResponse); rpc GetBlob(GetBlobRequest) returns (GetBlobResponse); rpc ListCommits(ListCommitsRequest) returns (stream ListCommitsResponse); - rpc ListBranches(ListBranchesRequest) returns (stream ListBranchesResponse); - rpc ListCommitTags(ListCommitTagsRequest) returns (stream ListCommitTagsResponse); } message CreateRepositoryRequest { @@ -96,32 +94,6 @@ message ListCommitsResponseHeader { int64 total_count = 1; } -message ListBranchesRequest { - enum SortOption { - Default = 0; - Name = 1; - Date = 2; - } - - string repo_uid = 1; - bool include_commit = 2; - string query = 3; - SortOption sort = 4; - SortOrder order = 5; - int32 page = 6; - int32 pageSize = 7; -} - -message ListBranchesResponse { - Branch branch = 1; -} - -message Branch { - string name = 1; - string sha = 2; - Commit commit = 3; -} - message GetBlobRequest { string repo_uid = 1; string sha = 2; @@ -151,52 +123,4 @@ message GetSubmoduleResponse { message Submodule { string name = 1; string url = 2; -} - -message ListCommitTagsRequest { - enum SortOption { - Default = 0; - Name = 1; - Date = 2; - } - - string repo_uid = 1; - bool include_commit = 2; - string query = 3; - SortOption sort = 4; - SortOrder order = 5; - int32 page = 6; - int32 pageSize = 7; -} - -message ListCommitTagsResponse { - CommitTag tag = 1; -} - -message CommitTag { - string name = 1; - string sha = 2; - bool is_annotated = 3; - string title = 4; - string message = 5; - Signature tagger = 6; - Commit commit = 7; -} - -message Commit { - string sha = 1; - string title = 2; - string message = 3; - Signature author = 4; - Signature committer = 5; -} - -message Signature { - Identity identity = 1; - int64 when = 2; -} - -message Identity { - string name = 1; - string email = 2; -} +} \ No newline at end of file diff --git a/gitrpc/proto/shared.proto b/gitrpc/proto/shared.proto index 1ce12e7b4..f702d7a8c 100644 --- a/gitrpc/proto/shared.proto +++ b/gitrpc/proto/shared.proto @@ -23,4 +23,22 @@ enum SortOrder { Default = 0; Asc = 1; Desc = 2; -} \ No newline at end of file +} + +message Commit { + string sha = 1; + string title = 2; + string message = 3; + Signature author = 4; + Signature committer = 5; +} + +message Signature { + Identity identity = 1; + int64 when = 2; +} + +message Identity { + string name = 1; + string email = 2; +} diff --git a/gitrpc/repo.go b/gitrpc/repo.go index 50e606b22..181261e92 100644 --- a/gitrpc/repo.go +++ b/gitrpc/repo.go @@ -79,7 +79,7 @@ func (c *Client) CreateRepository(ctx context.Context, _, err = stream.CloseAndRecv() if err != nil { - return nil, err + return nil, processRPCErrorf(err, "failed to create repo on server (uid: '%s')", uid) } log.Ctx(ctx).Info().Msgf("completed git repo setup.") diff --git a/gitrpc/rpc/ref.pb.go b/gitrpc/rpc/ref.pb.go new file mode 100644 index 000000000..466251c95 --- /dev/null +++ b/gitrpc/rpc/ref.pb.go @@ -0,0 +1,1090 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.7 +// source: ref.proto + +package rpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListBranchesRequest_SortOption int32 + +const ( + ListBranchesRequest_Default ListBranchesRequest_SortOption = 0 + ListBranchesRequest_Name ListBranchesRequest_SortOption = 1 + ListBranchesRequest_Date ListBranchesRequest_SortOption = 2 +) + +// Enum value maps for ListBranchesRequest_SortOption. +var ( + ListBranchesRequest_SortOption_name = map[int32]string{ + 0: "Default", + 1: "Name", + 2: "Date", + } + ListBranchesRequest_SortOption_value = map[string]int32{ + "Default": 0, + "Name": 1, + "Date": 2, + } +) + +func (x ListBranchesRequest_SortOption) Enum() *ListBranchesRequest_SortOption { + p := new(ListBranchesRequest_SortOption) + *p = x + return p +} + +func (x ListBranchesRequest_SortOption) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ListBranchesRequest_SortOption) Descriptor() protoreflect.EnumDescriptor { + return file_ref_proto_enumTypes[0].Descriptor() +} + +func (ListBranchesRequest_SortOption) Type() protoreflect.EnumType { + return &file_ref_proto_enumTypes[0] +} + +func (x ListBranchesRequest_SortOption) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ListBranchesRequest_SortOption.Descriptor instead. +func (ListBranchesRequest_SortOption) EnumDescriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{4, 0} +} + +type ListCommitTagsRequest_SortOption int32 + +const ( + ListCommitTagsRequest_Default ListCommitTagsRequest_SortOption = 0 + ListCommitTagsRequest_Name ListCommitTagsRequest_SortOption = 1 + ListCommitTagsRequest_Date ListCommitTagsRequest_SortOption = 2 +) + +// Enum value maps for ListCommitTagsRequest_SortOption. +var ( + ListCommitTagsRequest_SortOption_name = map[int32]string{ + 0: "Default", + 1: "Name", + 2: "Date", + } + ListCommitTagsRequest_SortOption_value = map[string]int32{ + "Default": 0, + "Name": 1, + "Date": 2, + } +) + +func (x ListCommitTagsRequest_SortOption) Enum() *ListCommitTagsRequest_SortOption { + p := new(ListCommitTagsRequest_SortOption) + *p = x + return p +} + +func (x ListCommitTagsRequest_SortOption) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ListCommitTagsRequest_SortOption) Descriptor() protoreflect.EnumDescriptor { + return file_ref_proto_enumTypes[1].Descriptor() +} + +func (ListCommitTagsRequest_SortOption) Type() protoreflect.EnumType { + return &file_ref_proto_enumTypes[1] +} + +func (x ListCommitTagsRequest_SortOption) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ListCommitTagsRequest_SortOption.Descriptor instead. +func (ListCommitTagsRequest_SortOption) EnumDescriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{7, 0} +} + +type CreateBranchRequest 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"` + 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() { + *x = CreateBranchRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateBranchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateBranchRequest) ProtoMessage() {} + +func (x *CreateBranchRequest) ProtoReflect() protoreflect.Message { + mi := &file_ref_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 CreateBranchRequest.ProtoReflect.Descriptor instead. +func (*CreateBranchRequest) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateBranchRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +func (x *CreateBranchRequest) GetBranchName() string { + if x != nil { + return x.BranchName + } + return "" +} + +func (x *CreateBranchRequest) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +type CreateBranchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Branch *Branch `protobuf:"bytes,1,opt,name=branch,proto3" json:"branch,omitempty"` +} + +func (x *CreateBranchResponse) Reset() { + *x = CreateBranchResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateBranchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateBranchResponse) ProtoMessage() {} + +func (x *CreateBranchResponse) ProtoReflect() protoreflect.Message { + mi := &file_ref_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 CreateBranchResponse.ProtoReflect.Descriptor instead. +func (*CreateBranchResponse) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateBranchResponse) GetBranch() *Branch { + if x != nil { + return x.Branch + } + return nil +} + +type DeleteBranchRequest 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"` + 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() { + *x = DeleteBranchRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteBranchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteBranchRequest) ProtoMessage() {} + +func (x *DeleteBranchRequest) ProtoReflect() protoreflect.Message { + mi := &file_ref_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 DeleteBranchRequest.ProtoReflect.Descriptor instead. +func (*DeleteBranchRequest) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{2} +} + +func (x *DeleteBranchRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +func (x *DeleteBranchRequest) GetBranchName() string { + if x != nil { + return x.BranchName + } + return "" +} + +func (x *DeleteBranchRequest) GetForce() bool { + if x != nil { + return x.Force + } + return false +} + +type DeleteBranchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteBranchResponse) Reset() { + *x = DeleteBranchResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteBranchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteBranchResponse) ProtoMessage() {} + +func (x *DeleteBranchResponse) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[3] + 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 DeleteBranchResponse.ProtoReflect.Descriptor instead. +func (*DeleteBranchResponse) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{3} +} + +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"` + 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"` + Order SortOrder `protobuf:"varint,5,opt,name=order,proto3,enum=rpc.SortOrder" json:"order,omitempty"` + Page int32 `protobuf:"varint,6,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,7,opt,name=pageSize,proto3" json:"pageSize,omitempty"` +} + +func (x *ListBranchesRequest) Reset() { + *x = ListBranchesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListBranchesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListBranchesRequest) ProtoMessage() {} + +func (x *ListBranchesRequest) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[4] + 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 ListBranchesRequest.ProtoReflect.Descriptor instead. +func (*ListBranchesRequest) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{4} +} + +func (x *ListBranchesRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +func (x *ListBranchesRequest) GetIncludeCommit() bool { + if x != nil { + return x.IncludeCommit + } + return false +} + +func (x *ListBranchesRequest) GetQuery() string { + if x != nil { + return x.Query + } + return "" +} + +func (x *ListBranchesRequest) GetSort() ListBranchesRequest_SortOption { + if x != nil { + return x.Sort + } + return ListBranchesRequest_Default +} + +func (x *ListBranchesRequest) GetOrder() SortOrder { + if x != nil { + return x.Order + } + return SortOrder_Default +} + +func (x *ListBranchesRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListBranchesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +type ListBranchesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Branch *Branch `protobuf:"bytes,1,opt,name=branch,proto3" json:"branch,omitempty"` +} + +func (x *ListBranchesResponse) Reset() { + *x = ListBranchesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListBranchesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListBranchesResponse) ProtoMessage() {} + +func (x *ListBranchesResponse) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[5] + 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 ListBranchesResponse.ProtoReflect.Descriptor instead. +func (*ListBranchesResponse) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{5} +} + +func (x *ListBranchesResponse) GetBranch() *Branch { + if x != nil { + return x.Branch + } + return nil +} + +type Branch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Sha string `protobuf:"bytes,2,opt,name=sha,proto3" json:"sha,omitempty"` + Commit *Commit `protobuf:"bytes,3,opt,name=commit,proto3" json:"commit,omitempty"` +} + +func (x *Branch) Reset() { + *x = Branch{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Branch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Branch) ProtoMessage() {} + +func (x *Branch) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[6] + 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 Branch.ProtoReflect.Descriptor instead. +func (*Branch) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{6} +} + +func (x *Branch) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Branch) GetSha() string { + if x != nil { + return x.Sha + } + return "" +} + +func (x *Branch) GetCommit() *Commit { + if x != nil { + return x.Commit + } + return nil +} + +type ListCommitTagsRequest 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"` + 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"` + Order SortOrder `protobuf:"varint,5,opt,name=order,proto3,enum=rpc.SortOrder" json:"order,omitempty"` + Page int32 `protobuf:"varint,6,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,7,opt,name=pageSize,proto3" json:"pageSize,omitempty"` +} + +func (x *ListCommitTagsRequest) Reset() { + *x = ListCommitTagsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListCommitTagsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListCommitTagsRequest) ProtoMessage() {} + +func (x *ListCommitTagsRequest) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[7] + 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 ListCommitTagsRequest.ProtoReflect.Descriptor instead. +func (*ListCommitTagsRequest) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{7} +} + +func (x *ListCommitTagsRequest) GetRepoUid() string { + if x != nil { + return x.RepoUid + } + return "" +} + +func (x *ListCommitTagsRequest) GetIncludeCommit() bool { + if x != nil { + return x.IncludeCommit + } + return false +} + +func (x *ListCommitTagsRequest) GetQuery() string { + if x != nil { + return x.Query + } + return "" +} + +func (x *ListCommitTagsRequest) GetSort() ListCommitTagsRequest_SortOption { + if x != nil { + return x.Sort + } + return ListCommitTagsRequest_Default +} + +func (x *ListCommitTagsRequest) GetOrder() SortOrder { + if x != nil { + return x.Order + } + return SortOrder_Default +} + +func (x *ListCommitTagsRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListCommitTagsRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +type ListCommitTagsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag *CommitTag `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *ListCommitTagsResponse) Reset() { + *x = ListCommitTagsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListCommitTagsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListCommitTagsResponse) ProtoMessage() {} + +func (x *ListCommitTagsResponse) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[8] + 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 ListCommitTagsResponse.ProtoReflect.Descriptor instead. +func (*ListCommitTagsResponse) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{8} +} + +func (x *ListCommitTagsResponse) GetTag() *CommitTag { + if x != nil { + return x.Tag + } + return nil +} + +type CommitTag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Sha string `protobuf:"bytes,2,opt,name=sha,proto3" json:"sha,omitempty"` + IsAnnotated bool `protobuf:"varint,3,opt,name=is_annotated,json=isAnnotated,proto3" json:"is_annotated,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"` + Tagger *Signature `protobuf:"bytes,6,opt,name=tagger,proto3" json:"tagger,omitempty"` + Commit *Commit `protobuf:"bytes,7,opt,name=commit,proto3" json:"commit,omitempty"` +} + +func (x *CommitTag) Reset() { + *x = CommitTag{} + if protoimpl.UnsafeEnabled { + mi := &file_ref_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitTag) ProtoMessage() {} + +func (x *CommitTag) ProtoReflect() protoreflect.Message { + mi := &file_ref_proto_msgTypes[9] + 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 CommitTag.ProtoReflect.Descriptor instead. +func (*CommitTag) Descriptor() ([]byte, []int) { + return file_ref_proto_rawDescGZIP(), []int{9} +} + +func (x *CommitTag) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CommitTag) GetSha() string { + if x != nil { + return x.Sha + } + return "" +} + +func (x *CommitTag) GetIsAnnotated() bool { + if x != nil { + return x.IsAnnotated + } + return false +} + +func (x *CommitTag) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *CommitTag) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *CommitTag) GetTagger() *Signature { + if x != nil { + return x.Tagger + } + return nil +} + +func (x *CommitTag) GetCommit() *Commit { + if x != nil { + return x.Commit + } + return nil +} + +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, + 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, + 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, + 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, 0x39, 0x0a, 0x04, 0x73, 0x6f, 0x72, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 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, 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, 0x3a, 0x0a, 0x16, 0x4c, 0x69, 0x73, + 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, + 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0xd1, 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x54, 0x61, 0x67, 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, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, + 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0b, 0x69, 0x73, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 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, 0x26, 0x0a, 0x06, + 0x74, 0x61, 0x67, 0x67, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, + 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, 0x32, 0xb0, 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, 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, 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 ( + file_ref_proto_rawDescOnce sync.Once + file_ref_proto_rawDescData = file_ref_proto_rawDesc +) + +func file_ref_proto_rawDescGZIP() []byte { + file_ref_proto_rawDescOnce.Do(func() { + file_ref_proto_rawDescData = protoimpl.X.CompressGZIP(file_ref_proto_rawDescData) + }) + return file_ref_proto_rawDescData +} + +var file_ref_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_ref_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_ref_proto_goTypes = []interface{}{ + (ListBranchesRequest_SortOption)(0), // 0: rpc.ListBranchesRequest.SortOption + (ListCommitTagsRequest_SortOption)(0), // 1: rpc.ListCommitTagsRequest.SortOption + (*CreateBranchRequest)(nil), // 2: rpc.CreateBranchRequest + (*CreateBranchResponse)(nil), // 3: rpc.CreateBranchResponse + (*DeleteBranchRequest)(nil), // 4: rpc.DeleteBranchRequest + (*DeleteBranchResponse)(nil), // 5: rpc.DeleteBranchResponse + (*ListBranchesRequest)(nil), // 6: rpc.ListBranchesRequest + (*ListBranchesResponse)(nil), // 7: rpc.ListBranchesResponse + (*Branch)(nil), // 8: rpc.Branch + (*ListCommitTagsRequest)(nil), // 9: rpc.ListCommitTagsRequest + (*ListCommitTagsResponse)(nil), // 10: rpc.ListCommitTagsResponse + (*CommitTag)(nil), // 11: rpc.CommitTag + (SortOrder)(0), // 12: rpc.SortOrder + (*Commit)(nil), // 13: rpc.Commit + (*Signature)(nil), // 14: rpc.Signature +} +var file_ref_proto_depIdxs = []int32{ + 8, // 0: rpc.CreateBranchResponse.branch:type_name -> rpc.Branch + 0, // 1: rpc.ListBranchesRequest.sort:type_name -> rpc.ListBranchesRequest.SortOption + 12, // 2: rpc.ListBranchesRequest.order:type_name -> rpc.SortOrder + 8, // 3: rpc.ListBranchesResponse.branch:type_name -> rpc.Branch + 13, // 4: rpc.Branch.commit:type_name -> rpc.Commit + 1, // 5: rpc.ListCommitTagsRequest.sort:type_name -> rpc.ListCommitTagsRequest.SortOption + 12, // 6: rpc.ListCommitTagsRequest.order:type_name -> rpc.SortOrder + 11, // 7: rpc.ListCommitTagsResponse.tag:type_name -> rpc.CommitTag + 14, // 8: rpc.CommitTag.tagger:type_name -> rpc.Signature + 13, // 9: rpc.CommitTag.commit:type_name -> rpc.Commit + 2, // 10: rpc.ReferenceService.CreateBranch:input_type -> rpc.CreateBranchRequest + 4, // 11: rpc.ReferenceService.DeleteBranch:input_type -> rpc.DeleteBranchRequest + 6, // 12: rpc.ReferenceService.ListBranches:input_type -> rpc.ListBranchesRequest + 9, // 13: rpc.ReferenceService.ListCommitTags:input_type -> rpc.ListCommitTagsRequest + 3, // 14: rpc.ReferenceService.CreateBranch:output_type -> rpc.CreateBranchResponse + 5, // 15: rpc.ReferenceService.DeleteBranch:output_type -> rpc.DeleteBranchResponse + 7, // 16: rpc.ReferenceService.ListBranches:output_type -> rpc.ListBranchesResponse + 10, // 17: rpc.ReferenceService.ListCommitTags:output_type -> rpc.ListCommitTagsResponse + 14, // [14:18] is the sub-list for method output_type + 10, // [10:14] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name +} + +func init() { file_ref_proto_init() } +func file_ref_proto_init() { + if File_ref_proto != nil { + return + } + file_shared_proto_init() + if !protoimpl.UnsafeEnabled { + file_ref_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateBranchRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateBranchResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteBranchRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteBranchResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListBranchesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListBranchesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Branch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListCommitTagsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListCommitTagsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ref_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitTag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ref_proto_rawDesc, + NumEnums: 2, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_ref_proto_goTypes, + DependencyIndexes: file_ref_proto_depIdxs, + EnumInfos: file_ref_proto_enumTypes, + MessageInfos: file_ref_proto_msgTypes, + }.Build() + File_ref_proto = out.File + file_ref_proto_rawDesc = nil + file_ref_proto_goTypes = nil + file_ref_proto_depIdxs = nil +} diff --git a/gitrpc/rpc/ref_grpc.pb.go b/gitrpc/rpc/ref_grpc.pb.go new file mode 100644 index 000000000..4c4789895 --- /dev/null +++ b/gitrpc/rpc/ref_grpc.pb.go @@ -0,0 +1,268 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.7 +// source: ref.proto + +package rpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// ReferenceServiceClient is the client API for ReferenceService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ReferenceServiceClient interface { + CreateBranch(ctx context.Context, in *CreateBranchRequest, opts ...grpc.CallOption) (*CreateBranchResponse, error) + DeleteBranch(ctx context.Context, in *DeleteBranchRequest, opts ...grpc.CallOption) (*DeleteBranchResponse, error) + ListBranches(ctx context.Context, in *ListBranchesRequest, opts ...grpc.CallOption) (ReferenceService_ListBranchesClient, error) + ListCommitTags(ctx context.Context, in *ListCommitTagsRequest, opts ...grpc.CallOption) (ReferenceService_ListCommitTagsClient, error) +} + +type referenceServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewReferenceServiceClient(cc grpc.ClientConnInterface) ReferenceServiceClient { + return &referenceServiceClient{cc} +} + +func (c *referenceServiceClient) CreateBranch(ctx context.Context, in *CreateBranchRequest, opts ...grpc.CallOption) (*CreateBranchResponse, error) { + out := new(CreateBranchResponse) + err := c.cc.Invoke(ctx, "/rpc.ReferenceService/CreateBranch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *referenceServiceClient) DeleteBranch(ctx context.Context, in *DeleteBranchRequest, opts ...grpc.CallOption) (*DeleteBranchResponse, error) { + out := new(DeleteBranchResponse) + err := c.cc.Invoke(ctx, "/rpc.ReferenceService/DeleteBranch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *referenceServiceClient) ListBranches(ctx context.Context, in *ListBranchesRequest, opts ...grpc.CallOption) (ReferenceService_ListBranchesClient, error) { + stream, err := c.cc.NewStream(ctx, &ReferenceService_ServiceDesc.Streams[0], "/rpc.ReferenceService/ListBranches", opts...) + if err != nil { + return nil, err + } + x := &referenceServiceListBranchesClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ReferenceService_ListBranchesClient interface { + Recv() (*ListBranchesResponse, error) + grpc.ClientStream +} + +type referenceServiceListBranchesClient struct { + grpc.ClientStream +} + +func (x *referenceServiceListBranchesClient) Recv() (*ListBranchesResponse, error) { + m := new(ListBranchesResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *referenceServiceClient) ListCommitTags(ctx context.Context, in *ListCommitTagsRequest, opts ...grpc.CallOption) (ReferenceService_ListCommitTagsClient, error) { + stream, err := c.cc.NewStream(ctx, &ReferenceService_ServiceDesc.Streams[1], "/rpc.ReferenceService/ListCommitTags", opts...) + if err != nil { + return nil, err + } + x := &referenceServiceListCommitTagsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ReferenceService_ListCommitTagsClient interface { + Recv() (*ListCommitTagsResponse, error) + grpc.ClientStream +} + +type referenceServiceListCommitTagsClient struct { + grpc.ClientStream +} + +func (x *referenceServiceListCommitTagsClient) Recv() (*ListCommitTagsResponse, error) { + m := new(ListCommitTagsResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// ReferenceServiceServer is the server API for ReferenceService service. +// All implementations must embed UnimplementedReferenceServiceServer +// for forward compatibility +type ReferenceServiceServer interface { + CreateBranch(context.Context, *CreateBranchRequest) (*CreateBranchResponse, error) + DeleteBranch(context.Context, *DeleteBranchRequest) (*DeleteBranchResponse, error) + ListBranches(*ListBranchesRequest, ReferenceService_ListBranchesServer) error + ListCommitTags(*ListCommitTagsRequest, ReferenceService_ListCommitTagsServer) error + mustEmbedUnimplementedReferenceServiceServer() +} + +// UnimplementedReferenceServiceServer must be embedded to have forward compatible implementations. +type UnimplementedReferenceServiceServer struct { +} + +func (UnimplementedReferenceServiceServer) CreateBranch(context.Context, *CreateBranchRequest) (*CreateBranchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateBranch not implemented") +} +func (UnimplementedReferenceServiceServer) DeleteBranch(context.Context, *DeleteBranchRequest) (*DeleteBranchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteBranch not implemented") +} +func (UnimplementedReferenceServiceServer) ListBranches(*ListBranchesRequest, ReferenceService_ListBranchesServer) error { + return status.Errorf(codes.Unimplemented, "method ListBranches not implemented") +} +func (UnimplementedReferenceServiceServer) ListCommitTags(*ListCommitTagsRequest, ReferenceService_ListCommitTagsServer) error { + return status.Errorf(codes.Unimplemented, "method ListCommitTags not implemented") +} +func (UnimplementedReferenceServiceServer) mustEmbedUnimplementedReferenceServiceServer() {} + +// UnsafeReferenceServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ReferenceServiceServer will +// result in compilation errors. +type UnsafeReferenceServiceServer interface { + mustEmbedUnimplementedReferenceServiceServer() +} + +func RegisterReferenceServiceServer(s grpc.ServiceRegistrar, srv ReferenceServiceServer) { + s.RegisterService(&ReferenceService_ServiceDesc, srv) +} + +func _ReferenceService_CreateBranch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateBranchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ReferenceServiceServer).CreateBranch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.ReferenceService/CreateBranch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ReferenceServiceServer).CreateBranch(ctx, req.(*CreateBranchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ReferenceService_DeleteBranch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteBranchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ReferenceServiceServer).DeleteBranch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rpc.ReferenceService/DeleteBranch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ReferenceServiceServer).DeleteBranch(ctx, req.(*DeleteBranchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ReferenceService_ListBranches_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListBranchesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ReferenceServiceServer).ListBranches(m, &referenceServiceListBranchesServer{stream}) +} + +type ReferenceService_ListBranchesServer interface { + Send(*ListBranchesResponse) error + grpc.ServerStream +} + +type referenceServiceListBranchesServer struct { + grpc.ServerStream +} + +func (x *referenceServiceListBranchesServer) Send(m *ListBranchesResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _ReferenceService_ListCommitTags_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListCommitTagsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ReferenceServiceServer).ListCommitTags(m, &referenceServiceListCommitTagsServer{stream}) +} + +type ReferenceService_ListCommitTagsServer interface { + Send(*ListCommitTagsResponse) error + grpc.ServerStream +} + +type referenceServiceListCommitTagsServer struct { + grpc.ServerStream +} + +func (x *referenceServiceListCommitTagsServer) Send(m *ListCommitTagsResponse) error { + return x.ServerStream.SendMsg(m) +} + +// ReferenceService_ServiceDesc is the grpc.ServiceDesc for ReferenceService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ReferenceService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "rpc.ReferenceService", + HandlerType: (*ReferenceServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateBranch", + Handler: _ReferenceService_CreateBranch_Handler, + }, + { + MethodName: "DeleteBranch", + Handler: _ReferenceService_DeleteBranch_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "ListBranches", + Handler: _ReferenceService_ListBranches_Handler, + ServerStreams: true, + }, + { + StreamName: "ListCommitTags", + Handler: _ReferenceService_ListCommitTags_Handler, + ServerStreams: true, + }, + }, + Metadata: "ref.proto", +} diff --git a/gitrpc/rpc/repo.pb.go b/gitrpc/rpc/repo.pb.go index d40b3294e..4b3d690b3 100644 --- a/gitrpc/rpc/repo.pb.go +++ b/gitrpc/rpc/repo.pb.go @@ -124,104 +124,6 @@ func (TreeNodeMode) EnumDescriptor() ([]byte, []int) { return file_repo_proto_rawDescGZIP(), []int{1} } -type ListBranchesRequest_SortOption int32 - -const ( - ListBranchesRequest_Default ListBranchesRequest_SortOption = 0 - ListBranchesRequest_Name ListBranchesRequest_SortOption = 1 - ListBranchesRequest_Date ListBranchesRequest_SortOption = 2 -) - -// Enum value maps for ListBranchesRequest_SortOption. -var ( - ListBranchesRequest_SortOption_name = map[int32]string{ - 0: "Default", - 1: "Name", - 2: "Date", - } - ListBranchesRequest_SortOption_value = map[string]int32{ - "Default": 0, - "Name": 1, - "Date": 2, - } -) - -func (x ListBranchesRequest_SortOption) Enum() *ListBranchesRequest_SortOption { - p := new(ListBranchesRequest_SortOption) - *p = x - return p -} - -func (x ListBranchesRequest_SortOption) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ListBranchesRequest_SortOption) Descriptor() protoreflect.EnumDescriptor { - return file_repo_proto_enumTypes[2].Descriptor() -} - -func (ListBranchesRequest_SortOption) Type() protoreflect.EnumType { - return &file_repo_proto_enumTypes[2] -} - -func (x ListBranchesRequest_SortOption) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ListBranchesRequest_SortOption.Descriptor instead. -func (ListBranchesRequest_SortOption) EnumDescriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{11, 0} -} - -type ListCommitTagsRequest_SortOption int32 - -const ( - ListCommitTagsRequest_Default ListCommitTagsRequest_SortOption = 0 - ListCommitTagsRequest_Name ListCommitTagsRequest_SortOption = 1 - ListCommitTagsRequest_Date ListCommitTagsRequest_SortOption = 2 -) - -// Enum value maps for ListCommitTagsRequest_SortOption. -var ( - ListCommitTagsRequest_SortOption_name = map[int32]string{ - 0: "Default", - 1: "Name", - 2: "Date", - } - ListCommitTagsRequest_SortOption_value = map[string]int32{ - "Default": 0, - "Name": 1, - "Date": 2, - } -) - -func (x ListCommitTagsRequest_SortOption) Enum() *ListCommitTagsRequest_SortOption { - p := new(ListCommitTagsRequest_SortOption) - *p = x - return p -} - -func (x ListCommitTagsRequest_SortOption) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ListCommitTagsRequest_SortOption) Descriptor() protoreflect.EnumDescriptor { - return file_repo_proto_enumTypes[3].Descriptor() -} - -func (ListCommitTagsRequest_SortOption) Type() protoreflect.EnumType { - return &file_repo_proto_enumTypes[3] -} - -func (x ListCommitTagsRequest_SortOption) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ListCommitTagsRequest_SortOption.Descriptor instead. -func (ListCommitTagsRequest_SortOption) EnumDescriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{20, 0} -} - type CreateRepositoryRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -932,211 +834,6 @@ func (x *ListCommitsResponseHeader) GetTotalCount() int64 { return 0 } -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"` - 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"` - Order SortOrder `protobuf:"varint,5,opt,name=order,proto3,enum=rpc.SortOrder" json:"order,omitempty"` - Page int32 `protobuf:"varint,6,opt,name=page,proto3" json:"page,omitempty"` - PageSize int32 `protobuf:"varint,7,opt,name=pageSize,proto3" json:"pageSize,omitempty"` -} - -func (x *ListBranchesRequest) Reset() { - *x = ListBranchesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListBranchesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListBranchesRequest) ProtoMessage() {} - -func (x *ListBranchesRequest) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[11] - 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 ListBranchesRequest.ProtoReflect.Descriptor instead. -func (*ListBranchesRequest) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{11} -} - -func (x *ListBranchesRequest) GetRepoUid() string { - if x != nil { - return x.RepoUid - } - return "" -} - -func (x *ListBranchesRequest) GetIncludeCommit() bool { - if x != nil { - return x.IncludeCommit - } - return false -} - -func (x *ListBranchesRequest) GetQuery() string { - if x != nil { - return x.Query - } - return "" -} - -func (x *ListBranchesRequest) GetSort() ListBranchesRequest_SortOption { - if x != nil { - return x.Sort - } - return ListBranchesRequest_Default -} - -func (x *ListBranchesRequest) GetOrder() SortOrder { - if x != nil { - return x.Order - } - return SortOrder_Default -} - -func (x *ListBranchesRequest) GetPage() int32 { - if x != nil { - return x.Page - } - return 0 -} - -func (x *ListBranchesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -type ListBranchesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Branch *Branch `protobuf:"bytes,1,opt,name=branch,proto3" json:"branch,omitempty"` -} - -func (x *ListBranchesResponse) Reset() { - *x = ListBranchesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListBranchesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListBranchesResponse) ProtoMessage() {} - -func (x *ListBranchesResponse) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[12] - 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 ListBranchesResponse.ProtoReflect.Descriptor instead. -func (*ListBranchesResponse) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{12} -} - -func (x *ListBranchesResponse) GetBranch() *Branch { - if x != nil { - return x.Branch - } - return nil -} - -type Branch struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Sha string `protobuf:"bytes,2,opt,name=sha,proto3" json:"sha,omitempty"` - Commit *Commit `protobuf:"bytes,3,opt,name=commit,proto3" json:"commit,omitempty"` -} - -func (x *Branch) Reset() { - *x = Branch{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Branch) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Branch) ProtoMessage() {} - -func (x *Branch) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[13] - 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 Branch.ProtoReflect.Descriptor instead. -func (*Branch) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{13} -} - -func (x *Branch) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Branch) GetSha() string { - if x != nil { - return x.Sha - } - return "" -} - -func (x *Branch) GetCommit() *Commit { - if x != nil { - return x.Commit - } - return nil -} - type GetBlobRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1150,7 +847,7 @@ type GetBlobRequest struct { func (x *GetBlobRequest) Reset() { *x = GetBlobRequest{} if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[14] + mi := &file_repo_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1163,7 +860,7 @@ func (x *GetBlobRequest) String() string { func (*GetBlobRequest) ProtoMessage() {} func (x *GetBlobRequest) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[14] + mi := &file_repo_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1176,7 +873,7 @@ func (x *GetBlobRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBlobRequest.ProtoReflect.Descriptor instead. func (*GetBlobRequest) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{14} + return file_repo_proto_rawDescGZIP(), []int{11} } func (x *GetBlobRequest) GetRepoUid() string { @@ -1211,7 +908,7 @@ type GetBlobResponse struct { func (x *GetBlobResponse) Reset() { *x = GetBlobResponse{} if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[15] + mi := &file_repo_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1224,7 +921,7 @@ func (x *GetBlobResponse) String() string { func (*GetBlobResponse) ProtoMessage() {} func (x *GetBlobResponse) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[15] + mi := &file_repo_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1237,7 +934,7 @@ func (x *GetBlobResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBlobResponse.ProtoReflect.Descriptor instead. func (*GetBlobResponse) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{15} + return file_repo_proto_rawDescGZIP(), []int{12} } func (x *GetBlobResponse) GetBlob() *Blob { @@ -1260,7 +957,7 @@ type Blob struct { func (x *Blob) Reset() { *x = Blob{} if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[16] + mi := &file_repo_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1273,7 +970,7 @@ func (x *Blob) String() string { func (*Blob) ProtoMessage() {} func (x *Blob) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[16] + mi := &file_repo_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1286,7 +983,7 @@ func (x *Blob) ProtoReflect() protoreflect.Message { // Deprecated: Use Blob.ProtoReflect.Descriptor instead. func (*Blob) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{16} + return file_repo_proto_rawDescGZIP(), []int{13} } func (x *Blob) GetSha() string { @@ -1323,7 +1020,7 @@ type GetSubmoduleRequest struct { func (x *GetSubmoduleRequest) Reset() { *x = GetSubmoduleRequest{} if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[17] + mi := &file_repo_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1336,7 +1033,7 @@ func (x *GetSubmoduleRequest) String() string { func (*GetSubmoduleRequest) ProtoMessage() {} func (x *GetSubmoduleRequest) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[17] + mi := &file_repo_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1349,7 +1046,7 @@ func (x *GetSubmoduleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSubmoduleRequest.ProtoReflect.Descriptor instead. func (*GetSubmoduleRequest) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{17} + return file_repo_proto_rawDescGZIP(), []int{14} } func (x *GetSubmoduleRequest) GetRepoUid() string { @@ -1384,7 +1081,7 @@ type GetSubmoduleResponse struct { func (x *GetSubmoduleResponse) Reset() { *x = GetSubmoduleResponse{} if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[18] + mi := &file_repo_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1397,7 +1094,7 @@ func (x *GetSubmoduleResponse) String() string { func (*GetSubmoduleResponse) ProtoMessage() {} func (x *GetSubmoduleResponse) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[18] + mi := &file_repo_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1410,7 +1107,7 @@ func (x *GetSubmoduleResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSubmoduleResponse.ProtoReflect.Descriptor instead. func (*GetSubmoduleResponse) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{18} + return file_repo_proto_rawDescGZIP(), []int{15} } func (x *GetSubmoduleResponse) GetSubmodule() *Submodule { @@ -1432,7 +1129,7 @@ type Submodule struct { func (x *Submodule) Reset() { *x = Submodule{} if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[19] + mi := &file_repo_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1445,7 +1142,7 @@ func (x *Submodule) String() string { func (*Submodule) ProtoMessage() {} func (x *Submodule) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[19] + mi := &file_repo_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1458,7 +1155,7 @@ func (x *Submodule) ProtoReflect() protoreflect.Message { // Deprecated: Use Submodule.ProtoReflect.Descriptor instead. func (*Submodule) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{19} + return file_repo_proto_rawDescGZIP(), []int{16} } func (x *Submodule) GetName() string { @@ -1475,432 +1172,6 @@ func (x *Submodule) GetUrl() string { return "" } -type ListCommitTagsRequest 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"` - 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"` - Order SortOrder `protobuf:"varint,5,opt,name=order,proto3,enum=rpc.SortOrder" json:"order,omitempty"` - Page int32 `protobuf:"varint,6,opt,name=page,proto3" json:"page,omitempty"` - PageSize int32 `protobuf:"varint,7,opt,name=pageSize,proto3" json:"pageSize,omitempty"` -} - -func (x *ListCommitTagsRequest) Reset() { - *x = ListCommitTagsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListCommitTagsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListCommitTagsRequest) ProtoMessage() {} - -func (x *ListCommitTagsRequest) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListCommitTagsRequest.ProtoReflect.Descriptor instead. -func (*ListCommitTagsRequest) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{20} -} - -func (x *ListCommitTagsRequest) GetRepoUid() string { - if x != nil { - return x.RepoUid - } - return "" -} - -func (x *ListCommitTagsRequest) GetIncludeCommit() bool { - if x != nil { - return x.IncludeCommit - } - return false -} - -func (x *ListCommitTagsRequest) GetQuery() string { - if x != nil { - return x.Query - } - return "" -} - -func (x *ListCommitTagsRequest) GetSort() ListCommitTagsRequest_SortOption { - if x != nil { - return x.Sort - } - return ListCommitTagsRequest_Default -} - -func (x *ListCommitTagsRequest) GetOrder() SortOrder { - if x != nil { - return x.Order - } - return SortOrder_Default -} - -func (x *ListCommitTagsRequest) GetPage() int32 { - if x != nil { - return x.Page - } - return 0 -} - -func (x *ListCommitTagsRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -type ListCommitTagsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Tag *CommitTag `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` -} - -func (x *ListCommitTagsResponse) Reset() { - *x = ListCommitTagsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListCommitTagsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListCommitTagsResponse) ProtoMessage() {} - -func (x *ListCommitTagsResponse) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[21] - 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 ListCommitTagsResponse.ProtoReflect.Descriptor instead. -func (*ListCommitTagsResponse) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{21} -} - -func (x *ListCommitTagsResponse) GetTag() *CommitTag { - if x != nil { - return x.Tag - } - return nil -} - -type CommitTag struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Sha string `protobuf:"bytes,2,opt,name=sha,proto3" json:"sha,omitempty"` - IsAnnotated bool `protobuf:"varint,3,opt,name=is_annotated,json=isAnnotated,proto3" json:"is_annotated,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"` - Tagger *Signature `protobuf:"bytes,6,opt,name=tagger,proto3" json:"tagger,omitempty"` - Commit *Commit `protobuf:"bytes,7,opt,name=commit,proto3" json:"commit,omitempty"` -} - -func (x *CommitTag) Reset() { - *x = CommitTag{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CommitTag) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CommitTag) ProtoMessage() {} - -func (x *CommitTag) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[22] - 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 CommitTag.ProtoReflect.Descriptor instead. -func (*CommitTag) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{22} -} - -func (x *CommitTag) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CommitTag) GetSha() string { - if x != nil { - return x.Sha - } - return "" -} - -func (x *CommitTag) GetIsAnnotated() bool { - if x != nil { - return x.IsAnnotated - } - return false -} - -func (x *CommitTag) GetTitle() string { - if x != nil { - return x.Title - } - return "" -} - -func (x *CommitTag) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *CommitTag) GetTagger() *Signature { - if x != nil { - return x.Tagger - } - return nil -} - -func (x *CommitTag) GetCommit() *Commit { - if x != nil { - return x.Commit - } - return nil -} - -type Commit struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Sha string `protobuf:"bytes,1,opt,name=sha,proto3" json:"sha,omitempty"` - Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` - Author *Signature `protobuf:"bytes,4,opt,name=author,proto3" json:"author,omitempty"` - Committer *Signature `protobuf:"bytes,5,opt,name=committer,proto3" json:"committer,omitempty"` -} - -func (x *Commit) Reset() { - *x = Commit{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Commit) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Commit) ProtoMessage() {} - -func (x *Commit) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[23] - 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 Commit.ProtoReflect.Descriptor instead. -func (*Commit) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{23} -} - -func (x *Commit) GetSha() string { - if x != nil { - return x.Sha - } - return "" -} - -func (x *Commit) GetTitle() string { - if x != nil { - return x.Title - } - return "" -} - -func (x *Commit) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *Commit) GetAuthor() *Signature { - if x != nil { - return x.Author - } - return nil -} - -func (x *Commit) GetCommitter() *Signature { - if x != nil { - return x.Committer - } - return nil -} - -type Signature struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Identity *Identity `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - When int64 `protobuf:"varint,2,opt,name=when,proto3" json:"when,omitempty"` -} - -func (x *Signature) Reset() { - *x = Signature{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Signature) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Signature) ProtoMessage() {} - -func (x *Signature) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[24] - 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 Signature.ProtoReflect.Descriptor instead. -func (*Signature) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{24} -} - -func (x *Signature) GetIdentity() *Identity { - if x != nil { - return x.Identity - } - return nil -} - -func (x *Signature) GetWhen() int64 { - if x != nil { - return x.When - } - return 0 -} - -type Identity struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` -} - -func (x *Identity) Reset() { - *x = Identity{} - if protoimpl.UnsafeEnabled { - mi := &file_repo_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Identity) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Identity) ProtoMessage() {} - -func (x *Identity) ProtoReflect() protoreflect.Message { - mi := &file_repo_proto_msgTypes[25] - 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 Identity.ProtoReflect.Descriptor instead. -func (*Identity) Descriptor() ([]byte, []int) { - return file_repo_proto_rawDescGZIP(), []int{25} -} - -func (x *Identity) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Identity) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - var File_repo_proto protoreflect.FileDescriptor var file_repo_proto_rawDesc = []byte{ @@ -1983,34 +1254,6 @@ var file_repo_proto_rawDesc = []byte{ 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, - 0x74, 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, 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, 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, @@ -2038,114 +1281,50 @@ var file_repo_proto_rawDesc = []byte{ 0x09, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 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, 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, 0x39, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x25, 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, 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, 0x3a, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x03, - 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0xd1, - 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 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, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, - 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x41, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x65, 0x64, 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, 0x26, 0x0a, 0x06, 0x74, 0x61, 0x67, 0x67, 0x65, 0x72, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x72, 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, 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, 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, - 0xc5, 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, 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, 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, + 0x2a, 0x52, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x54, 0x72, 0x65, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, + 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x10, 0x02, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x54, + 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53, 0x79, 0x6d, 0x6c, 0x69, + 0x6e, 0x6b, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x4d, 0x6f, 0x64, 0x65, 0x45, 0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, + 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x03, + 0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x32, 0xb1, 0x03, 0x0a, 0x11, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, + 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, + 0x01, 0x12, 0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, + 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, + 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x43, 0x0a, + 0x0c, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, + 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x13, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x27, 0x5a, 0x25, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, + 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, + 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2160,88 +1339,61 @@ func file_repo_proto_rawDescGZIP() []byte { return file_repo_proto_rawDescData } -var file_repo_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 26) +var file_repo_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_repo_proto_goTypes = []interface{}{ (TreeNodeType)(0), // 0: rpc.TreeNodeType (TreeNodeMode)(0), // 1: rpc.TreeNodeMode - (ListBranchesRequest_SortOption)(0), // 2: rpc.ListBranchesRequest.SortOption - (ListCommitTagsRequest_SortOption)(0), // 3: rpc.ListCommitTagsRequest.SortOption - (*CreateRepositoryRequest)(nil), // 4: rpc.CreateRepositoryRequest - (*CreateRepositoryRequestHeader)(nil), // 5: rpc.CreateRepositoryRequestHeader - (*CreateRepositoryResponse)(nil), // 6: rpc.CreateRepositoryResponse - (*GetTreeNodeRequest)(nil), // 7: rpc.GetTreeNodeRequest - (*GetTreeNodeResponse)(nil), // 8: rpc.GetTreeNodeResponse - (*ListTreeNodesRequest)(nil), // 9: rpc.ListTreeNodesRequest - (*ListTreeNodesResponse)(nil), // 10: rpc.ListTreeNodesResponse - (*TreeNode)(nil), // 11: rpc.TreeNode - (*ListCommitsRequest)(nil), // 12: rpc.ListCommitsRequest - (*ListCommitsResponse)(nil), // 13: rpc.ListCommitsResponse - (*ListCommitsResponseHeader)(nil), // 14: rpc.ListCommitsResponseHeader - (*ListBranchesRequest)(nil), // 15: rpc.ListBranchesRequest - (*ListBranchesResponse)(nil), // 16: rpc.ListBranchesResponse - (*Branch)(nil), // 17: rpc.Branch - (*GetBlobRequest)(nil), // 18: rpc.GetBlobRequest - (*GetBlobResponse)(nil), // 19: rpc.GetBlobResponse - (*Blob)(nil), // 20: rpc.Blob - (*GetSubmoduleRequest)(nil), // 21: rpc.GetSubmoduleRequest - (*GetSubmoduleResponse)(nil), // 22: rpc.GetSubmoduleResponse - (*Submodule)(nil), // 23: rpc.Submodule - (*ListCommitTagsRequest)(nil), // 24: rpc.ListCommitTagsRequest - (*ListCommitTagsResponse)(nil), // 25: rpc.ListCommitTagsResponse - (*CommitTag)(nil), // 26: rpc.CommitTag - (*Commit)(nil), // 27: rpc.Commit - (*Signature)(nil), // 28: rpc.Signature - (*Identity)(nil), // 29: rpc.Identity - (*FileUpload)(nil), // 30: rpc.FileUpload - (SortOrder)(0), // 31: rpc.SortOrder + (*CreateRepositoryRequest)(nil), // 2: rpc.CreateRepositoryRequest + (*CreateRepositoryRequestHeader)(nil), // 3: rpc.CreateRepositoryRequestHeader + (*CreateRepositoryResponse)(nil), // 4: rpc.CreateRepositoryResponse + (*GetTreeNodeRequest)(nil), // 5: rpc.GetTreeNodeRequest + (*GetTreeNodeResponse)(nil), // 6: rpc.GetTreeNodeResponse + (*ListTreeNodesRequest)(nil), // 7: rpc.ListTreeNodesRequest + (*ListTreeNodesResponse)(nil), // 8: rpc.ListTreeNodesResponse + (*TreeNode)(nil), // 9: rpc.TreeNode + (*ListCommitsRequest)(nil), // 10: rpc.ListCommitsRequest + (*ListCommitsResponse)(nil), // 11: rpc.ListCommitsResponse + (*ListCommitsResponseHeader)(nil), // 12: rpc.ListCommitsResponseHeader + (*GetBlobRequest)(nil), // 13: rpc.GetBlobRequest + (*GetBlobResponse)(nil), // 14: rpc.GetBlobResponse + (*Blob)(nil), // 15: rpc.Blob + (*GetSubmoduleRequest)(nil), // 16: rpc.GetSubmoduleRequest + (*GetSubmoduleResponse)(nil), // 17: rpc.GetSubmoduleResponse + (*Submodule)(nil), // 18: rpc.Submodule + (*FileUpload)(nil), // 19: rpc.FileUpload + (*Commit)(nil), // 20: rpc.Commit } var file_repo_proto_depIdxs = []int32{ - 5, // 0: rpc.CreateRepositoryRequest.header:type_name -> rpc.CreateRepositoryRequestHeader - 30, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload - 11, // 2: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode - 27, // 3: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit - 11, // 4: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode - 27, // 5: rpc.ListTreeNodesResponse.commit:type_name -> rpc.Commit + 3, // 0: rpc.CreateRepositoryRequest.header:type_name -> rpc.CreateRepositoryRequestHeader + 19, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload + 9, // 2: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode + 20, // 3: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit + 9, // 4: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode + 20, // 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 - 14, // 8: rpc.ListCommitsResponse.header:type_name -> rpc.ListCommitsResponseHeader - 27, // 9: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit - 2, // 10: rpc.ListBranchesRequest.sort:type_name -> rpc.ListBranchesRequest.SortOption - 31, // 11: rpc.ListBranchesRequest.order:type_name -> rpc.SortOrder - 17, // 12: rpc.ListBranchesResponse.branch:type_name -> rpc.Branch - 27, // 13: rpc.Branch.commit:type_name -> rpc.Commit - 20, // 14: rpc.GetBlobResponse.blob:type_name -> rpc.Blob - 23, // 15: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule - 3, // 16: rpc.ListCommitTagsRequest.sort:type_name -> rpc.ListCommitTagsRequest.SortOption - 31, // 17: rpc.ListCommitTagsRequest.order:type_name -> rpc.SortOrder - 26, // 18: rpc.ListCommitTagsResponse.tag:type_name -> rpc.CommitTag - 28, // 19: rpc.CommitTag.tagger:type_name -> rpc.Signature - 27, // 20: rpc.CommitTag.commit:type_name -> rpc.Commit - 28, // 21: rpc.Commit.author:type_name -> rpc.Signature - 28, // 22: rpc.Commit.committer:type_name -> rpc.Signature - 29, // 23: rpc.Signature.identity:type_name -> rpc.Identity - 4, // 24: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest - 7, // 25: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest - 9, // 26: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest - 21, // 27: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest - 18, // 28: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest - 12, // 29: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest - 15, // 30: rpc.RepositoryService.ListBranches:input_type -> rpc.ListBranchesRequest - 24, // 31: rpc.RepositoryService.ListCommitTags:input_type -> rpc.ListCommitTagsRequest - 6, // 32: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse - 8, // 33: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse - 10, // 34: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse - 22, // 35: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse - 19, // 36: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse - 13, // 37: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse - 16, // 38: rpc.RepositoryService.ListBranches:output_type -> rpc.ListBranchesResponse - 25, // 39: rpc.RepositoryService.ListCommitTags:output_type -> rpc.ListCommitTagsResponse - 32, // [32:40] is the sub-list for method output_type - 24, // [24:32] is the sub-list for method input_type - 24, // [24:24] is the sub-list for extension type_name - 24, // [24:24] is the sub-list for extension extendee - 0, // [0:24] is the sub-list for field type_name + 12, // 8: rpc.ListCommitsResponse.header:type_name -> rpc.ListCommitsResponseHeader + 20, // 9: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit + 15, // 10: rpc.GetBlobResponse.blob:type_name -> rpc.Blob + 18, // 11: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule + 2, // 12: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest + 5, // 13: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest + 7, // 14: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest + 16, // 15: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest + 13, // 16: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest + 10, // 17: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest + 4, // 18: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse + 6, // 19: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse + 8, // 20: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse + 17, // 21: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse + 14, // 22: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse + 11, // 23: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse + 18, // [18:24] is the sub-list for method output_type + 12, // [12:18] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_repo_proto_init() } @@ -2384,42 +1536,6 @@ func file_repo_proto_init() { } } file_repo_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListBranchesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_repo_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListBranchesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_repo_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Branch); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_repo_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetBlobRequest); i { case 0: return &v.state @@ -2431,7 +1547,7 @@ func file_repo_proto_init() { return nil } } - file_repo_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_repo_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetBlobResponse); i { case 0: return &v.state @@ -2443,7 +1559,7 @@ func file_repo_proto_init() { return nil } } - file_repo_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_repo_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Blob); i { case 0: return &v.state @@ -2455,7 +1571,7 @@ func file_repo_proto_init() { return nil } } - file_repo_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_repo_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetSubmoduleRequest); i { case 0: return &v.state @@ -2467,7 +1583,7 @@ func file_repo_proto_init() { return nil } } - file_repo_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_repo_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetSubmoduleResponse); i { case 0: return &v.state @@ -2479,7 +1595,7 @@ func file_repo_proto_init() { return nil } } - file_repo_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_repo_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Submodule); i { case 0: return &v.state @@ -2491,78 +1607,6 @@ func file_repo_proto_init() { return nil } } - file_repo_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListCommitTagsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_repo_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListCommitTagsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_repo_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommitTag); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_repo_proto_msgTypes[23].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_repo_proto_msgTypes[24].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_repo_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Identity); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } file_repo_proto_msgTypes[0].OneofWrappers = []interface{}{ (*CreateRepositoryRequest_Header)(nil), @@ -2577,8 +1621,8 @@ func file_repo_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_repo_proto_rawDesc, - NumEnums: 4, - NumMessages: 26, + NumEnums: 2, + NumMessages: 17, NumExtensions: 0, NumServices: 1, }, diff --git a/gitrpc/rpc/repo_grpc.pb.go b/gitrpc/rpc/repo_grpc.pb.go index b53b4225d..607231308 100644 --- a/gitrpc/rpc/repo_grpc.pb.go +++ b/gitrpc/rpc/repo_grpc.pb.go @@ -28,8 +28,6 @@ type RepositoryServiceClient interface { GetSubmodule(ctx context.Context, in *GetSubmoduleRequest, opts ...grpc.CallOption) (*GetSubmoduleResponse, error) GetBlob(ctx context.Context, in *GetBlobRequest, opts ...grpc.CallOption) (*GetBlobResponse, error) ListCommits(ctx context.Context, in *ListCommitsRequest, opts ...grpc.CallOption) (RepositoryService_ListCommitsClient, error) - ListBranches(ctx context.Context, in *ListBranchesRequest, opts ...grpc.CallOption) (RepositoryService_ListBranchesClient, error) - ListCommitTags(ctx context.Context, in *ListCommitTagsRequest, opts ...grpc.CallOption) (RepositoryService_ListCommitTagsClient, error) } type repositoryServiceClient struct { @@ -165,70 +163,6 @@ func (x *repositoryServiceListCommitsClient) Recv() (*ListCommitsResponse, error return m, nil } -func (c *repositoryServiceClient) ListBranches(ctx context.Context, in *ListBranchesRequest, opts ...grpc.CallOption) (RepositoryService_ListBranchesClient, error) { - stream, err := c.cc.NewStream(ctx, &RepositoryService_ServiceDesc.Streams[3], "/rpc.RepositoryService/ListBranches", opts...) - if err != nil { - return nil, err - } - x := &repositoryServiceListBranchesClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type RepositoryService_ListBranchesClient interface { - Recv() (*ListBranchesResponse, error) - grpc.ClientStream -} - -type repositoryServiceListBranchesClient struct { - grpc.ClientStream -} - -func (x *repositoryServiceListBranchesClient) Recv() (*ListBranchesResponse, error) { - m := new(ListBranchesResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *repositoryServiceClient) ListCommitTags(ctx context.Context, in *ListCommitTagsRequest, opts ...grpc.CallOption) (RepositoryService_ListCommitTagsClient, error) { - stream, err := c.cc.NewStream(ctx, &RepositoryService_ServiceDesc.Streams[4], "/rpc.RepositoryService/ListCommitTags", opts...) - if err != nil { - return nil, err - } - x := &repositoryServiceListCommitTagsClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type RepositoryService_ListCommitTagsClient interface { - Recv() (*ListCommitTagsResponse, error) - grpc.ClientStream -} - -type repositoryServiceListCommitTagsClient struct { - grpc.ClientStream -} - -func (x *repositoryServiceListCommitTagsClient) Recv() (*ListCommitTagsResponse, error) { - m := new(ListCommitTagsResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - // RepositoryServiceServer is the server API for RepositoryService service. // All implementations must embed UnimplementedRepositoryServiceServer // for forward compatibility @@ -239,8 +173,6 @@ type RepositoryServiceServer interface { GetSubmodule(context.Context, *GetSubmoduleRequest) (*GetSubmoduleResponse, error) GetBlob(context.Context, *GetBlobRequest) (*GetBlobResponse, error) ListCommits(*ListCommitsRequest, RepositoryService_ListCommitsServer) error - ListBranches(*ListBranchesRequest, RepositoryService_ListBranchesServer) error - ListCommitTags(*ListCommitTagsRequest, RepositoryService_ListCommitTagsServer) error mustEmbedUnimplementedRepositoryServiceServer() } @@ -266,12 +198,6 @@ func (UnimplementedRepositoryServiceServer) GetBlob(context.Context, *GetBlobReq func (UnimplementedRepositoryServiceServer) ListCommits(*ListCommitsRequest, RepositoryService_ListCommitsServer) error { return status.Errorf(codes.Unimplemented, "method ListCommits not implemented") } -func (UnimplementedRepositoryServiceServer) ListBranches(*ListBranchesRequest, RepositoryService_ListBranchesServer) error { - return status.Errorf(codes.Unimplemented, "method ListBranches not implemented") -} -func (UnimplementedRepositoryServiceServer) ListCommitTags(*ListCommitTagsRequest, RepositoryService_ListCommitTagsServer) error { - return status.Errorf(codes.Unimplemented, "method ListCommitTags not implemented") -} func (UnimplementedRepositoryServiceServer) mustEmbedUnimplementedRepositoryServiceServer() {} // UnsafeRepositoryServiceServer may be embedded to opt out of forward compatibility for this service. @@ -407,48 +333,6 @@ func (x *repositoryServiceListCommitsServer) Send(m *ListCommitsResponse) error return x.ServerStream.SendMsg(m) } -func _RepositoryService_ListBranches_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(ListBranchesRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RepositoryServiceServer).ListBranches(m, &repositoryServiceListBranchesServer{stream}) -} - -type RepositoryService_ListBranchesServer interface { - Send(*ListBranchesResponse) error - grpc.ServerStream -} - -type repositoryServiceListBranchesServer struct { - grpc.ServerStream -} - -func (x *repositoryServiceListBranchesServer) Send(m *ListBranchesResponse) error { - return x.ServerStream.SendMsg(m) -} - -func _RepositoryService_ListCommitTags_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(ListCommitTagsRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RepositoryServiceServer).ListCommitTags(m, &repositoryServiceListCommitTagsServer{stream}) -} - -type RepositoryService_ListCommitTagsServer interface { - Send(*ListCommitTagsResponse) error - grpc.ServerStream -} - -type repositoryServiceListCommitTagsServer struct { - grpc.ServerStream -} - -func (x *repositoryServiceListCommitTagsServer) Send(m *ListCommitTagsResponse) error { - return x.ServerStream.SendMsg(m) -} - // RepositoryService_ServiceDesc is the grpc.ServiceDesc for RepositoryService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -485,16 +369,6 @@ var RepositoryService_ServiceDesc = grpc.ServiceDesc{ Handler: _RepositoryService_ListCommits_Handler, ServerStreams: true, }, - { - StreamName: "ListBranches", - Handler: _RepositoryService_ListBranches_Handler, - ServerStreams: true, - }, - { - StreamName: "ListCommitTags", - Handler: _RepositoryService_ListCommitTags_Handler, - ServerStreams: true, - }, }, Metadata: "repo.proto", } diff --git a/gitrpc/rpc/shared.pb.go b/gitrpc/rpc/shared.pb.go index eb26ab31d..05660b808 100644 --- a/gitrpc/rpc/shared.pb.go +++ b/gitrpc/rpc/shared.pb.go @@ -251,6 +251,195 @@ func (x *Chunk) GetData() []byte { return nil } +type Commit struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sha string `protobuf:"bytes,1,opt,name=sha,proto3" json:"sha,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Author *Signature `protobuf:"bytes,4,opt,name=author,proto3" json:"author,omitempty"` + Committer *Signature `protobuf:"bytes,5,opt,name=committer,proto3" json:"committer,omitempty"` +} + +func (x *Commit) Reset() { + *x = Commit{} + if protoimpl.UnsafeEnabled { + mi := &file_shared_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Commit) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Commit) ProtoMessage() {} + +func (x *Commit) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[3] + 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 Commit.ProtoReflect.Descriptor instead. +func (*Commit) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{3} +} + +func (x *Commit) GetSha() string { + if x != nil { + return x.Sha + } + return "" +} + +func (x *Commit) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *Commit) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *Commit) GetAuthor() *Signature { + if x != nil { + return x.Author + } + return nil +} + +func (x *Commit) GetCommitter() *Signature { + if x != nil { + return x.Committer + } + return nil +} + +type Signature struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Identity *Identity `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + When int64 `protobuf:"varint,2,opt,name=when,proto3" json:"when,omitempty"` +} + +func (x *Signature) Reset() { + *x = Signature{} + if protoimpl.UnsafeEnabled { + mi := &file_shared_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Signature) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Signature) ProtoMessage() {} + +func (x *Signature) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[4] + 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 Signature.ProtoReflect.Descriptor instead. +func (*Signature) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{4} +} + +func (x *Signature) GetIdentity() *Identity { + if x != nil { + return x.Identity + } + return nil +} + +func (x *Signature) GetWhen() int64 { + if x != nil { + return x.When + } + return 0 +} + +type Identity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *Identity) Reset() { + *x = Identity{} + if protoimpl.UnsafeEnabled { + mi := &file_shared_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Identity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Identity) ProtoMessage() {} + +func (x *Identity) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[5] + 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 Identity.ProtoReflect.Descriptor instead. +func (*Identity) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{5} +} + +func (x *Identity) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Identity) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + var File_shared_proto protoreflect.FileDescriptor var file_shared_proto_rawDesc = []byte{ @@ -267,13 +456,31 @@ var file_shared_proto_rawDesc = []byte{ 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, 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, + 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 ( @@ -289,21 +496,27 @@ func file_shared_proto_rawDescGZIP() []byte { } var file_shared_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_shared_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_shared_proto_msgTypes = make([]protoimpl.MessageInfo, 6) 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 } var file_shared_proto_depIdxs = []int32{ 2, // 0: rpc.FileUpload.header:type_name -> rpc.FileUploadHeader 3, // 1: rpc.FileUpload.chunk:type_name -> rpc.Chunk - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 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 } func init() { file_shared_proto_init() } @@ -348,6 +561,42 @@ func file_shared_proto_init() { return nil } } + file_shared_proto_msgTypes[3].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[4].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[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Identity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_shared_proto_msgTypes[0].OneofWrappers = []interface{}{ (*FileUpload_Header)(nil), @@ -359,7 +608,7 @@ func file_shared_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_shared_proto_rawDesc, NumEnums: 1, - NumMessages: 3, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/gitrpc/server/server.go b/gitrpc/server/server.go index a568553cc..8deb79b7e 100644 --- a/gitrpc/server/server.go +++ b/gitrpc/server/server.go @@ -5,6 +5,10 @@ package server import ( + "errors" + "os" + "path/filepath" + "github.com/harness/gitness/gitrpc/internal/gitea" "github.com/harness/gitness/gitrpc/internal/service" "github.com/harness/gitness/gitrpc/internal/storage" @@ -16,6 +20,10 @@ import ( "google.golang.org/grpc" ) +const ( + repoSubdirName = "repos" +) + type Server struct { *grpc.Server Bind string @@ -23,6 +31,14 @@ type Server struct { // TODO: this wiring should be done by wire. func NewServer(bind string, gitRoot string) (*Server, error) { + // Create repos folder + reposRoot := filepath.Join(gitRoot, repoSubdirName) + if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) { + if err = os.MkdirAll(reposRoot, 0o700); err != nil { + return nil, err + } + } + // TODO: should be subdir of gitRoot? What is it being used for? setting.Git.HomePath = "home" adapter, err := gitea.New() @@ -32,16 +48,22 @@ func NewServer(bind string, gitRoot string) (*Server, error) { s := grpc.NewServer() store := storage.NewLocalStore() // initialize services - repoService, err := service.NewRepositoryService(adapter, store, gitRoot) + repoService, err := service.NewRepositoryService(adapter, store, reposRoot) if err != nil { return nil, err } - httpService, err := service.NewHTTPService(adapter, gitRoot) + // initialize services + refService, err := service.NewReferenceService(adapter, reposRoot) + if err != nil { + return nil, err + } + httpService, err := service.NewHTTPService(adapter, reposRoot) if err != nil { return nil, err } // register services rpc.RegisterRepositoryServiceServer(s, repoService) + rpc.RegisterReferenceServiceServer(s, refService) rpc.RegisterSmartHTTPServiceServer(s, httpService) return &Server{ diff --git a/gitrpc/smarthttp.go b/gitrpc/smarthttp.go index 8c3c72efd..3c0e7ff68 100644 --- a/gitrpc/smarthttp.go +++ b/gitrpc/smarthttp.go @@ -135,7 +135,7 @@ func (c *Client) ServicePack(ctx context.Context, w io.Writer, params *ServicePa break } if err != nil { - return fmt.Errorf("PostUploadPack() error receiving stream bytes: %w", err) + return processRPCErrorf(err, "PostUploadPack() error receiving stream bytes") } if response.GetData() == nil { return fmt.Errorf("PostUploadPack() data is nil") diff --git a/gitrpc/submodule.go b/gitrpc/submodule.go index 1a0004cf1..2c47a4e75 100644 --- a/gitrpc/submodule.go +++ b/gitrpc/submodule.go @@ -37,7 +37,7 @@ func (c *Client) GetSubmodule(ctx context.Context, params *GetSubmoduleParams) ( Path: params.Path, }) if err != nil { - return nil, err + return nil, processRPCErrorf(err, "failed to get submodule from server") } if resp.GetSubmodule() == nil { return nil, fmt.Errorf("rpc submodule is nil") diff --git a/gitrpc/tag.go b/gitrpc/tag.go index eba0e6cd8..b5912ef02 100644 --- a/gitrpc/tag.go +++ b/gitrpc/tag.go @@ -52,7 +52,7 @@ func (c *Client) ListCommitTags(ctx context.Context, params *ListCommitTagsParam return nil, ErrNoParamsProvided } - stream, err := c.repoService.ListCommitTags(ctx, &rpc.ListCommitTagsRequest{ + stream, err := c.refService.ListCommitTags(ctx, &rpc.ListCommitTagsRequest{ RepoUid: params.RepoUID, IncludeCommit: params.IncludeCommit, Query: params.Query, @@ -77,7 +77,7 @@ func (c *Client) ListCommitTags(ctx context.Context, params *ListCommitTagsParam break } if err != nil { - return nil, fmt.Errorf("received unexpected error from rpc: %w", err) + return nil, processRPCErrorf(err, "received unexpected error from server") } if next.GetTag() == nil { return nil, fmt.Errorf("expected tag message") @@ -92,7 +92,6 @@ func (c *Client) ListCommitTags(ctx context.Context, params *ListCommitTagsParam output.Tags = append(output.Tags, *tag) } - // TODO: is this needed? err = stream.CloseSend() if err != nil { return nil, fmt.Errorf("failed to close stream") diff --git a/gitrpc/tree.go b/gitrpc/tree.go index 02596592e..04cc91d28 100644 --- a/gitrpc/tree.go +++ b/gitrpc/tree.go @@ -88,7 +88,7 @@ func (c *Client) GetTreeNode(ctx context.Context, params *GetTreeNodeParams) (*G IncludeLatestCommit: params.IncludeLatestCommit, }) if err != nil { - return nil, err + return nil, processRPCErrorf(err, "failed to get tree node from server") } node, err := mapRPCTreeNode(resp.GetNode()) @@ -133,7 +133,7 @@ func (c *Client) ListTreeNodes(ctx context.Context, params *ListTreeNodeParams) break } if err != nil { - return nil, fmt.Errorf("received unexpected error from rpc: %w", err) + return nil, processRPCErrorf(err, "received unexpected error from server") } var node TreeNode diff --git a/internal/api/controller/repo/create_branch.go b/internal/api/controller/repo/create_branch.go new file mode 100644 index 000000000..8390a461c --- /dev/null +++ b/internal/api/controller/repo/create_branch.go @@ -0,0 +1,79 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + +package repo + +import ( + "context" + "fmt" + + "github.com/harness/gitness/gitrpc" + apiauth "github.com/harness/gitness/internal/api/auth" + "github.com/harness/gitness/internal/api/usererror" + "github.com/harness/gitness/internal/auth" + "github.com/harness/gitness/types/check" + "github.com/harness/gitness/types/enum" +) + +// CreateBranchInput used for branch creation apis. +type CreateBranchInput struct { + Name string `json:"name"` + + // Target is the commit (or points to the commit) the new branch will be pointing to. + // If no target is provided, the branch points to the same commit as the default branch of the repo. + Target *string `json:"target"` +} + +/* +* Creates a new branch for a repo. + */ +func (c *Controller) CreateBranch(ctx context.Context, session *auth.Session, + repoRef string, in *CreateBranchInput) (*Branch, error) { + repo, err := findRepoFromRef(ctx, c.repoStore, repoRef) + if err != nil { + return nil, err + } + + if err = apiauth.CheckRepo(ctx, c.authorizer, session, repo, enum.PermissionRepoEdit, false); err != nil { + return nil, err + } + + // set target to default branch in case no target was provided + if in.Target == nil || *in.Target == "" { + in.Target = &repo.DefaultBranch + } + + err = checkBranchName(in.Name) + if err != nil { + return nil, err + } + + rpcOut, err := c.gitRPCClient.CreateBranch(ctx, &gitrpc.CreateBranchParams{ + RepoUID: repo.GitUID, + BranchName: in.Name, + Target: *in.Target, + }) + if err != nil { + return nil, err + } + + branch, err := mapBranch(rpcOut.Branch) + if err != nil { + return nil, fmt.Errorf("failed to map branch: %w", err) + } + + return &branch, nil +} + +// checkBranchName does some basic branch validation +// We only ensure there are no control characters, the rest is up to git. +// TODO: Do we need some more validation here? +func checkBranchName(name string) error { + // fail fast on missing name + if len(name) == 0 { + return usererror.ErrBadRequest + } + + return check.ForControlCharacters(name) +} diff --git a/internal/api/controller/repo/delete_branch.go b/internal/api/controller/repo/delete_branch.go new file mode 100644 index 000000000..923d46e21 --- /dev/null +++ b/internal/api/controller/repo/delete_branch.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 repo + +import ( + "context" + + "github.com/harness/gitness/gitrpc" + apiauth "github.com/harness/gitness/internal/api/auth" + "github.com/harness/gitness/internal/api/usererror" + "github.com/harness/gitness/internal/auth" + "github.com/harness/gitness/types/enum" +) + +/* +* DeletePath deletes a repo branch. + */ +func (c *Controller) DeleteBranch(ctx context.Context, session *auth.Session, repoRef string, branchName string) error { + repo, err := findRepoFromRef(ctx, c.repoStore, repoRef) + if err != nil { + return err + } + + if err = apiauth.CheckRepo(ctx, c.authorizer, session, repo, enum.PermissionRepoEdit, false); err != nil { + return err + } + + // make sure user isn't deleting the default branch + // ASSUMPTION: lower layer calls explicit branch api + // and 'refs/heads/branch1' would fail if 'branch1' exists. + // TODO: Add functional test to ensure the scenario is covered! + if branchName == repo.DefaultBranch { + return usererror.ErrDefaultBranchCantBeDeleted + } + + err = c.gitRPCClient.DeleteBranch(ctx, &gitrpc.DeleteBranchParams{ + RepoUID: repo.GitUID, + BranchName: branchName, + }) + if err != nil { + return err + } + + return nil +} diff --git a/internal/api/controller/repo/get_content.go b/internal/api/controller/repo/get_content.go index fb5c42ac2..82a0bc4c0 100644 --- a/internal/api/controller/repo/get_content.go +++ b/internal/api/controller/repo/get_content.go @@ -13,10 +13,8 @@ import ( "github.com/harness/gitness/gitrpc" apiauth "github.com/harness/gitness/internal/api/auth" - "github.com/harness/gitness/internal/api/usererror" "github.com/harness/gitness/internal/auth" "github.com/harness/gitness/types/enum" - "github.com/rs/zerolog/log" ) const ( @@ -125,7 +123,6 @@ func (c *Controller) GetContent(ctx context.Context, session *auth.Session, repo gitRef = repo.DefaultBranch } - log := log.Ctx(ctx) treeNodeOutput, err := c.gitRPCClient.GetTreeNode(ctx, &gitrpc.GetTreeNodeParams{ RepoUID: repo.GitUID, GitREF: gitRef, @@ -133,11 +130,7 @@ func (c *Controller) GetContent(ctx context.Context, session *auth.Session, repo IncludeLatestCommit: includeLatestCommit, }) if err != nil { - // TODO: this should only return not found if it's an actual not found error. - // This requires gitrpc to also return notfound though! - log.Debug().Err(err). - Msgf("unable to find content for repo '%s', gitRef '%s' and path '%s'", repoRef, gitRef, repoPath) - return nil, usererror.ErrNotFound + return nil, err } info, err := mapToContentInfo(&treeNodeOutput.Node, treeNodeOutput.Commit) diff --git a/internal/api/handler/repo/create_branch.go b/internal/api/handler/repo/create_branch.go new file mode 100644 index 000000000..7f3558597 --- /dev/null +++ b/internal/api/handler/repo/create_branch.go @@ -0,0 +1,44 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + +package repo + +import ( + "encoding/json" + "net/http" + + "github.com/harness/gitness/internal/api/controller/repo" + "github.com/harness/gitness/internal/api/render" + "github.com/harness/gitness/internal/api/request" +) + +/* + * Writes json-encoded branch information to the http response body. + */ +func HandleCreateBranch(repoCtrl *repo.Controller) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + session, _ := request.AuthSessionFrom(ctx) + repoRef, err := request.GetRepoRefFromPath(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } + + in := new(repo.CreateBranchInput) + err = json.NewDecoder(r.Body).Decode(in) + if err != nil { + render.BadRequestf(w, "Invalid request body: %s.", err) + return + } + + branch, err := repoCtrl.CreateBranch(ctx, session, repoRef, in) + if err != nil { + render.TranslatedUserError(w, err) + return + } + + render.JSON(w, http.StatusOK, branch) + } +} diff --git a/internal/api/handler/repo/delete_branch.go b/internal/api/handler/repo/delete_branch.go new file mode 100644 index 000000000..65f426f1d --- /dev/null +++ b/internal/api/handler/repo/delete_branch.go @@ -0,0 +1,40 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + +package repo + +import ( + "net/http" + + "github.com/harness/gitness/internal/api/controller/repo" + "github.com/harness/gitness/internal/api/render" + "github.com/harness/gitness/internal/api/request" +) + +/* + * Deletes a given branch. + */ +func HandleDeleteBranch(repoCtrl *repo.Controller) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + session, _ := request.AuthSessionFrom(ctx) + repoRef, err := request.GetRepoRefFromPath(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } + branchName, err := request.GetRemainderFromPath(r) + if err != nil { + render.TranslatedUserError(w, err) + return + } + + err = repoCtrl.DeleteBranch(ctx, session, repoRef, branchName) + if err != nil { + render.TranslatedUserError(w, err) + } + + render.DeleteSuccessful(w) + } +} diff --git a/internal/api/render/render.go b/internal/api/render/render.go index d7f232786..e49da0395 100644 --- a/internal/api/render/render.go +++ b/internal/api/render/render.go @@ -27,6 +27,7 @@ func init() { // TranslatedUserError writes the translated user error of the provided error. func TranslatedUserError(w http.ResponseWriter, err error) { + log.Warn().Msgf("operation resulted in user facing error. Internal details: %s", err) UserError(w, usererror.Translate(err)) } diff --git a/internal/api/request/util.go b/internal/api/request/util.go index 3a4b2989a..c25df3478 100644 --- a/internal/api/request/util.go +++ b/internal/api/request/util.go @@ -111,6 +111,11 @@ func GetOptionalRemainderFromPath(r *http.Request) string { return PathParamOrEmpty(r, PathParamRemainder) } +// GetRemainderFromPath returns the remainder ("*") from the path or an an error if it doesn't exist. +func GetRemainderFromPath(r *http.Request) (string, error) { + return PathParamOrError(r, PathParamRemainder) +} + // ParseQuery extracts the query parameter from the url. func ParseQuery(r *http.Request) string { return r.FormValue(QueryParamQuery) diff --git a/internal/api/usererror/translate.go b/internal/api/usererror/translate.go index 92166d145..4aecf6d37 100644 --- a/internal/api/usererror/translate.go +++ b/internal/api/usererror/translate.go @@ -8,6 +8,7 @@ import ( "errors" "net/http" + "github.com/harness/gitness/gitrpc" apiauth "github.com/harness/gitness/internal/api/auth" "github.com/harness/gitness/internal/store" "github.com/harness/gitness/types/check" @@ -47,6 +48,14 @@ func Translate(err error) *Error { case errors.Is(err, store.ErrSpaceWithChildsCantBeDeleted): return ErrSpaceWithChildsCantBeDeleted + // gitrpc errors + case errors.Is(err, gitrpc.ErrAlreadyExists): + return ErrDuplicate + case errors.Is(err, gitrpc.ErrInvalidArgument): + return ErrBadRequest + case errors.Is(err, gitrpc.ErrNotFound): + return ErrNotFound + // unknown error default: log.Warn().Msgf("Unable to translate error: %s", err) diff --git a/internal/api/usererror/usererror.go b/internal/api/usererror/usererror.go index 325637a45..b271ee505 100644 --- a/internal/api/usererror/usererror.go +++ b/internal/api/usererror/usererror.go @@ -29,7 +29,7 @@ var ( ErrNoChange = New(http.StatusBadRequest, "No Change") // ErrDuplicate is returned when a resource already exits. - ErrDuplicate = New(http.StatusBadRequest, "Resource already exists") + ErrDuplicate = New(http.StatusConflict, "Resource already exists") // ErrPrimaryPathCantBeDeleted is returned when trying to delete a primary path. ErrPrimaryPathCantBeDeleted = New(http.StatusBadRequest, "The primary path of an object can't be deleted") @@ -44,6 +44,9 @@ var ( // still has child resources. ErrSpaceWithChildsCantBeDeleted = New(http.StatusBadRequest, "Space can't be deleted as it still contains child resources") + + // ErrDefaultBranchCantBeDeleted is returned if the user tries to delete the default branch of a repository. + ErrDefaultBranchCantBeDeleted = New(http.StatusBadRequest, "The default branch of a repository can't be deleted") ) // Error represents a json-encoded API error. diff --git a/internal/router/api.go b/internal/router/api.go index 60e18b82c..42e61fe04 100644 --- a/internal/router/api.go +++ b/internal/router/api.go @@ -168,6 +168,8 @@ func setupRepos(r chi.Router, repoCtrl *repo.Controller) { // branch operations r.Route("/branches", func(r chi.Router) { r.Get("/", handlerrepo.HandleListBranches(repoCtrl)) + r.Post("/", handlerrepo.HandleCreateBranch(repoCtrl)) + r.Delete("/*", handlerrepo.HandleDeleteBranch(repoCtrl)) }) // tags operations diff --git a/internal/store/database/util.go b/internal/store/database/util.go index a51c9faab..581c0292f 100644 --- a/internal/store/database/util.go +++ b/internal/store/database/util.go @@ -37,19 +37,24 @@ func offset(page, size int) int { return page * size } -// Logs the error and message, returns either the original error or a store equivalent if possible. +// Logs the error and message, returns either the provided message or a gitrpc equivalent if possible. +// Always logs the full message with error as warning. func processSQLErrorf(err error, format string, args ...interface{}) error { - // always log DB error (print formated message) - log.Debug().Msgf("%s %s", fmt.Sprintf(format, args...), err) + // create fallback error returned if we can't map it + fallbackErr := fmt.Errorf(format, args...) + + // always log internal error together with message. + log.Debug().Msgf("%v: [SQL] %v", fallbackErr, err) // If it's a known error, return converted error instead. - if errors.Is(err, sql.ErrNoRows) { + switch { + case errors.Is(err, sql.ErrNoRows): return store.ErrResourceNotFound - } else if isSQLUniqueConstraintError(err) { + case isSQLUniqueConstraintError(err): return store.ErrDuplicate + default: + return fallbackErr } - - return err } func isSQLUniqueConstraintError(original error) bool { diff --git a/types/check/common.go b/types/check/common.go index 57c72bdf9..664b3f01f 100644 --- a/types/check/common.go +++ b/types/check/common.go @@ -7,7 +7,6 @@ package check import ( "fmt" "regexp" - "strings" ) const ( @@ -26,7 +25,6 @@ var ( ErrDisplayNameLength = &ValidationError{ fmt.Sprintf("DisplayName has to be between %d and %d in length.", minDisplayNameLength, maxDisplayNameLength), } - ErrDisplayNameContainsInvalidASCII = &ValidationError{"DisplayName has to consist of valid ASCII characters."} ErrUIDLength = &ValidationError{ fmt.Sprintf("UID has to be between %d and %d in length.", @@ -39,6 +37,8 @@ var ( ErrEmailLen = &ValidationError{ fmt.Sprintf("Email address has to be within %d and %d characters", minEmailLength, maxEmailLength), } + + ErrInvalidCharacters = &ValidationError{"Input contains invalid characters."} ) // DisplayName checks the provided display name and returns an error if it isn't valid. @@ -48,16 +48,15 @@ func DisplayName(displayName string) error { return ErrDisplayNameLength } - // created sanitized string restricted to ASCII characters (without control characters). - sanitizedString := strings.Map(func(r rune) rune { - if r < 32 || r == 127 || r > 255 { - return -1 - } - return r - }, displayName) + return ForControlCharacters(displayName) +} - if len(sanitizedString) != len(displayName) { - return ErrDisplayNameContainsInvalidASCII +// ForControlCharacters ensures that there are no control characters in the provided string. +func ForControlCharacters(s string) error { + for _, r := range s { + if r < 32 || r == 127 { + return ErrInvalidCharacters + } } return nil