Added gitrpc.UpdateRef (#236)

This commit is contained in:
Marko Gaćeša 2023-01-20 17:06:35 +01:00 committed by GitHub
parent 6a7cc4e518
commit d6ce1bc762
14 changed files with 574 additions and 212 deletions

View File

@ -6,6 +6,8 @@ package gitrpc
import "github.com/harness/gitness/gitrpc/rpc" import "github.com/harness/gitness/gitrpc/rpc"
const NilSHA = "0000000000000000000000000000000000000000"
// ReadParams contains the base parameters for read operations. // ReadParams contains the base parameters for read operations.
type ReadParams struct { type ReadParams struct {
RepoUID string RepoUID string

51
gitrpc/enum/ref.go Normal file
View File

@ -0,0 +1,51 @@
// 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 enum
import "github.com/harness/gitness/gitrpc/rpc"
type RefType int
const (
RefTypeRaw RefType = iota
RefTypeBranch
RefTypeTag
RefTypePullReqHead
RefTypePullReqMerge
)
func RefFromRPC(t rpc.RefType) (RefType, bool) {
switch t {
case rpc.RefType_RefRaw:
return RefTypeRaw, true
case rpc.RefType_RefBranch:
return RefTypeBranch, true
case rpc.RefType_RefTag:
return RefTypeTag, true
case rpc.RefType_RefPullReqHead:
return RefTypePullReqHead, true
case rpc.RefType_RefPullReqMerge:
return RefTypePullReqMerge, true
default:
return 0, false
}
}
func RefToRPC(t RefType) (rpc.RefType, bool) {
switch t {
case RefTypeRaw:
return rpc.RefType_RefRaw, true
case RefTypeBranch:
return rpc.RefType_RefBranch, true
case RefTypeTag:
return rpc.RefType_RefTag, true
case RefTypePullReqHead:
return rpc.RefType_RefPullReqHead, true
case RefTypePullReqMerge:
return rpc.RefType_RefPullReqMerge, true
default:
return 0, false
}
}

View File

@ -18,7 +18,13 @@ type Interface interface {
CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error) CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error)
DeleteBranch(ctx context.Context, params *DeleteBranchParams) error DeleteBranch(ctx context.Context, params *DeleteBranchParams) error
ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error) ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error)
GetRef(ctx context.Context, params *GetRefParams) (*GetRefResponse, error)
GetRef(ctx context.Context, params GetRefParams) (GetRefResponse, error)
// UpdateRef creates, updates or deletes a git ref. If the OldValue is defined it must match the reference value
// prior to the call. To remove a ref use the zero ref as the NewValue. To require the creation of a new one and
// not update of an exiting one, set the zero ref as the OldValue.
UpdateRef(ctx context.Context, params UpdateRefParams) error
/* /*
* Commits service * Commits service

View File

@ -11,6 +11,7 @@ import (
"math" "math"
"strings" "strings"
"github.com/harness/gitness/gitrpc/enum"
"github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/internal/types"
gitea "code.gitea.io/gitea/modules/git" gitea "code.gitea.io/gitea/modules/git"
@ -126,14 +127,10 @@ func walkGiteaReferenceParser(parser *gitearef.Parser, handler types.WalkReferen
return nil return nil
} }
func (g Adapter) GetRef(ctx context.Context, repoPath, refName string, refType types.RefType) (string, error) { func (g Adapter) GetRef(ctx context.Context, repoPath, refName string, refType enum.RefType) (string, error) {
switch refType { refName, errRef := getRef(refName, refType)
case types.RefTypeBranch: if errRef != nil {
refName = gitea.BranchPrefix + refName return "", errRef
case types.RefTypeTag:
refName = gitea.TagPrefix + refName
default:
return "", types.ErrInvalidArgument
} }
cmd := gitea.NewCommand(ctx, "show-ref", "--verify", "-s", "--", refName) cmd := gitea.NewCommand(ctx, "show-ref", "--verify", "-s", "--", refName)
@ -149,3 +146,55 @@ func (g Adapter) GetRef(ctx context.Context, repoPath, refName string, refType t
return strings.TrimSpace(stdout), nil return strings.TrimSpace(stdout), nil
} }
func (g Adapter) UpdateRef(ctx context.Context,
repoPath, refName string, refType enum.RefType,
newValue, oldValue string,
) error {
refName, errRef := getRef(refName, refType)
if errRef != nil {
return errRef
}
args := make([]string, 0, 4)
args = append(args, "update-ref", refName, newValue)
if oldValue != "" {
args = append(args, oldValue)
}
cmd := gitea.NewCommand(ctx, args...)
_, _, err := cmd.RunStdString(&gitea.RunOpts{
Dir: repoPath,
})
if err != nil {
if err.IsExitCode(128) {
return types.ErrNotFound
}
return err
}
return nil
}
func getRef(refName string, refType enum.RefType) (string, error) {
const (
refPullReqPrefix = "refs/pullreq/"
refPullReqHeadSuffix = "/head"
refPullReqMergeSuffix = "/merge"
)
switch refType {
case enum.RefTypeRaw:
return refName, nil
case enum.RefTypeBranch:
return gitea.BranchPrefix + refName, nil
case enum.RefTypeTag:
return gitea.TagPrefix + refName, nil
case enum.RefTypePullReqHead:
return refPullReqPrefix + refName + refPullReqHeadSuffix, nil
case enum.RefTypePullReqMerge:
return refPullReqPrefix + refName + refPullReqMergeSuffix, nil
default:
return "", types.ErrInvalidArgument
}
}

View File

@ -8,6 +8,7 @@ import (
"context" "context"
"io" "io"
"github.com/harness/gitness/gitrpc/enum"
"github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/internal/types"
) )
@ -39,7 +40,8 @@ type GitAdapter interface {
GetBranch(ctx context.Context, repoPath string, branchName string) (*types.Branch, error) GetBranch(ctx context.Context, repoPath string, branchName string) (*types.Branch, error)
GetCommitDivergences(ctx context.Context, repoPath string, GetCommitDivergences(ctx context.Context, repoPath string,
requests []types.CommitDivergenceRequest, max int32) ([]types.CommitDivergence, error) requests []types.CommitDivergenceRequest, max int32) ([]types.CommitDivergence, error)
GetRef(ctx context.Context, repoPath string, name string, refType types.RefType) (string, error) GetRef(ctx context.Context, repoPath string, name string, refType enum.RefType) (string, error)
UpdateRef(ctx context.Context, repoPath, refName string, refType enum.RefType, newValue, oldValue string) error
CreateTemporaryRepoForPR(ctx context.Context, reposTempPath string, pr *types.PullRequest) (string, error) CreateTemporaryRepoForPR(ctx context.Context, reposTempPath string, pr *types.PullRequest) (string, error)
Merge(ctx context.Context, pr *types.PullRequest, mergeMethod string, trackingBranch string, Merge(ctx context.Context, pr *types.PullRequest, mergeMethod string, trackingBranch string,
tmpBasePath string, mergeMsg string, env []string) error tmpBasePath string, mergeMsg string, env []string) error

View File

@ -10,6 +10,7 @@ import (
"math" "math"
"strings" "strings"
"github.com/harness/gitness/gitrpc/enum"
"github.com/harness/gitness/gitrpc/internal/types" "github.com/harness/gitness/gitrpc/internal/types"
"github.com/harness/gitness/gitrpc/rpc" "github.com/harness/gitness/gitrpc/rpc"
@ -178,24 +179,19 @@ func wrapInstructorWithOptionalPagination(inner types.WalkReferencesInstructor,
} }
func (s ReferenceService) GetRef(ctx context.Context, func (s ReferenceService) GetRef(ctx context.Context,
request *rpc.GetRefRequest) (*rpc.GetRefResponse, error) { request *rpc.GetRefRequest,
base := request.GetBase() ) (*rpc.GetRefResponse, error) {
if base == nil { if request.Base == nil {
return nil, types.ErrBaseCannotBeEmpty return nil, types.ErrBaseCannotBeEmpty
} }
repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid()) refType, ok := enum.RefFromRPC(request.GetRefType())
if !ok {
var refType types.RefType return nil, status.Error(codes.InvalidArgument, "invalid value of RefType argument")
switch request.RefType {
case rpc.GetRefRequest_Branch:
refType = types.RefTypeBranch
case rpc.GetRefRequest_Tag:
refType = types.RefTypeTag
default:
return nil, status.Error(codes.InvalidArgument, "invalid value of refType argument")
} }
repoPath := getFullPathForRepo(s.reposRoot, request.Base.GetRepoUid())
sha, err := s.adapter.GetRef(ctx, repoPath, request.RefName, refType) sha, err := s.adapter.GetRef(ctx, repoPath, request.RefName, refType)
if err != nil { if err != nil {
return nil, err return nil, err
@ -203,3 +199,25 @@ func (s ReferenceService) GetRef(ctx context.Context,
return &rpc.GetRefResponse{Sha: sha}, nil return &rpc.GetRefResponse{Sha: sha}, nil
} }
func (s ReferenceService) UpdateRef(ctx context.Context,
request *rpc.UpdateRefRequest,
) (*rpc.UpdateRefResponse, error) {
if request.Base == nil {
return nil, types.ErrBaseCannotBeEmpty
}
refType, ok := enum.RefFromRPC(request.GetRefType())
if !ok {
return nil, status.Error(codes.InvalidArgument, "invalid value of RefType argument")
}
repoPath := getFullPathForRepo(s.reposRoot, request.Base.GetRepoUid())
err := s.adapter.UpdateRef(ctx, repoPath, request.RefName, refType, request.NewValue, request.OldValue)
if err != nil {
return nil, err
}
return &rpc.UpdateRefResponse{}, nil
}

View File

@ -80,13 +80,6 @@ func ParseGitReferenceField(f string) (GitReferenceField, error) {
} }
} }
type RefType int
const (
RefTypeBranch RefType = iota
RefTypeTag
)
type WalkInstruction int type WalkInstruction int
const ( const (

View File

@ -11,6 +11,7 @@ service ReferenceService {
rpc ListBranches(ListBranchesRequest) returns (stream ListBranchesResponse); rpc ListBranches(ListBranchesRequest) returns (stream ListBranchesResponse);
rpc ListCommitTags(ListCommitTagsRequest) returns (stream ListCommitTagsResponse); rpc ListCommitTags(ListCommitTagsRequest) returns (stream ListCommitTagsResponse);
rpc GetRef(GetRefRequest) returns (GetRefResponse); rpc GetRef(GetRefRequest) returns (GetRefResponse);
rpc UpdateRef(UpdateRefRequest) returns (UpdateRefResponse);
} }
message CreateBranchRequest { message CreateBranchRequest {
@ -89,12 +90,15 @@ message CommitTag {
Commit commit = 7; Commit commit = 7;
} }
enum RefType {
RefRaw = 0;
RefBranch = 1;
RefTag = 2;
RefPullReqHead = 3;
RefPullReqMerge = 4;
}
message GetRefRequest { message GetRefRequest {
enum RefType {
Branch = 0;
Tag = 1;
}
ReadRequest base = 1; ReadRequest base = 1;
string ref_name = 2; string ref_name = 2;
RefType ref_type = 3; RefType ref_type = 3;
@ -103,3 +107,13 @@ message GetRefRequest {
message GetRefResponse { message GetRefResponse {
string sha = 1; string sha = 1;
} }
message UpdateRefRequest {
WriteRequest base = 1;
string ref_name = 2;
RefType ref_type = 3;
string new_value = 4;
string old_value = 5;
}
message UpdateRefResponse {}

View File

@ -7,42 +7,27 @@ package gitrpc
import ( import (
"context" "context"
"github.com/harness/gitness/gitrpc/enum"
"github.com/harness/gitness/gitrpc/rpc" "github.com/harness/gitness/gitrpc/rpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
type RefType int
const (
RefTypeBranch RefType = iota
RefTypeTag
)
type GetRefParams struct { type GetRefParams struct {
ReadParams ReadParams
Name string Name string
Type RefType Type enum.RefType
} }
type GetRefResponse struct { type GetRefResponse struct {
SHA string SHA string
} }
func (c *Client) GetRef(ctx context.Context, params *GetRefParams) (*GetRefResponse, error) { func (c *Client) GetRef(ctx context.Context, params GetRefParams) (GetRefResponse, error) {
if params == nil { refType, isOk := enum.RefToRPC(params.Type)
return nil, ErrNoParamsProvided if !isOk {
} return GetRefResponse{}, ErrInvalidArgument
var refType rpc.GetRefRequest_RefType
switch params.Type {
case RefTypeBranch:
refType = rpc.GetRefRequest_Branch
case RefTypeTag:
refType = rpc.GetRefRequest_Tag
default:
return nil, ErrInvalidArgument
} }
result, err := c.refService.GetRef(ctx, &rpc.GetRefRequest{ result, err := c.refService.GetRef(ctx, &rpc.GetRefRequest{
@ -51,13 +36,36 @@ func (c *Client) GetRef(ctx context.Context, params *GetRefParams) (*GetRefRespo
RefType: refType, RefType: refType,
}) })
if s, ok := status.FromError(err); err != nil && ok && s.Code() == codes.NotFound { if s, ok := status.FromError(err); err != nil && ok && s.Code() == codes.NotFound {
return nil, ErrNotFound return GetRefResponse{}, ErrNotFound
}
if err != nil {
return nil, err
} }
return &GetRefResponse{ return GetRefResponse{SHA: result.Sha}, nil
SHA: result.Sha, }
}, nil
type UpdateRefParams struct {
WriteParams
Name string
Type enum.RefType
NewValue string
OldValue string
}
func (c *Client) UpdateRef(ctx context.Context, params UpdateRefParams) error {
refType, isOk := enum.RefToRPC(params.Type)
if !isOk {
return ErrInvalidArgument
}
_, err := c.refService.UpdateRef(ctx, &rpc.UpdateRefRequest{
Base: mapToRPCWriteRequest(params.WriteParams),
RefName: params.Name,
RefType: refType,
NewValue: params.NewValue,
OldValue: params.OldValue,
})
if s, ok := status.FromError(err); err != nil && ok && s.Code() == codes.NotFound {
return ErrNotFound
}
return err
} }

View File

@ -20,6 +20,61 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type RefType int32
const (
RefType_RefRaw RefType = 0
RefType_RefBranch RefType = 1
RefType_RefTag RefType = 2
RefType_RefPullReqHead RefType = 3
RefType_RefPullReqMerge RefType = 4
)
// Enum value maps for RefType.
var (
RefType_name = map[int32]string{
0: "RefRaw",
1: "RefBranch",
2: "RefTag",
3: "RefPullReqHead",
4: "RefPullReqMerge",
}
RefType_value = map[string]int32{
"RefRaw": 0,
"RefBranch": 1,
"RefTag": 2,
"RefPullReqHead": 3,
"RefPullReqMerge": 4,
}
)
func (x RefType) Enum() *RefType {
p := new(RefType)
*p = x
return p
}
func (x RefType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (RefType) Descriptor() protoreflect.EnumDescriptor {
return file_ref_proto_enumTypes[0].Descriptor()
}
func (RefType) Type() protoreflect.EnumType {
return &file_ref_proto_enumTypes[0]
}
func (x RefType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use RefType.Descriptor instead.
func (RefType) EnumDescriptor() ([]byte, []int) {
return file_ref_proto_rawDescGZIP(), []int{0}
}
type ListBranchesRequest_SortOption int32 type ListBranchesRequest_SortOption int32
const ( const (
@ -53,11 +108,11 @@ func (x ListBranchesRequest_SortOption) String() string {
} }
func (ListBranchesRequest_SortOption) Descriptor() protoreflect.EnumDescriptor { func (ListBranchesRequest_SortOption) Descriptor() protoreflect.EnumDescriptor {
return file_ref_proto_enumTypes[0].Descriptor() return file_ref_proto_enumTypes[1].Descriptor()
} }
func (ListBranchesRequest_SortOption) Type() protoreflect.EnumType { func (ListBranchesRequest_SortOption) Type() protoreflect.EnumType {
return &file_ref_proto_enumTypes[0] return &file_ref_proto_enumTypes[1]
} }
func (x ListBranchesRequest_SortOption) Number() protoreflect.EnumNumber { func (x ListBranchesRequest_SortOption) Number() protoreflect.EnumNumber {
@ -102,11 +157,11 @@ func (x ListCommitTagsRequest_SortOption) String() string {
} }
func (ListCommitTagsRequest_SortOption) Descriptor() protoreflect.EnumDescriptor { func (ListCommitTagsRequest_SortOption) Descriptor() protoreflect.EnumDescriptor {
return file_ref_proto_enumTypes[1].Descriptor() return file_ref_proto_enumTypes[2].Descriptor()
} }
func (ListCommitTagsRequest_SortOption) Type() protoreflect.EnumType { func (ListCommitTagsRequest_SortOption) Type() protoreflect.EnumType {
return &file_ref_proto_enumTypes[1] return &file_ref_proto_enumTypes[2]
} }
func (x ListCommitTagsRequest_SortOption) Number() protoreflect.EnumNumber { func (x ListCommitTagsRequest_SortOption) Number() protoreflect.EnumNumber {
@ -118,52 +173,6 @@ func (ListCommitTagsRequest_SortOption) EnumDescriptor() ([]byte, []int) {
return file_ref_proto_rawDescGZIP(), []int{7, 0} return file_ref_proto_rawDescGZIP(), []int{7, 0}
} }
type GetRefRequest_RefType int32
const (
GetRefRequest_Branch GetRefRequest_RefType = 0
GetRefRequest_Tag GetRefRequest_RefType = 1
)
// Enum value maps for GetRefRequest_RefType.
var (
GetRefRequest_RefType_name = map[int32]string{
0: "Branch",
1: "Tag",
}
GetRefRequest_RefType_value = map[string]int32{
"Branch": 0,
"Tag": 1,
}
)
func (x GetRefRequest_RefType) Enum() *GetRefRequest_RefType {
p := new(GetRefRequest_RefType)
*p = x
return p
}
func (x GetRefRequest_RefType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (GetRefRequest_RefType) Descriptor() protoreflect.EnumDescriptor {
return file_ref_proto_enumTypes[2].Descriptor()
}
func (GetRefRequest_RefType) Type() protoreflect.EnumType {
return &file_ref_proto_enumTypes[2]
}
func (x GetRefRequest_RefType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use GetRefRequest_RefType.Descriptor instead.
func (GetRefRequest_RefType) EnumDescriptor() ([]byte, []int) {
return file_ref_proto_rawDescGZIP(), []int{10, 0}
}
type CreateBranchRequest struct { type CreateBranchRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -831,9 +840,9 @@ type GetRefRequest struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"`
RefName string `protobuf:"bytes,2,opt,name=ref_name,json=refName,proto3" json:"ref_name,omitempty"` RefName string `protobuf:"bytes,2,opt,name=ref_name,json=refName,proto3" json:"ref_name,omitempty"`
RefType GetRefRequest_RefType `protobuf:"varint,3,opt,name=ref_type,json=refType,proto3,enum=rpc.GetRefRequest_RefType" json:"ref_type,omitempty"` RefType RefType `protobuf:"varint,3,opt,name=ref_type,json=refType,proto3,enum=rpc.RefType" json:"ref_type,omitempty"`
} }
func (x *GetRefRequest) Reset() { func (x *GetRefRequest) Reset() {
@ -882,11 +891,11 @@ func (x *GetRefRequest) GetRefName() string {
return "" return ""
} }
func (x *GetRefRequest) GetRefType() GetRefRequest_RefType { func (x *GetRefRequest) GetRefType() RefType {
if x != nil { if x != nil {
return x.RefType return x.RefType
} }
return GetRefRequest_Branch return RefType_RefRaw
} }
type GetRefResponse struct { type GetRefResponse struct {
@ -936,6 +945,123 @@ func (x *GetRefResponse) GetSha() string {
return "" return ""
} }
type UpdateRefRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Base *WriteRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"`
RefName string `protobuf:"bytes,2,opt,name=ref_name,json=refName,proto3" json:"ref_name,omitempty"`
RefType RefType `protobuf:"varint,3,opt,name=ref_type,json=refType,proto3,enum=rpc.RefType" json:"ref_type,omitempty"`
NewValue string `protobuf:"bytes,4,opt,name=new_value,json=newValue,proto3" json:"new_value,omitempty"`
OldValue string `protobuf:"bytes,5,opt,name=old_value,json=oldValue,proto3" json:"old_value,omitempty"`
}
func (x *UpdateRefRequest) Reset() {
*x = UpdateRefRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_ref_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateRefRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateRefRequest) ProtoMessage() {}
func (x *UpdateRefRequest) ProtoReflect() protoreflect.Message {
mi := &file_ref_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 UpdateRefRequest.ProtoReflect.Descriptor instead.
func (*UpdateRefRequest) Descriptor() ([]byte, []int) {
return file_ref_proto_rawDescGZIP(), []int{12}
}
func (x *UpdateRefRequest) GetBase() *WriteRequest {
if x != nil {
return x.Base
}
return nil
}
func (x *UpdateRefRequest) GetRefName() string {
if x != nil {
return x.RefName
}
return ""
}
func (x *UpdateRefRequest) GetRefType() RefType {
if x != nil {
return x.RefType
}
return RefType_RefRaw
}
func (x *UpdateRefRequest) GetNewValue() string {
if x != nil {
return x.NewValue
}
return ""
}
func (x *UpdateRefRequest) GetOldValue() string {
if x != nil {
return x.OldValue
}
return ""
}
type UpdateRefResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *UpdateRefResponse) Reset() {
*x = UpdateRefResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_ref_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateRefResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateRefResponse) ProtoMessage() {}
func (x *UpdateRefResponse) ProtoReflect() protoreflect.Message {
mi := &file_ref_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 UpdateRefResponse.ProtoReflect.Descriptor instead.
func (*UpdateRefResponse) Descriptor() ([]byte, []int) {
return file_ref_proto_rawDescGZIP(), []int{13}
}
var File_ref_proto protoreflect.FileDescriptor var File_ref_proto protoreflect.FileDescriptor
var file_ref_proto_rawDesc = []byte{ var file_ref_proto_rawDesc = []byte{
@ -1027,45 +1153,65 @@ var file_ref_proto_rawDesc = []byte{
0x70, 0x63, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x06, 0x74, 0x61, 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, 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, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69,
0x74, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x22, 0xa7, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x22, 0x79, 0x0a, 0x0d, 0x47, 0x65, 0x74,
0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61,
0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52,
0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65,
0x65, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01,
0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x66, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x66, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x08, 0x72,
0x72, 0x65, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x65, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x72, 0x65, 0x66,
0x73, 0x74, 0x2e, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x72, 0x65, 0x66, 0x54, 0x54, 0x79, 0x70, 0x65, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65,
0x79, 0x70, 0x65, 0x22, 0x1e, 0x0a, 0x07, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20,
0x0a, 0x06, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x61, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x22, 0xb7, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64,
0x67, 0x10, 0x01, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x73, 0x61, 0x74, 0x65, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x72, 0x70,
0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x32, 0xe3, 0x02, 0x0a, 0x10, 0x52, 0x65, 0x66, 0x65, 0x63, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04,
0x72, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x6e, 0x61, 0x6d, 0x65,
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x18, 0x2e, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x66, 0x4e, 0x61, 0x6d, 0x65, 0x12,
0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x27, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x0e, 0x32, 0x0c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x52,
0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x07, 0x72, 0x65, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f,
0x65, 0x12, 0x43, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77,
0x68, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c,
0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, 0x6c,
0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x75, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x66, 0x52,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x59, 0x0a, 0x07, 0x52, 0x65, 0x66, 0x54, 0x79,
0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x52, 0x65, 0x66, 0x52, 0x61, 0x77, 0x10, 0x00, 0x12, 0x0d,
0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x0a, 0x09, 0x52, 0x65, 0x66, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x10, 0x01, 0x12, 0x0a, 0x0a,
0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x06, 0x52, 0x65, 0x66, 0x54, 0x61, 0x67, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x52, 0x65, 0x66,
0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x4b, 0x0a, 0x50, 0x75, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x48, 0x65, 0x61, 0x64, 0x10, 0x03, 0x12, 0x13, 0x0a,
0x0e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x0f, 0x52, 0x65, 0x66, 0x50, 0x75, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x4d, 0x65, 0x72, 0x67, 0x65,
0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x32, 0x9f, 0x03, 0x0a, 0x10, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65,
0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x70, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74,
0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x06, 0x47, 0x65, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x52, 0x65, 0x66, 0x12, 0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x72,
0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0c,
0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x18, 0x2e, 0x72,
0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52,
0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c,
0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x65, 0x74, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x45, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65,
0x73, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e,
0x63, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x4b, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x12,
0x12, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x66,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x52, 0x65, 0x66, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x52, 0x65, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x66, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65,
0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -1081,11 +1227,11 @@ func file_ref_proto_rawDescGZIP() []byte {
} }
var file_ref_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_ref_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_ref_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_ref_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_ref_proto_goTypes = []interface{}{ var file_ref_proto_goTypes = []interface{}{
(ListBranchesRequest_SortOption)(0), // 0: rpc.ListBranchesRequest.SortOption (RefType)(0), // 0: rpc.RefType
(ListCommitTagsRequest_SortOption)(0), // 1: rpc.ListCommitTagsRequest.SortOption (ListBranchesRequest_SortOption)(0), // 1: rpc.ListBranchesRequest.SortOption
(GetRefRequest_RefType)(0), // 2: rpc.GetRefRequest.RefType (ListCommitTagsRequest_SortOption)(0), // 2: rpc.ListCommitTagsRequest.SortOption
(*CreateBranchRequest)(nil), // 3: rpc.CreateBranchRequest (*CreateBranchRequest)(nil), // 3: rpc.CreateBranchRequest
(*CreateBranchResponse)(nil), // 4: rpc.CreateBranchResponse (*CreateBranchResponse)(nil), // 4: rpc.CreateBranchResponse
(*DeleteBranchRequest)(nil), // 5: rpc.DeleteBranchRequest (*DeleteBranchRequest)(nil), // 5: rpc.DeleteBranchRequest
@ -1098,44 +1244,50 @@ var file_ref_proto_goTypes = []interface{}{
(*CommitTag)(nil), // 12: rpc.CommitTag (*CommitTag)(nil), // 12: rpc.CommitTag
(*GetRefRequest)(nil), // 13: rpc.GetRefRequest (*GetRefRequest)(nil), // 13: rpc.GetRefRequest
(*GetRefResponse)(nil), // 14: rpc.GetRefResponse (*GetRefResponse)(nil), // 14: rpc.GetRefResponse
(*WriteRequest)(nil), // 15: rpc.WriteRequest (*UpdateRefRequest)(nil), // 15: rpc.UpdateRefRequest
(*ReadRequest)(nil), // 16: rpc.ReadRequest (*UpdateRefResponse)(nil), // 16: rpc.UpdateRefResponse
(SortOrder)(0), // 17: rpc.SortOrder (*WriteRequest)(nil), // 17: rpc.WriteRequest
(*Commit)(nil), // 18: rpc.Commit (*ReadRequest)(nil), // 18: rpc.ReadRequest
(*Signature)(nil), // 19: rpc.Signature (SortOrder)(0), // 19: rpc.SortOrder
(*Commit)(nil), // 20: rpc.Commit
(*Signature)(nil), // 21: rpc.Signature
} }
var file_ref_proto_depIdxs = []int32{ var file_ref_proto_depIdxs = []int32{
15, // 0: rpc.CreateBranchRequest.base:type_name -> rpc.WriteRequest 17, // 0: rpc.CreateBranchRequest.base:type_name -> rpc.WriteRequest
9, // 1: rpc.CreateBranchResponse.branch:type_name -> rpc.Branch 9, // 1: rpc.CreateBranchResponse.branch:type_name -> rpc.Branch
15, // 2: rpc.DeleteBranchRequest.base:type_name -> rpc.WriteRequest 17, // 2: rpc.DeleteBranchRequest.base:type_name -> rpc.WriteRequest
16, // 3: rpc.ListBranchesRequest.base:type_name -> rpc.ReadRequest 18, // 3: rpc.ListBranchesRequest.base:type_name -> rpc.ReadRequest
0, // 4: rpc.ListBranchesRequest.sort:type_name -> rpc.ListBranchesRequest.SortOption 1, // 4: rpc.ListBranchesRequest.sort:type_name -> rpc.ListBranchesRequest.SortOption
17, // 5: rpc.ListBranchesRequest.order:type_name -> rpc.SortOrder 19, // 5: rpc.ListBranchesRequest.order:type_name -> rpc.SortOrder
9, // 6: rpc.ListBranchesResponse.branch:type_name -> rpc.Branch 9, // 6: rpc.ListBranchesResponse.branch:type_name -> rpc.Branch
18, // 7: rpc.Branch.commit:type_name -> rpc.Commit 20, // 7: rpc.Branch.commit:type_name -> rpc.Commit
16, // 8: rpc.ListCommitTagsRequest.base:type_name -> rpc.ReadRequest 18, // 8: rpc.ListCommitTagsRequest.base:type_name -> rpc.ReadRequest
1, // 9: rpc.ListCommitTagsRequest.sort:type_name -> rpc.ListCommitTagsRequest.SortOption 2, // 9: rpc.ListCommitTagsRequest.sort:type_name -> rpc.ListCommitTagsRequest.SortOption
17, // 10: rpc.ListCommitTagsRequest.order:type_name -> rpc.SortOrder 19, // 10: rpc.ListCommitTagsRequest.order:type_name -> rpc.SortOrder
12, // 11: rpc.ListCommitTagsResponse.tag:type_name -> rpc.CommitTag 12, // 11: rpc.ListCommitTagsResponse.tag:type_name -> rpc.CommitTag
19, // 12: rpc.CommitTag.tagger:type_name -> rpc.Signature 21, // 12: rpc.CommitTag.tagger:type_name -> rpc.Signature
18, // 13: rpc.CommitTag.commit:type_name -> rpc.Commit 20, // 13: rpc.CommitTag.commit:type_name -> rpc.Commit
16, // 14: rpc.GetRefRequest.base:type_name -> rpc.ReadRequest 18, // 14: rpc.GetRefRequest.base:type_name -> rpc.ReadRequest
2, // 15: rpc.GetRefRequest.ref_type:type_name -> rpc.GetRefRequest.RefType 0, // 15: rpc.GetRefRequest.ref_type:type_name -> rpc.RefType
3, // 16: rpc.ReferenceService.CreateBranch:input_type -> rpc.CreateBranchRequest 17, // 16: rpc.UpdateRefRequest.base:type_name -> rpc.WriteRequest
5, // 17: rpc.ReferenceService.DeleteBranch:input_type -> rpc.DeleteBranchRequest 0, // 17: rpc.UpdateRefRequest.ref_type:type_name -> rpc.RefType
7, // 18: rpc.ReferenceService.ListBranches:input_type -> rpc.ListBranchesRequest 3, // 18: rpc.ReferenceService.CreateBranch:input_type -> rpc.CreateBranchRequest
10, // 19: rpc.ReferenceService.ListCommitTags:input_type -> rpc.ListCommitTagsRequest 5, // 19: rpc.ReferenceService.DeleteBranch:input_type -> rpc.DeleteBranchRequest
13, // 20: rpc.ReferenceService.GetRef:input_type -> rpc.GetRefRequest 7, // 20: rpc.ReferenceService.ListBranches:input_type -> rpc.ListBranchesRequest
4, // 21: rpc.ReferenceService.CreateBranch:output_type -> rpc.CreateBranchResponse 10, // 21: rpc.ReferenceService.ListCommitTags:input_type -> rpc.ListCommitTagsRequest
6, // 22: rpc.ReferenceService.DeleteBranch:output_type -> rpc.DeleteBranchResponse 13, // 22: rpc.ReferenceService.GetRef:input_type -> rpc.GetRefRequest
8, // 23: rpc.ReferenceService.ListBranches:output_type -> rpc.ListBranchesResponse 15, // 23: rpc.ReferenceService.UpdateRef:input_type -> rpc.UpdateRefRequest
11, // 24: rpc.ReferenceService.ListCommitTags:output_type -> rpc.ListCommitTagsResponse 4, // 24: rpc.ReferenceService.CreateBranch:output_type -> rpc.CreateBranchResponse
14, // 25: rpc.ReferenceService.GetRef:output_type -> rpc.GetRefResponse 6, // 25: rpc.ReferenceService.DeleteBranch:output_type -> rpc.DeleteBranchResponse
21, // [21:26] is the sub-list for method output_type 8, // 26: rpc.ReferenceService.ListBranches:output_type -> rpc.ListBranchesResponse
16, // [16:21] is the sub-list for method input_type 11, // 27: rpc.ReferenceService.ListCommitTags:output_type -> rpc.ListCommitTagsResponse
16, // [16:16] is the sub-list for extension type_name 14, // 28: rpc.ReferenceService.GetRef:output_type -> rpc.GetRefResponse
16, // [16:16] is the sub-list for extension extendee 16, // 29: rpc.ReferenceService.UpdateRef:output_type -> rpc.UpdateRefResponse
0, // [0:16] is the sub-list for field type_name 24, // [24:30] is the sub-list for method output_type
18, // [18:24] is the sub-list for method input_type
18, // [18:18] is the sub-list for extension type_name
18, // [18:18] is the sub-list for extension extendee
0, // [0:18] is the sub-list for field type_name
} }
func init() { file_ref_proto_init() } func init() { file_ref_proto_init() }
@ -1289,6 +1441,30 @@ func file_ref_proto_init() {
return nil return nil
} }
} }
file_ref_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateRefRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ref_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateRefResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -1296,7 +1472,7 @@ func file_ref_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_ref_proto_rawDesc, RawDescriptor: file_ref_proto_rawDesc,
NumEnums: 3, NumEnums: 3,
NumMessages: 12, NumMessages: 14,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -27,6 +27,7 @@ type ReferenceServiceClient interface {
ListBranches(ctx context.Context, in *ListBranchesRequest, opts ...grpc.CallOption) (ReferenceService_ListBranchesClient, 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) ListCommitTags(ctx context.Context, in *ListCommitTagsRequest, opts ...grpc.CallOption) (ReferenceService_ListCommitTagsClient, error)
GetRef(ctx context.Context, in *GetRefRequest, opts ...grpc.CallOption) (*GetRefResponse, error) GetRef(ctx context.Context, in *GetRefRequest, opts ...grpc.CallOption) (*GetRefResponse, error)
UpdateRef(ctx context.Context, in *UpdateRefRequest, opts ...grpc.CallOption) (*UpdateRefResponse, error)
} }
type referenceServiceClient struct { type referenceServiceClient struct {
@ -128,6 +129,15 @@ func (c *referenceServiceClient) GetRef(ctx context.Context, in *GetRefRequest,
return out, nil return out, nil
} }
func (c *referenceServiceClient) UpdateRef(ctx context.Context, in *UpdateRefRequest, opts ...grpc.CallOption) (*UpdateRefResponse, error) {
out := new(UpdateRefResponse)
err := c.cc.Invoke(ctx, "/rpc.ReferenceService/UpdateRef", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ReferenceServiceServer is the server API for ReferenceService service. // ReferenceServiceServer is the server API for ReferenceService service.
// All implementations must embed UnimplementedReferenceServiceServer // All implementations must embed UnimplementedReferenceServiceServer
// for forward compatibility // for forward compatibility
@ -137,6 +147,7 @@ type ReferenceServiceServer interface {
ListBranches(*ListBranchesRequest, ReferenceService_ListBranchesServer) error ListBranches(*ListBranchesRequest, ReferenceService_ListBranchesServer) error
ListCommitTags(*ListCommitTagsRequest, ReferenceService_ListCommitTagsServer) error ListCommitTags(*ListCommitTagsRequest, ReferenceService_ListCommitTagsServer) error
GetRef(context.Context, *GetRefRequest) (*GetRefResponse, error) GetRef(context.Context, *GetRefRequest) (*GetRefResponse, error)
UpdateRef(context.Context, *UpdateRefRequest) (*UpdateRefResponse, error)
mustEmbedUnimplementedReferenceServiceServer() mustEmbedUnimplementedReferenceServiceServer()
} }
@ -159,6 +170,9 @@ func (UnimplementedReferenceServiceServer) ListCommitTags(*ListCommitTagsRequest
func (UnimplementedReferenceServiceServer) GetRef(context.Context, *GetRefRequest) (*GetRefResponse, error) { func (UnimplementedReferenceServiceServer) GetRef(context.Context, *GetRefRequest) (*GetRefResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRef not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetRef not implemented")
} }
func (UnimplementedReferenceServiceServer) UpdateRef(context.Context, *UpdateRefRequest) (*UpdateRefResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateRef not implemented")
}
func (UnimplementedReferenceServiceServer) mustEmbedUnimplementedReferenceServiceServer() {} func (UnimplementedReferenceServiceServer) mustEmbedUnimplementedReferenceServiceServer() {}
// UnsafeReferenceServiceServer may be embedded to opt out of forward compatibility for this service. // UnsafeReferenceServiceServer may be embedded to opt out of forward compatibility for this service.
@ -268,6 +282,24 @@ func _ReferenceService_GetRef_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _ReferenceService_UpdateRef_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateRefRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ReferenceServiceServer).UpdateRef(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/rpc.ReferenceService/UpdateRef",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ReferenceServiceServer).UpdateRef(ctx, req.(*UpdateRefRequest))
}
return interceptor(ctx, in, info, handler)
}
// ReferenceService_ServiceDesc is the grpc.ServiceDesc for ReferenceService service. // ReferenceService_ServiceDesc is the grpc.ServiceDesc for ReferenceService service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -287,6 +319,10 @@ var ReferenceService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetRef", MethodName: "GetRef",
Handler: _ReferenceService_GetRef_Handler, Handler: _ReferenceService_GetRef_Handler,
}, },
{
MethodName: "UpdateRef",
Handler: _ReferenceService_UpdateRef_Handler,
},
}, },
Streams: []grpc.StreamDesc{ Streams: []grpc.StreamDesc{
{ {

View File

@ -10,8 +10,8 @@ import (
"fmt" "fmt"
"github.com/harness/gitness/gitrpc" "github.com/harness/gitness/gitrpc"
gitrpcenum "github.com/harness/gitness/gitrpc/enum"
apiauth "github.com/harness/gitness/internal/api/auth" apiauth "github.com/harness/gitness/internal/api/auth"
repoctrl "github.com/harness/gitness/internal/api/controller/repo"
"github.com/harness/gitness/internal/api/usererror" "github.com/harness/gitness/internal/api/usererror"
"github.com/harness/gitness/internal/auth" "github.com/harness/gitness/internal/auth"
"github.com/harness/gitness/internal/auth/authz" "github.com/harness/gitness/internal/auth/authz"
@ -64,27 +64,28 @@ func NewController(
func (c *Controller) verifyBranchExistence(ctx context.Context, func (c *Controller) verifyBranchExistence(ctx context.Context,
repo *types.Repository, branch string, repo *types.Repository, branch string,
) error { ) (string, error) {
if branch == "" { if branch == "" {
return usererror.BadRequest("branch name can't be empty") return "", usererror.BadRequest("branch name can't be empty")
} }
_, err := c.gitRPCClient.GetRef(ctx, ref, err := c.gitRPCClient.GetRef(ctx,
&gitrpc.GetRefParams{ gitrpc.GetRefParams{
ReadParams: repoctrl.CreateRPCReadParams(repo), ReadParams: gitrpc.ReadParams{RepoUID: repo.GitUID},
Name: branch, Name: branch,
Type: gitrpc.RefTypeBranch}) Type: gitrpcenum.RefTypeBranch,
})
if errors.Is(err, gitrpc.ErrNotFound) { if errors.Is(err, gitrpc.ErrNotFound) {
return usererror.BadRequest( return "", usererror.BadRequest(
fmt.Sprintf("branch %s does not exist in the repository %s", branch, repo.UID)) fmt.Sprintf("branch %s does not exist in the repository %s", branch, repo.UID))
} }
if err != nil { if err != nil {
return fmt.Errorf( return "", fmt.Errorf(
"failed to check existence of the branch %s in the repository %s: %w", "failed to check existence of the branch %s in the repository %s: %w",
branch, repo.UID, err) branch, repo.UID, err)
} }
return nil return ref.SHA, nil
} }
func (c *Controller) getRepoCheckAccess(ctx context.Context, func (c *Controller) getRepoCheckAccess(ctx context.Context,

View File

@ -54,11 +54,14 @@ func (c *Controller) Create(
return nil, usererror.BadRequest("target and source branch can't be the same") return nil, usererror.BadRequest("target and source branch can't be the same")
} }
if errBranch := c.verifyBranchExistence(ctx, sourceRepo, in.SourceBranch); errBranch != nil { var sourceSHA string
return nil, errBranch
if sourceSHA, err = c.verifyBranchExistence(ctx, sourceRepo, in.SourceBranch); err != nil {
return nil, err
} }
if errBranch := c.verifyBranchExistence(ctx, targetRepo, in.TargetBranch); errBranch != nil {
return nil, errBranch if _, err = c.verifyBranchExistence(ctx, targetRepo, in.TargetBranch); err != nil {
return nil, err
} }
if err = c.checkIfAlreadyExists(ctx, targetRepo.ID, sourceRepo.ID, in.SourceBranch, in.TargetBranch); err != nil { if err = c.checkIfAlreadyExists(ctx, targetRepo.ID, sourceRepo.ID, in.SourceBranch, in.TargetBranch); err != nil {
@ -73,6 +76,8 @@ func (c *Controller) Create(
return nil, fmt.Errorf("failed to aquire PullReqSeq number: %w", err) return nil, fmt.Errorf("failed to aquire PullReqSeq number: %w", err)
} }
_ = fmt.Sprintf("TODO: %s", sourceSHA) // TODO: Use sourceSHA to create git PR head ref
pr := newPullReq(session, targetRepo.PullReqSeq, sourceRepo, targetRepo, in) pr := newPullReq(session, targetRepo.PullReqSeq, sourceRepo, targetRepo, in)
err = c.pullreqStore.Create(ctx, pr) err = c.pullreqStore.Create(ctx, pr)

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/harness/gitness/gitrpc" "github.com/harness/gitness/gitrpc"
gitrpcenum "github.com/harness/gitness/gitrpc/enum"
"github.com/harness/gitness/internal/api/usererror" "github.com/harness/gitness/internal/api/usererror"
"github.com/harness/gitness/internal/auth" "github.com/harness/gitness/internal/auth"
"github.com/harness/gitness/internal/store" "github.com/harness/gitness/internal/store"
@ -69,16 +70,16 @@ func (c *Controller) ReviewSubmit(
return nil, usererror.BadRequest("Can't submit review to own pull requests.") return nil, usererror.BadRequest("Can't submit review to own pull requests.")
} }
ref, err := c.gitRPCClient.GetRef(ctx, &gitrpc.GetRefParams{ ref, err := c.gitRPCClient.GetRef(ctx, gitrpc.GetRefParams{
ReadParams: gitrpc.ReadParams{RepoUID: repo.GitUID}, ReadParams: gitrpc.ReadParams{RepoUID: repo.GitUID},
Name: pr.TargetBranch, Name: pr.TargetBranch,
Type: gitrpc.RefTypeBranch, Type: gitrpcenum.RefTypeBranch,
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get git branch sha: %w", err) return nil, fmt.Errorf("failed to get git branch sha: %w", err)
} }
if ref == nil || ref.SHA == "" { if ref.SHA == "" {
return nil, usererror.BadRequest("Failed to get branch SHA. Does the branch still exist?") return nil, usererror.BadRequest("Failed to get branch SHA. Does the branch still exist?")
} }