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>2022-06-15 21:17:48 +0300
committerJohn Cai <jcai@gitlab.com>2022-06-15 21:17:48 +0300
commit96e6852003980a58d50cf3cd16c23c3f6bc367f0 (patch)
tree2d83d93ccf88421bf94891772a5e0a7897c74a57
parent5caf724a8305ea04370dc49f0d9a7d5f3bc8dd4a (diff)
parent14a2fb7235028cd9c5287655f99688a75cadcbb0 (diff)
Merge branch 'jc-pass-user-details-to-pack-objects' into 'master'
Add glId, glUser, glRepo, glProtocol to PackObjectsRequest See merge request gitlab-org/gitaly!4599
-rw-r--r--cmd/gitaly-hooks/hooks.go36
-rw-r--r--cmd/gitaly-hooks/hooks_test.go4
-rw-r--r--internal/git/hooks_options.go30
-rw-r--r--internal/git/hooks_options_test.go28
-rw-r--r--internal/git/hooks_payload.go20
-rw-r--r--internal/git/hooks_payload_test.go4
-rw-r--r--internal/git/updateref/update_with_hooks.go2
-rw-r--r--internal/git/updateref/update_with_hooks_test.go2
-rw-r--r--internal/gitaly/hook/custom.go6
-rw-r--r--internal/gitaly/hook/postreceive.go6
-rw-r--r--internal/gitaly/hook/postreceive_test.go6
-rw-r--r--internal/gitaly/hook/prereceive.go18
-rw-r--r--internal/gitaly/hook/prereceive_test.go6
-rw-r--r--internal/gitaly/hook/transactions_test.go2
-rw-r--r--internal/gitaly/hook/update.go2
-rw-r--r--internal/gitaly/hook/update_test.go4
-rw-r--r--internal/gitaly/service/hook/post_receive_test.go4
-rw-r--r--internal/gitaly/service/hook/pre_receive_test.go8
-rw-r--r--internal/gitaly/service/hook/update_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/upload_pack.go2
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go2
-rw-r--r--internal/gitaly/service/ssh/upload_pack.go2
-rw-r--r--proto/go/gitalypb/hook.pb.go127
-rw-r--r--proto/hook.proto7
-rw-r--r--ruby/lib/gitlab/git/hook.rb2
-rw-r--r--ruby/proto/gitaly/hook_pb.rb3
-rw-r--r--ruby/spec/lib/gitlab/git/hook_spec.rb2
28 files changed, 235 insertions, 104 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go
index 5a56464c8..10a0d2514 100644
--- a/cmd/gitaly-hooks/hooks.go
+++ b/cmd/gitaly-hooks/hooks.go
@@ -25,6 +25,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/streamio"
"gitlab.com/gitlab-org/labkit/tracing"
"google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
)
type hookError struct {
@@ -387,9 +388,42 @@ func handlePackObjectsWithSidechannel(ctx context.Context, payload git.HooksPayl
}
defer wt.Close()
+ var glID, glUsername, gitProtocol string
+
+ // TODO: remove this conditional in 15.2.
+ // Since the git2go binary is replaced before the gitaly binary, there
+ // is a period of time during an upgrade when the gitaly binary is older
+ // than the corresponding git2go binary, which means gitaly will still
+ // be sending ReceiveHooksPayload until the upgrade is finished.
+ if payload.UserDetails != nil {
+ glID = payload.UserDetails.UserID
+ glUsername = payload.UserDetails.Username
+ gitProtocol = payload.UserDetails.Protocol
+ } else {
+ glID = payload.ReceiveHooksPayload.UserID
+ glUsername = payload.ReceiveHooksPayload.Username
+ gitProtocol = payload.ReceiveHooksPayload.Protocol
+ }
+
+ ctx = metadata.AppendToOutgoingContext(
+ ctx,
+ "user_id",
+ glID,
+ "username",
+ glUsername,
+ "protocol",
+ gitProtocol,
+ )
+
if _, err := hookClient.PackObjectsHookWithSidechannel(
ctx,
- &gitalypb.PackObjectsHookWithSidechannelRequest{Repository: payload.Repo, Args: args},
+ &gitalypb.PackObjectsHookWithSidechannelRequest{
+ Repository: payload.Repo,
+ Args: args,
+ GlId: glID,
+ GlUsername: glUsername,
+ GitProtocol: gitProtocol,
+ },
); err != nil {
return fmt.Errorf("call PackObjectsHookWithSidechannel: %w", err)
}
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index be59445d2..9db2ea23f 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -58,7 +58,7 @@ func rawFeatureFlags(ctx context.Context) featureflag.Raw {
// envForHooks generates a set of environment variables for gitaly hooks
func envForHooks(t testing.TB, ctx context.Context, cfg config.Cfg, repo *gitalypb.Repository, glHookValues glHookValues, proxyValues proxyValues, gitPushOptions ...string) []string {
- payload, err := git.NewHooksPayload(cfg, repo, nil, &git.ReceiveHooksPayload{
+ payload, err := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
UserID: glHookValues.GLID,
Username: glHookValues.GLUsername,
Protocol: glHookValues.GLProtocol,
@@ -407,7 +407,7 @@ func TestHooksPostReceiveFailed(t *testing.T) {
Node: "node",
Primary: tc.primary,
},
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: glID,
Username: glUsername,
Protocol: glProtocol,
diff --git a/internal/git/hooks_options.go b/internal/git/hooks_options.go
index f88fbd9ba..5a24f8a9d 100644
--- a/internal/git/hooks_options.go
+++ b/internal/git/hooks_options.go
@@ -9,6 +9,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/log"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v15/internal/transaction/txinfo"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -50,7 +51,7 @@ func WithRefTxHook(repo repository.GitRepo) CmdOpt {
}
// WithPackObjectsHookEnv provides metadata for gitaly-hooks so it can act as a pack-objects hook.
-func WithPackObjectsHookEnv(repo *gitalypb.Repository) CmdOpt {
+func WithPackObjectsHookEnv(repo *gitalypb.Repository, protocol string) CmdOpt {
return func(ctx context.Context, cfg config.Cfg, gitCmdFactory CommandFactory, cc *cmdCfg) error {
if !cfg.PackObjectsCache.Enabled {
return nil
@@ -60,7 +61,20 @@ func WithPackObjectsHookEnv(repo *gitalypb.Repository) CmdOpt {
return fmt.Errorf("missing repo: %w", ErrInvalidArg)
}
- if err := cc.configureHooks(ctx, repo, cfg, gitCmdFactory, nil, PackObjectsHook); err != nil {
+ userDetails := &UserDetails{
+ Protocol: protocol,
+ UserID: metadata.GetValue(ctx, "user_id"),
+ Username: metadata.GetValue(ctx, "username"),
+ }
+
+ if err := cc.configureHooks(
+ ctx,
+ repo,
+ cfg,
+ gitCmdFactory,
+ userDetails,
+ PackObjectsHook,
+ ); err != nil {
return fmt.Errorf("pack-objects hook configuration: %w", err)
}
@@ -81,7 +95,7 @@ func (cc *cmdCfg) configureHooks(
repo *gitalypb.Repository,
cfg config.Cfg,
gitCmdFactory CommandFactory,
- receiveHooksPayload *ReceiveHooksPayload,
+ userDetails *UserDetails,
requestedHooks Hook,
) error {
if cc.hooksConfigured {
@@ -95,7 +109,13 @@ func (cc *cmdCfg) configureHooks(
return err
}
- payload, err := NewHooksPayload(cfg, repo, transaction, receiveHooksPayload, requestedHooks, featureflag.RawFromContext(ctx)).Env()
+ payload, err := NewHooksPayload(
+ cfg,
+ repo,
+ transaction,
+ userDetails,
+ requestedHooks,
+ featureflag.RawFromContext(ctx)).Env()
if err != nil {
return err
}
@@ -126,7 +146,7 @@ type ReceivePackRequest interface {
// git-receive-pack(1).
func WithReceivePackHooks(req ReceivePackRequest, protocol string) CmdOpt {
return func(ctx context.Context, cfg config.Cfg, gitCmdFactory CommandFactory, cc *cmdCfg) error {
- if err := cc.configureHooks(ctx, req.GetRepository(), cfg, gitCmdFactory, &ReceiveHooksPayload{
+ if err := cc.configureHooks(ctx, req.GetRepository(), cfg, gitCmdFactory, &UserDetails{
UserID: req.GetGlId(),
Username: req.GetGlUsername(),
Protocol: protocol,
diff --git a/internal/git/hooks_options_test.go b/internal/git/hooks_options_test.go
index 430c1874b..bf6da080e 100644
--- a/internal/git/hooks_options_test.go
+++ b/internal/git/hooks_options_test.go
@@ -8,8 +8,10 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/command"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
+ grpcmetadata "google.golang.org/grpc/metadata"
)
func TestWithRefHook(t *testing.T) {
@@ -55,3 +57,29 @@ func TestWithRefHook(t *testing.T) {
})
}
}
+
+func TestWithPackObjectsHookEnv(t *testing.T) {
+ cfg, repo, _ := testcfg.BuildWithRepo(t)
+ ctx := testhelper.Context(t)
+ cfg.PackObjectsCache.Enabled = true
+
+ userID := "user-123"
+ username := "username"
+ protocol := "protocol"
+
+ opt := git.WithPackObjectsHookEnv(repo, protocol)
+ subCmd := git.SubCmd{Name: "upload-pack", Args: []string{"a/b/c"}}
+
+ ctx = grpcmetadata.AppendToOutgoingContext(ctx, "user_id", userID, "username", username)
+ ctx = metadata.OutgoingToIncoming(ctx)
+
+ cmd, err := gittest.NewCommandFactory(t, cfg, git.WithSkipHooks()).New(ctx, repo, subCmd, opt)
+ require.NoError(t, err)
+
+ payload, err := git.HooksPayloadFromEnv(cmd.Env())
+ require.NoError(t, err)
+
+ require.Equal(t, userID, payload.UserDetails.UserID)
+ require.Equal(t, username, payload.UserDetails.Username)
+ require.Equal(t, protocol, payload.UserDetails.Protocol)
+}
diff --git a/internal/git/hooks_payload.go b/internal/git/hooks_payload.go
index 96e2758ee..f0185d495 100644
--- a/internal/git/hooks_payload.go
+++ b/internal/git/hooks_payload.go
@@ -71,15 +71,21 @@ type HooksPayload struct {
// it's not set, no transactional voting will happen.
Transaction *txinfo.Transaction `json:"transaction"`
- // ReceiveHooksPayload contains information required when executing
- // git-receive-pack.
- ReceiveHooksPayload *ReceiveHooksPayload `json:"receive_hooks_payload"`
+ // UserDetails contains information required when executing
+ // git-receive-pack or git-upload-pack
+ UserDetails *UserDetails `json:"user_details"`
+ // ReceiveHooksPayload should be identical to UserDetails.
+ // Since the git2go binary is replaced before the gitaly binary, there
+ // is a period of time during an upgrade when the gitaly binary is older
+ // than the corresponding git2go binary. So, we need to keep the
+ // receive_hooks_payload key for one release before we can remove it.
+ ReceiveHooksPayload *UserDetails `json:"receive_hooks_payload"`
}
-// ReceiveHooksPayload contains all information which is required for hooks
+// UserDetails contains all information which is required for hooks
// executed by git-receive-pack, namely the pre-receive, update or post-receive
// hook.
-type ReceiveHooksPayload struct {
+type UserDetails struct {
// Username contains the name of the user who has caused the hook to be executed.
Username string `json:"username"`
// UserID contains the ID of the user who has caused the hook to be executed.
@@ -102,7 +108,7 @@ func NewHooksPayload(
cfg config.Cfg,
repo *gitalypb.Repository,
tx *txinfo.Transaction,
- receiveHooksPayload *ReceiveHooksPayload,
+ userDetails *UserDetails,
requestedHooks Hook,
featureFlags featureflag.Raw,
) HooksPayload {
@@ -112,7 +118,7 @@ func NewHooksPayload(
InternalSocket: cfg.InternalSocketPath(),
InternalSocketToken: cfg.Auth.Token,
Transaction: tx,
- ReceiveHooksPayload: receiveHooksPayload,
+ UserDetails: userDetails,
RequestedHooks: requestedHooks,
FeatureFlags: featureFlags,
}
diff --git a/internal/git/hooks_payload_test.go b/internal/git/hooks_payload_test.go
index 1ed392636..b6220d656 100644
--- a/internal/git/hooks_payload_test.go
+++ b/internal/git/hooks_payload_test.go
@@ -75,7 +75,7 @@ func TestHooksPayload(t *testing.T) {
})
t.Run("receive hooks payload", func(t *testing.T) {
- env, err := git.NewHooksPayload(cfg, repo, nil, &git.ReceiveHooksPayload{
+ env, err := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "ssh",
@@ -95,7 +95,7 @@ func TestHooksPayload(t *testing.T) {
RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.InternalSocketPath(),
InternalSocketToken: cfg.Auth.Token,
- ReceiveHooksPayload: &git.ReceiveHooksPayload{
+ UserDetails: &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "ssh",
diff --git a/internal/git/updateref/update_with_hooks.go b/internal/git/updateref/update_with_hooks.go
index 236036dbd..de4c7cb92 100644
--- a/internal/git/updateref/update_with_hooks.go
+++ b/internal/git/updateref/update_with_hooks.go
@@ -172,7 +172,7 @@ func (u *UpdaterWithHooks) UpdateReference(
changes := fmt.Sprintf("%s %s %s\n", oldrev, newrev, reference)
- receiveHooksPayload := git.ReceiveHooksPayload{
+ receiveHooksPayload := git.UserDetails{
UserID: user.GetGlId(),
Username: user.GetGlUsername(),
Protocol: "web",
diff --git a/internal/git/updateref/update_with_hooks_test.go b/internal/git/updateref/update_with_hooks_test.go
index ab5e5ca97..fa02c5069 100644
--- a/internal/git/updateref/update_with_hooks_test.go
+++ b/internal/git/updateref/update_with_hooks_test.go
@@ -110,7 +110,7 @@ func TestUpdaterWithHooks_UpdateReference(t *testing.T) {
oldRev := "1e292f8fedd741b75372e19097c76d327140c312"
- payload, err := git.NewHooksPayload(cfg, repo, nil, &git.ReceiveHooksPayload{
+ payload, err := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
UserID: "1234",
Username: "Username",
Protocol: "web",
diff --git a/internal/gitaly/hook/custom.go b/internal/gitaly/hook/custom.go
index 8c1c6c4ec..327e014de 100644
--- a/internal/gitaly/hook/custom.go
+++ b/internal/gitaly/hook/custom.go
@@ -193,9 +193,9 @@ func (m *GitLabHookManager) customHooksEnv(ctx context.Context, payload git.Hook
"GIT_DIR="+repoPath,
"GL_REPOSITORY="+payload.Repo.GetGlRepository(),
"GL_PROJECT_PATH="+payload.Repo.GetGlProjectPath(),
- "GL_ID="+payload.ReceiveHooksPayload.UserID,
- "GL_USERNAME="+payload.ReceiveHooksPayload.Username,
- "GL_PROTOCOL="+payload.ReceiveHooksPayload.Protocol,
+ "GL_ID="+payload.UserDetails.UserID,
+ "GL_USERNAME="+payload.UserDetails.Username,
+ "GL_PROTOCOL="+payload.UserDetails.Protocol,
), nil
}
diff --git a/internal/gitaly/hook/postreceive.go b/internal/gitaly/hook/postreceive.go
index 2058baa4d..9ac6e041b 100644
--- a/internal/gitaly/hook/postreceive.go
+++ b/internal/gitaly/hook/postreceive.go
@@ -150,10 +150,10 @@ func (m *GitLabHookManager) postReceiveHook(ctx context.Context, payload git.Hoo
return helper.ErrInternalf("hook got no reference updates")
}
- if payload.ReceiveHooksPayload == nil {
+ if payload.UserDetails == nil {
return helper.ErrInternalf("payload has no receive hooks info")
}
- if payload.ReceiveHooksPayload.UserID == "" {
+ if payload.UserDetails.UserID == "" {
return helper.ErrInternalf("user ID not set")
}
if repo.GetGlRepository() == "" {
@@ -162,7 +162,7 @@ func (m *GitLabHookManager) postReceiveHook(ctx context.Context, payload git.Hoo
ok, messages, err := m.gitlabClient.PostReceive(
ctx, repo.GetGlRepository(),
- payload.ReceiveHooksPayload.UserID,
+ payload.UserDetails.UserID,
string(stdin),
pushOptions...,
)
diff --git a/internal/gitaly/hook/postreceive_test.go b/internal/gitaly/hook/postreceive_test.go
index 8fb8a377d..d8afe3ff5 100644
--- a/internal/gitaly/hook/postreceive_test.go
+++ b/internal/gitaly/hook/postreceive_test.go
@@ -75,7 +75,7 @@ func TestPostReceive_customHook(t *testing.T) {
t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive,
))
- receiveHooksPayload := &git.ReceiveHooksPayload{
+ receiveHooksPayload := &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
@@ -240,7 +240,7 @@ func (m *postreceiveAPIMock) PostReceive(ctx context.Context, glRepository, glID
func TestPostReceive_gitlab(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- payload, err := git.NewHooksPayload(cfg, repo, nil, &git.ReceiveHooksPayload{
+ payload, err := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
@@ -381,7 +381,7 @@ func TestPostReceive_quarantine(t *testing.T) {
} {
t.Run(fmt.Sprintf("quarantined: %v", isQuarantined), func(t *testing.T) {
env, err := git.NewHooksPayload(cfg, repo, nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
diff --git a/internal/gitaly/hook/prereceive.go b/internal/gitaly/hook/prereceive.go
index c38b989cb..c6425b2c1 100644
--- a/internal/gitaly/hook/prereceive.go
+++ b/internal/gitaly/hook/prereceive.go
@@ -113,13 +113,13 @@ func (m *GitLabHookManager) preReceiveHook(ctx context.Context, payload git.Hook
if repo.GetGlRepository() == "" {
return helper.ErrInternalf("repository not set")
}
- if payload.ReceiveHooksPayload == nil {
+ if payload.UserDetails == nil {
return helper.ErrInternalf("payload has no receive hooks info")
}
- if payload.ReceiveHooksPayload.UserID == "" {
+ if payload.UserDetails.UserID == "" {
return helper.ErrInternalf("user ID not set")
}
- if payload.ReceiveHooksPayload.Protocol == "" {
+ if payload.UserDetails.Protocol == "" {
return helper.ErrInternalf("protocol not set")
}
@@ -128,8 +128,8 @@ func (m *GitLabHookManager) preReceiveHook(ctx context.Context, payload git.Hook
GitObjectDirectory: repo.GitObjectDirectory,
GitAlternateObjectDirectories: repo.GitAlternateObjectDirectories,
GLRepository: repo.GetGlRepository(),
- GLID: payload.ReceiveHooksPayload.UserID,
- GLProtocol: payload.ReceiveHooksPayload.Protocol,
+ GLID: payload.UserDetails.UserID,
+ GLProtocol: payload.UserDetails.Protocol,
Changes: string(changes),
}
@@ -143,8 +143,8 @@ func (m *GitLabHookManager) preReceiveHook(ctx context.Context, payload git.Hook
// changes in gitlab-shell first.
return NotAllowedError{
Message: err.Error(),
- UserID: payload.ReceiveHooksPayload.UserID,
- Protocol: payload.ReceiveHooksPayload.Protocol,
+ UserID: payload.UserDetails.UserID,
+ Protocol: payload.UserDetails.Protocol,
Changes: changes,
}
}
@@ -154,8 +154,8 @@ func (m *GitLabHookManager) preReceiveHook(ctx context.Context, payload git.Hook
if !allowed {
return NotAllowedError{
Message: message,
- UserID: payload.ReceiveHooksPayload.UserID,
- Protocol: payload.ReceiveHooksPayload.Protocol,
+ UserID: payload.UserDetails.UserID,
+ Protocol: payload.UserDetails.Protocol,
Changes: changes,
}
}
diff --git a/internal/gitaly/hook/prereceive_test.go b/internal/gitaly/hook/prereceive_test.go
index ff2bb4af2..12dc504bd 100644
--- a/internal/gitaly/hook/prereceive_test.go
+++ b/internal/gitaly/hook/prereceive_test.go
@@ -34,7 +34,7 @@ func TestPrereceive_customHooks(t *testing.T) {
t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive,
))
- receiveHooksPayload := &git.ReceiveHooksPayload{
+ receiveHooksPayload := &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
@@ -200,7 +200,7 @@ func TestPrereceive_quarantine(t *testing.T) {
} {
t.Run(fmt.Sprintf("quarantined: %v", isQuarantined), func(t *testing.T) {
env, err := git.NewHooksPayload(cfg, repo, nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
@@ -252,7 +252,7 @@ func (m *prereceiveAPIMock) PostReceive(context.Context, string, string, string,
func TestPrereceive_gitlab(t *testing.T) {
cfg, repo, repoPath := testcfg.BuildWithRepo(t)
- payload, err := git.NewHooksPayload(cfg, repo, nil, &git.ReceiveHooksPayload{
+ payload, err := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
diff --git a/internal/gitaly/hook/transactions_test.go b/internal/gitaly/hook/transactions_test.go
index 05373e05b..5c485983f 100644
--- a/internal/gitaly/hook/transactions_test.go
+++ b/internal/gitaly/hook/transactions_test.go
@@ -39,7 +39,7 @@ func TestHookManager_stopCalled(t *testing.T) {
cfg,
repo,
&expectedTx,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
diff --git a/internal/gitaly/hook/update.go b/internal/gitaly/hook/update.go
index c00da7e5b..564e1550a 100644
--- a/internal/gitaly/hook/update.go
+++ b/internal/gitaly/hook/update.go
@@ -45,7 +45,7 @@ func (m *GitLabHookManager) updateHook(ctx context.Context, payload git.HooksPay
if err := git.ValidateObjectID(newValue); err != nil {
return helper.ErrInternalf("hook got invalid new value: %w", err)
}
- if payload.ReceiveHooksPayload == nil {
+ if payload.UserDetails == nil {
return helper.ErrInternalf("payload has no receive hooks info")
}
diff --git a/internal/gitaly/hook/update_test.go b/internal/gitaly/hook/update_test.go
index f55f76eb8..464340861 100644
--- a/internal/gitaly/hook/update_test.go
+++ b/internal/gitaly/hook/update_test.go
@@ -31,7 +31,7 @@ func TestUpdate_customHooks(t *testing.T) {
t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive,
))
- receiveHooksPayload := &git.ReceiveHooksPayload{
+ receiveHooksPayload := &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
@@ -231,7 +231,7 @@ func TestUpdate_quarantine(t *testing.T) {
} {
t.Run(fmt.Sprintf("quarantined: %v", isQuarantined), func(t *testing.T) {
env, err := git.NewHooksPayload(cfg, repo, nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "1234",
Username: "user",
Protocol: "web",
diff --git a/internal/gitaly/service/hook/post_receive_test.go b/internal/gitaly/service/hook/post_receive_test.go
index 05fb94866..39b0aeb27 100644
--- a/internal/gitaly/service/hook/post_receive_test.go
+++ b/internal/gitaly/service/hook/post_receive_test.go
@@ -103,7 +103,7 @@ func TestHooksMissingStdin(t *testing.T) {
Node: "node-1",
Primary: tc.primary,
},
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "key_id",
Username: "username",
Protocol: "protocol",
@@ -231,7 +231,7 @@ To create a merge request for okay, visit:
cfg,
repo,
nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "key_id",
Username: "username",
Protocol: "protocol",
diff --git a/internal/gitaly/service/hook/pre_receive_test.go b/internal/gitaly/service/hook/pre_receive_test.go
index fb46709c7..34175bb46 100644
--- a/internal/gitaly/service/hook/pre_receive_test.go
+++ b/internal/gitaly/service/hook/pre_receive_test.go
@@ -143,7 +143,7 @@ func TestPreReceiveHook_GitlabAPIAccess(t *testing.T) {
cfg,
repo,
nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: glID,
Username: "username",
Protocol: protocol,
@@ -265,7 +265,7 @@ func TestPreReceive_APIErrors(t *testing.T) {
cfg,
repo,
nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "key-123",
Username: "username",
Protocol: "web",
@@ -339,7 +339,7 @@ exit %d
cfg,
repo,
nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "key-123",
Username: "username",
Protocol: "web",
@@ -472,7 +472,7 @@ func TestPreReceiveHook_Primary(t *testing.T) {
Node: "node-1",
Primary: tc.primary,
},
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "key-123",
Username: "username",
Protocol: "web",
diff --git a/internal/gitaly/service/hook/update_test.go b/internal/gitaly/service/hook/update_test.go
index b28a49cd8..98e30678c 100644
--- a/internal/gitaly/service/hook/update_test.go
+++ b/internal/gitaly/service/hook/update_test.go
@@ -41,7 +41,7 @@ func TestUpdate_CustomHooks(t *testing.T) {
cfg,
repo,
nil,
- &git.ReceiveHooksPayload{
+ &git.UserDetails{
UserID: "key-123",
Username: "username",
Protocol: "web",
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 22ba8f62c..2be7e9dc9 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -106,7 +106,7 @@ func TestSuccessfulReceivePackRequest(t *testing.T) {
RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.InternalSocketPath(),
InternalSocketToken: cfg.Auth.Token,
- ReceiveHooksPayload: &git.ReceiveHooksPayload{
+ UserDetails: &git.UserDetails{
UserID: "123",
Username: "user",
Protocol: "http",
diff --git a/internal/gitaly/service/smarthttp/upload_pack.go b/internal/gitaly/service/smarthttp/upload_pack.go
index d97cc1718..b0353da19 100644
--- a/internal/gitaly/service/smarthttp/upload_pack.go
+++ b/internal/gitaly/service/smarthttp/upload_pack.go
@@ -136,7 +136,7 @@ func (s *server) runUploadPack(ctx context.Context, req basicPostUploadPackReque
git.WithStdin(stdin),
git.WithGitProtocol(req),
git.WithConfig(gitConfig...),
- git.WithPackObjectsHookEnv(req.GetRepository()),
+ git.WithPackObjectsHookEnv(req.GetRepository(), "http"),
}
cmd, err := s.gitCmdFactory.NewWithoutRepo(ctx, git.SubCmd{
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index 2158add1b..a7802461e 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -161,7 +161,7 @@ func TestReceivePackPushSuccess(t *testing.T) {
RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.InternalSocketPath(),
InternalSocketToken: cfg.Auth.Token,
- ReceiveHooksPayload: &git.ReceiveHooksPayload{
+ UserDetails: &git.UserDetails{
UserID: "123",
Username: "user",
Protocol: "ssh",
diff --git a/internal/gitaly/service/ssh/upload_pack.go b/internal/gitaly/service/ssh/upload_pack.go
index 248524417..1b0ef278f 100644
--- a/internal/gitaly/service/ssh/upload_pack.go
+++ b/internal/gitaly/service/ssh/upload_pack.go
@@ -121,7 +121,7 @@ func (s *server) sshUploadPack(ctx context.Context, req sshUploadPackRequest, st
commandOpts := []git.CmdOpt{
git.WithGitProtocol(req),
git.WithConfig(config...),
- git.WithPackObjectsHookEnv(repo),
+ git.WithPackObjectsHookEnv(repo, "ssh"),
}
var stderrBuilder strings.Builder
diff --git a/proto/go/gitalypb/hook.pb.go b/proto/go/gitalypb/hook.pb.go
index afa319d76..5512db073 100644
--- a/proto/go/gitalypb/hook.pb.go
+++ b/proto/go/gitalypb/hook.pb.go
@@ -664,6 +664,12 @@ type PackObjectsHookWithSidechannelRequest struct {
Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"`
// args contains the arguments passed to the pack-objects hook, without the leading "git"
Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
+ // GlId is the user id of the initator of the fetch
+ GlId string `protobuf:"bytes,3,opt,name=gl_id,json=glId,proto3" json:"gl_id,omitempty"`
+ // GlUsername is the username of the initator of the fetch
+ GlUsername string `protobuf:"bytes,5,opt,name=gl_username,json=glUsername,proto3" json:"gl_username,omitempty"`
+ // GitProtocol is the protocol used for the fetch
+ GitProtocol string `protobuf:"bytes,6,opt,name=git_protocol,json=gitProtocol,proto3" json:"git_protocol,omitempty"`
}
func (x *PackObjectsHookWithSidechannelRequest) Reset() {
@@ -712,6 +718,27 @@ func (x *PackObjectsHookWithSidechannelRequest) GetArgs() []string {
return nil
}
+func (x *PackObjectsHookWithSidechannelRequest) GetGlId() string {
+ if x != nil {
+ return x.GlId
+ }
+ return ""
+}
+
+func (x *PackObjectsHookWithSidechannelRequest) GetGlUsername() string {
+ if x != nil {
+ return x.GlUsername
+ }
+ return ""
+}
+
+func (x *PackObjectsHookWithSidechannelRequest) GetGitProtocol() string {
+ if x != nil {
+ return x.GitProtocol
+ }
+ return ""
+}
+
// This comment is left unintentionally blank.
type PackObjectsHookWithSidechannelResponse struct {
state protoimpl.MessageState
@@ -845,55 +872,61 @@ var file_hook_proto_rawDesc = []byte{
0x72, 0x72, 0x12, 0x33, 0x0a, 0x0b, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75,
0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79,
0x2e, 0x45, 0x78, 0x69, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x65, 0x78, 0x69,
- 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x75, 0x0a, 0x25, 0x50, 0x61, 0x63, 0x6b, 0x4f,
- 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69,
- 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
- 0x12, 0x38, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01,
- 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65,
- 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52, 0x0a,
- 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72,
- 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x22, 0x28,
- 0x0a, 0x26, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x6f, 0x6f,
- 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c,
- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x9e, 0x04, 0x0a, 0x0b, 0x48, 0x6f, 0x6f,
- 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5b, 0x0a, 0x0e, 0x50, 0x72, 0x65, 0x52,
- 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x1d, 0x2e, 0x67, 0x69, 0x74,
- 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x72, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f,
- 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61,
- 0x6c, 0x79, 0x2e, 0x50, 0x72, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f,
- 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08,
- 0x02, 0x28, 0x01, 0x30, 0x01, 0x12, 0x5e, 0x0a, 0x0f, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63,
- 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c,
- 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f,
- 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c,
- 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f,
- 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08,
- 0x02, 0x28, 0x01, 0x30, 0x01, 0x12, 0x4d, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48,
- 0x6f, 0x6f, 0x6b, 0x12, 0x19, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x55, 0x70, 0x64,
- 0x61, 0x74, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a,
- 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x6f,
- 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02,
- 0x08, 0x02, 0x30, 0x01, 0x12, 0x79, 0x0a, 0x18, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63,
- 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6f, 0x6f, 0x6b,
- 0x12, 0x27, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65,
- 0x6e, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6f,
- 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x67, 0x69, 0x74, 0x61,
- 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e,
- 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f,
- 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x28, 0x01, 0x30, 0x01, 0x12,
- 0x87, 0x01, 0x0a, 0x1e, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48,
- 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e,
- 0x65, 0x6c, 0x12, 0x2d, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x61, 0x63, 0x6b,
+ 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xce, 0x01, 0x0a, 0x25, 0x50, 0x61, 0x63, 0x6b,
0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53,
0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
- 0x74, 0x1a, 0x2e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x4f,
- 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69,
- 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
- 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74,
- 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2d, 0x6f,
- 0x72, 0x67, 0x2f, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2f, 0x76, 0x31, 0x35, 0x2f, 0x70, 0x72,
- 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x70, 0x62, 0x62,
- 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x74, 0x12, 0x38, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52,
+ 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52,
+ 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x61,
+ 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x12,
+ 0x13, 0x0a, 0x05, 0x67, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
+ 0x67, 0x6c, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x67, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x6e,
+ 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x67, 0x6c, 0x55, 0x73, 0x65,
+ 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74,
+ 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x28, 0x0a, 0x26, 0x50, 0x61, 0x63, 0x6b,
+ 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53,
+ 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+ 0x73, 0x65, 0x32, 0x9e, 0x04, 0x0a, 0x0b, 0x48, 0x6f, 0x6f, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69,
+ 0x63, 0x65, 0x12, 0x5b, 0x0a, 0x0e, 0x50, 0x72, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
+ 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x1d, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x72,
+ 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75,
+ 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x72, 0x65,
+ 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f,
+ 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x28, 0x01, 0x30, 0x01, 0x12,
+ 0x5e, 0x0a, 0x0f, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f,
+ 0x6f, 0x6b, 0x12, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74,
+ 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65,
+ 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74,
+ 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f,
+ 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x28, 0x01, 0x30, 0x01, 0x12,
+ 0x4d, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x19, 0x2e,
+ 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x6f, 0x6f,
+ 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c,
+ 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70,
+ 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x79,
+ 0x0a, 0x18, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73,
+ 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x67, 0x69, 0x74,
+ 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x72, 0x61,
+ 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75,
+ 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x66,
+ 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x48, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa,
+ 0x97, 0x28, 0x02, 0x08, 0x02, 0x28, 0x01, 0x30, 0x01, 0x12, 0x87, 0x01, 0x0a, 0x1e, 0x50, 0x61,
+ 0x63, 0x6b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74,
+ 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x2d, 0x2e, 0x67,
+ 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61,
+ 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x67, 0x69,
+ 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73,
+ 0x48, 0x6f, 0x6f, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e,
+ 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28,
+ 0x02, 0x08, 0x02, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f,
+ 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x69, 0x74,
+ 0x61, 0x6c, 0x79, 0x2f, 0x76, 0x31, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f,
+ 0x2f, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x33,
}
var (
diff --git a/proto/hook.proto b/proto/hook.proto
index f70d57362..7d9fa4174 100644
--- a/proto/hook.proto
+++ b/proto/hook.proto
@@ -156,6 +156,13 @@ message PackObjectsHookWithSidechannelRequest {
Repository repository = 1 [(target_repository)=true];
// args contains the arguments passed to the pack-objects hook, without the leading "git"
repeated string args = 2;
+ // GlId is the user id of the initator of the fetch
+ string gl_id = 3;
+ // GlUsername is the username of the initator of the fetch
+ string gl_username = 5;
+ // GitProtocol is the protocol used for the fetch
+ string git_protocol = 6;
+
}
// This comment is left unintentionally blank.
diff --git a/ruby/lib/gitlab/git/hook.rb b/ruby/lib/gitlab/git/hook.rb
index 58c99503c..8084cd74c 100644
--- a/ruby/lib/gitlab/git/hook.rb
+++ b/ruby/lib/gitlab/git/hook.rb
@@ -116,7 +116,7 @@ module Gitlab
git_path: Gitlab.config.git.bin_path,
internal_socket: Gitlab.config.gitaly.internal_socket,
internal_socket_token: ENV['GITALY_TOKEN'],
- receive_hooks_payload: {
+ user_details: {
userid: gl_id,
username: gl_username,
protocol: GL_PROTOCOL
diff --git a/ruby/proto/gitaly/hook_pb.rb b/ruby/proto/gitaly/hook_pb.rb
index beb096ee8..811749589 100644
--- a/ruby/proto/gitaly/hook_pb.rb
+++ b/ruby/proto/gitaly/hook_pb.rb
@@ -60,6 +60,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "gitaly.PackObjectsHookWithSidechannelRequest" do
optional :repository, :message, 1, "gitaly.Repository"
repeated :args, :string, 2
+ optional :gl_id, :string, 3
+ optional :gl_username, :string, 5
+ optional :git_protocol, :string, 6
end
add_message "gitaly.PackObjectsHookWithSidechannelResponse" do
end
diff --git a/ruby/spec/lib/gitlab/git/hook_spec.rb b/ruby/spec/lib/gitlab/git/hook_spec.rb
index 4839407e0..1d5454728 100644
--- a/ruby/spec/lib/gitlab/git/hook_spec.rb
+++ b/ruby/spec/lib/gitlab/git/hook_spec.rb
@@ -44,7 +44,7 @@ describe Gitlab::Git::Hook do
git_path: Gitlab.config.git.bin_path,
internal_socket: Gitlab.config.gitaly.internal_socket,
internal_socket_token: nil,
- receive_hooks_payload: {
+ user_details: {
userid: 'user-123',
username: 'janedoe',
protocol: 'web'