Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2020-06-09 03:50:05 +0300
committerJohn Cai <jcai@gitlab.com>2020-06-09 08:09:27 +0300
commite3a410352a0863c68bc4fa1d5b2edd195ab7eb2f (patch)
tree6029038d022974490638711908a3a9bf1da5b624
parenta10ef72068e224255018b9a84298156b3d42aa20 (diff)
Pass git push options into pre receive
-rw-r--r--changelogs/unreleased/jc-pass-git-push-options-prereceive.yml5
-rw-r--r--cmd/gitaly-hooks/hooks.go1
-rw-r--r--internal/service/hook/pre_receive.go11
-rw-r--r--internal/service/operations/rebase_test.go6
-rw-r--r--proto/go/gitalypb/hook.pb.go70
-rw-r--r--proto/hook.proto1
-rw-r--r--ruby/proto/gitaly/hook_pb.rb1
7 files changed, 63 insertions, 32 deletions
diff --git a/changelogs/unreleased/jc-pass-git-push-options-prereceive.yml b/changelogs/unreleased/jc-pass-git-push-options-prereceive.yml
new file mode 100644
index 000000000..3e575b40b
--- /dev/null
+++ b/changelogs/unreleased/jc-pass-git-push-options-prereceive.yml
@@ -0,0 +1,5 @@
+---
+title: Pass git push options into pre receive
+merge_request: 2266
+author:
+type: fixed
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go
index 9eb674475..fbac69f45 100644
--- a/cmd/gitaly-hooks/hooks.go
+++ b/cmd/gitaly-hooks/hooks.go
@@ -119,6 +119,7 @@ func main() {
if err := preReceiveHookStream.Send(&gitalypb.PreReceiveHookRequest{
Repository: repository,
EnvironmentVariables: environment,
+ GitPushOptions: gitPushOptions(),
}); err != nil {
logger.Fatalf("error when sending request for %q: %v", subCmd, err)
}
diff --git a/internal/service/hook/pre_receive.go b/internal/service/hook/pre_receive.go
index b4627ee13..b858f6db8 100644
--- a/internal/service/hook/pre_receive.go
+++ b/internal/service/hook/pre_receive.go
@@ -11,6 +11,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/alternates"
+ "gitlab.com/gitlab-org/gitaly/internal/git/hooks"
"gitlab.com/gitlab-org/gitaly/internal/gitlabshell"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/praefect/metadata"
@@ -24,6 +25,11 @@ type hookRequest interface {
GetRepository() *gitalypb.Repository
}
+type prePostRequest interface {
+ hookRequest
+ GetGitPushOptions() []string
+}
+
func hookRequestEnv(req hookRequest) ([]string, error) {
gitlabshellEnv, err := gitlabshell.Env()
if err != nil {
@@ -32,7 +38,7 @@ func hookRequestEnv(req hookRequest) ([]string, error) {
return append(gitlabshellEnv, req.GetEnvironmentVariables()...), nil
}
-func preReceiveEnv(req hookRequest) ([]string, error) {
+func preReceiveEnv(req prePostRequest) ([]string, error) {
_, env, err := alternates.PathAndEnv(req.GetRepository())
if err != nil {
return nil, err
@@ -43,6 +49,9 @@ func preReceiveEnv(req hookRequest) ([]string, error) {
return nil, err
}
+ env = append(env, hookEnv...)
+ env = append(env, hooks.GitPushOptions(req.GetGitPushOptions())...)
+
return append(hookEnv, env...), nil
}
diff --git a/internal/service/operations/rebase_test.go b/internal/service/operations/rebase_test.go
index 73e137e22..a967f0f22 100644
--- a/internal/service/operations/rebase_test.go
+++ b/internal/service/operations/rebase_test.go
@@ -62,6 +62,12 @@ func testSuccessfulUserRebaseConfirmableRequest(t *testing.T, ctxOuter context.C
branchSha := getBranchSha(t, testRepoPath, rebaseBranchName)
md := testhelper.GitalyServersMetadata(t, serverSocketPath)
+
+ mdFromCtx, ok := metadata.FromOutgoingContext(ctxOuter)
+ if ok {
+ md = metadata.Join(md, mdFromCtx)
+ }
+
ctx := metadata.NewOutgoingContext(ctxOuter, md)
rebaseStream, err := client.UserRebaseConfirmable(ctx)
diff --git a/proto/go/gitalypb/hook.pb.go b/proto/go/gitalypb/hook.pb.go
index 1c5ae1b00..6ab19d47e 100644
--- a/proto/go/gitalypb/hook.pb.go
+++ b/proto/go/gitalypb/hook.pb.go
@@ -28,6 +28,7 @@ type PreReceiveHookRequest struct {
Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"`
EnvironmentVariables []string `protobuf:"bytes,2,rep,name=environment_variables,json=environmentVariables,proto3" json:"environment_variables,omitempty"`
Stdin []byte `protobuf:"bytes,4,opt,name=stdin,proto3" json:"stdin,omitempty"`
+ GitPushOptions []string `protobuf:"bytes,5,rep,name=git_push_options,json=gitPushOptions,proto3" json:"git_push_options,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -79,6 +80,13 @@ func (m *PreReceiveHookRequest) GetStdin() []byte {
return nil
}
+func (m *PreReceiveHookRequest) GetGitPushOptions() []string {
+ if m != nil {
+ return m.GitPushOptions
+ }
+ return nil
+}
+
type PreReceiveHookResponse struct {
Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"`
Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"`
@@ -390,37 +398,37 @@ func init() {
func init() { proto.RegisterFile("hook.proto", fileDescriptor_3eef30da1c11ee1b) }
var fileDescriptor_3eef30da1c11ee1b = []byte{
- // 474 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xc1, 0x6e, 0xd3, 0x40,
- 0x10, 0x86, 0xb5, 0x4e, 0x1a, 0x35, 0x93, 0xa8, 0x94, 0x55, 0x1b, 0x8c, 0x11, 0x10, 0xf9, 0xe4,
- 0x03, 0x24, 0x51, 0x73, 0xe1, 0x5c, 0x09, 0x89, 0x0b, 0x22, 0x72, 0x45, 0x0f, 0x20, 0x61, 0x39,
- 0xf1, 0xe0, 0xac, 0xea, 0x7a, 0xcc, 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
- 0xf9, 0xc3, 0x65, 0xe9, 0x8d, 0x59, 0x71, 0x9c, 0x6d, 0x68, 0x53, 0x70, 0xc4, 0x8e, 0x47, 0xef,
- 0xca, 0x6b, 0x49, 0x38, 0x1d, 0xcc, 0xe8, 0x7c, 0x68, 0x8e, 0xcf, 0x49, 0xc6, 0x43, 0x53, 0x3c,
- 0xac, 0xfe, 0x7a, 0xc3, 0x98, 0xea, 0x38, 0x9b, 0x4e, 0x5b, 0x55, 0x6a, 0xfc, 0x37, 0x00, 0x00,
- 0xff, 0xff, 0xba, 0x91, 0xf9, 0x6c, 0x38, 0x05, 0x00, 0x00,
+ // 477 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xcd, 0x6e, 0xd3, 0x40,
+ 0x10, 0xc7, 0xb5, 0xce, 0x87, 0x9a, 0x49, 0x54, 0xca, 0xaa, 0x0d, 0xc6, 0x08, 0x88, 0x7c, 0xf2,
+ 0x01, 0x92, 0xa8, 0xb9, 0x70, 0xae, 0x84, 0xc4, 0x05, 0x11, 0xb9, 0xa2, 0x07, 0x90, 0xb0, 0x9c,
+ 0x78, 0x70, 0x56, 0x75, 0x3d, 0x66, 0x77, 0xed, 0x36, 0x07, 0x78, 0x0d, 0xe0, 0x85, 0xca, 0x8d,
+ 0x07, 0xe2, 0x84, 0xfc, 0x91, 0x34, 0x69, 0x5d, 0x71, 0x2b, 0xbd, 0xcd, 0xcc, 0x6f, 0x67, 0x56,
+ 0xff, 0xbf, 0x66, 0x17, 0x60, 0x41, 0x74, 0x3a, 0x4c, 0x24, 0x69, 0xe2, 0xed, 0x50, 0x68, 0x3f,
+ 0x5a, 0x5a, 0x10, 0x89, 0x58, 0x97, 0x35, 0xab, 0xa7, 0x16, 0xbe, 0xc4, 0xa0, 0xcc, 0xec, 0x4b,
+ 0x06, 0x07, 0x53, 0x89, 0x2e, 0xce, 0x51, 0x64, 0x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// Reference imports to suppress errors if they are not otherwise used.
diff --git a/proto/hook.proto b/proto/hook.proto
index b29c3dc81..0af53620e 100644
--- a/proto/hook.proto
+++ b/proto/hook.proto
@@ -29,6 +29,7 @@ message PreReceiveHookRequest {
Repository repository = 1 [(target_repository)=true];
repeated string environment_variables = 2;
bytes stdin = 4;
+ repeated string git_push_options = 5;
}
message PreReceiveHookResponse{
diff --git a/ruby/proto/gitaly/hook_pb.rb b/ruby/proto/gitaly/hook_pb.rb
index 26a13e941..54e8a9d5d 100644
--- a/ruby/proto/gitaly/hook_pb.rb
+++ b/ruby/proto/gitaly/hook_pb.rb
@@ -10,6 +10,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
optional :repository, :message, 1, "gitaly.Repository"
repeated :environment_variables, :string, 2
optional :stdin, :bytes, 4
+ repeated :git_push_options, :string, 5
end
add_message "gitaly.PreReceiveHookResponse" do
optional :stdout, :bytes, 1