diff options
Diffstat (limited to 'internal/gitaly/service/repository/fetch.go')
-rw-r--r-- | internal/gitaly/service/repository/fetch.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/gitaly/service/repository/fetch.go b/internal/gitaly/service/repository/fetch.go index ef10fee9b..08d7fd4a3 100644 --- a/internal/gitaly/service/repository/fetch.go +++ b/internal/gitaly/service/repository/fetch.go @@ -5,6 +5,7 @@ import ( "errors" "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" + gitalyerrors "gitlab.com/gitlab-org/gitaly/v15/internal/errors" "gitlab.com/gitlab-org/gitaly/v15/internal/git" "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/v15/internal/git/remoterepo" @@ -12,12 +13,21 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" ) -func (s *server) FetchSourceBranch(ctx context.Context, req *gitalypb.FetchSourceBranchRequest) (*gitalypb.FetchSourceBranchResponse, error) { - if err := git.ValidateRevision(req.GetSourceBranch()); err != nil { - return nil, helper.ErrInvalidArgument(err) +func validateFetchSourceBranchRequest(in *gitalypb.FetchSourceBranchRequest) error { + if in.GetRepository() == nil { + return gitalyerrors.ErrEmptyRepository + } + if err := git.ValidateRevision(in.GetSourceBranch()); err != nil { + return err } + if err := git.ValidateRevision(in.GetTargetRef()); err != nil { + return err + } + return nil +} - if err := git.ValidateRevision(req.GetTargetRef()); err != nil { +func (s *server) FetchSourceBranch(ctx context.Context, req *gitalypb.FetchSourceBranchRequest) (*gitalypb.FetchSourceBranchResponse, error) { + if err := validateFetchSourceBranchRequest(req); err != nil { return nil, helper.ErrInvalidArgument(err) } |