blob: 1fa5ea3419bd19a6ae6f804bd6242257e326acc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package operations
import (
"fmt"
"gitlab.com/gitlab-org/gitaly-proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (s *server) UserRebase(ctx context.Context, req *gitalypb.UserRebaseRequest) (*gitalypb.UserRebaseResponse, error) {
if err := validateUserRebaseRequest(req); err != nil {
return nil, status.Errorf(codes.InvalidArgument, "UserRebase: %v", err)
}
client, err := s.OperationServiceClient(ctx)
if err != nil {
return nil, err
}
clientCtx, err := rubyserver.SetHeaders(ctx, req.GetRepository())
if err != nil {
return nil, err
}
return client.UserRebase(clientCtx, req)
}
func validateUserRebaseRequest(req *gitalypb.UserRebaseRequest) error {
if req.GetRepository() == nil {
return fmt.Errorf("empty Repository")
}
if req.GetUser() == nil {
return fmt.Errorf("empty User")
}
if req.GetRebaseId() == "" {
return fmt.Errorf("empty RebaseId")
}
if req.GetBranch() == nil {
return fmt.Errorf("empty Branch")
}
if req.GetBranchSha() == "" {
return fmt.Errorf("empty BranchSha")
}
if req.GetRemoteRepository() == nil {
return fmt.Errorf("empty RemoteRepository")
}
if req.GetRemoteBranch() == nil {
return fmt.Errorf("empty RemoteBranch")
}
return nil
}
|