diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-29 10:54:15 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-02-03 09:52:57 +0300 |
commit | 495e948cc300644d9892944fa5ae6ecd67dbe580 (patch) | |
tree | 0f2194a8ece620ff96f1fe14b5c579ace8a2155e | |
parent | 1a40b67cd3ff585bf29185c68313fa0c6b59c046 (diff) |
git: Stop injecting git path via environment variable
With the git binary path now being available in the HookPayload since
the preceding commit, this commit converts code to inject the path via
the HooksPayload now. The old environment variable is not being set
anymore.
-rw-r--r-- | internal/git/hooks_options.go | 1 | ||||
-rw-r--r-- | internal/git/hooks_payload.go | 1 | ||||
-rw-r--r-- | internal/git/hooks_payload_test.go | 8 | ||||
-rw-r--r-- | internal/gitaly/service/smarthttp/receive_pack_test.go | 1 | ||||
-rw-r--r-- | internal/gitaly/service/ssh/receive_pack_test.go | 1 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/hook.rb | 1 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/hook_spec.rb | 1 |
7 files changed, 13 insertions, 1 deletions
diff --git a/internal/git/hooks_options.go b/internal/git/hooks_options.go index c7131df07..c7cd5f23e 100644 --- a/internal/git/hooks_options.go +++ b/internal/git/hooks_options.go @@ -54,7 +54,6 @@ func WithPackObjectsHookEnv(ctx context.Context, repo *gitalypb.Repository, cfg cc.env, payload, "GITALY_BIN_DIR="+cfg.BinDir, - "GITALY_GIT_BIN_PATH="+cfg.Git.BinPath, fmt.Sprintf("%s=%s", log.GitalyLogDirEnvKey, cfg.Logging.Dir), ) diff --git a/internal/git/hooks_payload.go b/internal/git/hooks_payload.go index e954f46b7..d20184862 100644 --- a/internal/git/hooks_payload.go +++ b/internal/git/hooks_payload.go @@ -86,6 +86,7 @@ func NewHooksPayload( return HooksPayload{ Repo: repo, BinDir: cfg.BinDir, + GitPath: cfg.Git.BinPath, InternalSocket: cfg.GitalyInternalSocketPath(), InternalSocketToken: cfg.Auth.Token, Transaction: tx, diff --git a/internal/git/hooks_payload_test.go b/internal/git/hooks_payload_test.go index e4b11136d..8e538832c 100644 --- a/internal/git/hooks_payload_test.go +++ b/internal/git/hooks_payload_test.go @@ -48,6 +48,7 @@ func TestHooksPayload(t *testing.T) { require.Equal(t, HooksPayload{ Repo: repo, BinDir: config.Config.BinDir, + GitPath: config.Config.Git.BinPath, InternalSocket: config.Config.GitalyInternalSocketPath(), }, payload) }) @@ -62,6 +63,7 @@ func TestHooksPayload(t *testing.T) { require.Equal(t, HooksPayload{ Repo: repo, BinDir: config.Config.BinDir, + GitPath: config.Config.Git.BinPath, InternalSocket: config.Config.GitalyInternalSocketPath(), Transaction: &tx, Praefect: &praefect, @@ -106,6 +108,7 @@ func TestHooksPayload(t *testing.T) { require.Equal(t, HooksPayload{ Repo: repo, BinDir: config.Config.BinDir, + GitPath: config.Config.Git.BinPath, InternalSocket: config.Config.GitalyInternalSocketPath(), InternalSocketToken: config.Config.Auth.Token, ReceiveHooksPayload: &ReceiveHooksPayload{ @@ -117,6 +120,11 @@ func TestHooksPayload(t *testing.T) { }) t.Run("payload with fallback git path", func(t *testing.T) { + defer func(old string) { + config.Config.Git.BinPath = old + }(config.Config.Git.BinPath) + config.Config.Git.BinPath = "" + env, err := NewHooksPayload(config.Config, repo, nil, nil, nil).Env() require.NoError(t, err) diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go index 86d0846f9..587437ead 100644 --- a/internal/gitaly/service/smarthttp/receive_pack_test.go +++ b/internal/gitaly/service/smarthttp/receive_pack_test.go @@ -90,6 +90,7 @@ func TestSuccessfulReceivePackRequest(t *testing.T) { require.Equal(t, git.HooksPayload{ BinDir: config.Config.BinDir, + GitPath: config.Config.Git.BinPath, InternalSocket: config.Config.GitalyInternalSocketPath(), InternalSocketToken: config.Config.Auth.Token, ReceiveHooksPayload: &git.ReceiveHooksPayload{ diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go index 681f703fc..94fb43b86 100644 --- a/internal/gitaly/service/ssh/receive_pack_test.go +++ b/internal/gitaly/service/ssh/receive_pack_test.go @@ -127,6 +127,7 @@ func TestReceivePackPushSuccess(t *testing.T) { require.Equal(t, git.HooksPayload{ BinDir: config.Config.BinDir, + GitPath: config.Config.Git.BinPath, InternalSocket: config.Config.GitalyInternalSocketPath(), InternalSocketToken: config.Config.Auth.Token, ReceiveHooksPayload: &git.ReceiveHooksPayload{ diff --git a/ruby/lib/gitlab/git/hook.rb b/ruby/lib/gitlab/git/hook.rb index 3d6da9b9a..a41df57d3 100644 --- a/ruby/lib/gitlab/git/hook.rb +++ b/ruby/lib/gitlab/git/hook.rb @@ -113,6 +113,7 @@ module Gitlab payload = { repository: repository.gitaly_repository.to_json, binary_directory: Gitlab.config.gitaly.bin_dir, + git_path: Gitlab.config.git.bin_path, internal_socket: Gitlab.config.gitaly.internal_socket, internal_socket_token: ENV['GITALY_TOKEN'], receive_hooks_payload: { diff --git a/ruby/spec/lib/gitlab/git/hook_spec.rb b/ruby/spec/lib/gitlab/git/hook_spec.rb index 133051b5e..4839407e0 100644 --- a/ruby/spec/lib/gitlab/git/hook_spec.rb +++ b/ruby/spec/lib/gitlab/git/hook_spec.rb @@ -41,6 +41,7 @@ describe Gitlab::Git::Hook do 'GITALY_HOOKS_PAYLOAD' => Base64.strict_encode64({ repository: repo.gitaly_repository.to_json, binary_directory: Gitlab.config.gitaly.bin_dir, + git_path: Gitlab.config.git.bin_path, internal_socket: Gitlab.config.gitaly.internal_socket, internal_socket_token: nil, receive_hooks_payload: { |