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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package operations
import (
"context"
"fmt"
"gitlab.com/gitlab-org/gitaly-proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (s *server) UserMergeBranch(bidi gitalypb.OperationService_UserMergeBranchServer) error {
firstRequest, err := bidi.Recv()
if err != nil {
return err
}
ctx := bidi.Context()
client, err := s.OperationServiceClient(ctx)
if err != nil {
return err
}
clientCtx, err := rubyserver.SetHeaders(ctx, firstRequest.GetRepository())
if err != nil {
return err
}
rubyBidi, err := client.UserMergeBranch(clientCtx)
if err != nil {
return err
}
if err := rubyBidi.Send(firstRequest); err != nil {
return err
}
return rubyserver.ProxyBidi(
func() error {
request, err := bidi.Recv()
if err != nil {
return err
}
return rubyBidi.Send(request)
},
rubyBidi,
func() error {
response, err := rubyBidi.Recv()
if err != nil {
return err
}
return bidi.Send(response)
},
)
}
func validateFFRequest(in *gitalypb.UserFFBranchRequest) error {
if len(in.Branch) == 0 {
return fmt.Errorf("empty branch name")
}
if in.User == nil {
return fmt.Errorf("empty user")
}
if in.CommitId == "" {
return fmt.Errorf("empty commit id")
}
return nil
}
func (s *server) UserFFBranch(ctx context.Context, in *gitalypb.UserFFBranchRequest) (*gitalypb.UserFFBranchResponse, error) {
if err := validateFFRequest(in); err != nil {
return nil, status.Errorf(codes.InvalidArgument, "UserFFBranch: %v", err)
}
client, err := s.OperationServiceClient(ctx)
if err != nil {
return nil, err
}
clientCtx, err := rubyserver.SetHeaders(ctx, in.GetRepository())
if err != nil {
return nil, err
}
return client.UserFFBranch(clientCtx, in)
}
|