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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-12-11 09:57:36 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-12-11 11:59:33 +0300
commit971b8b34d9f6aa553903e9108e9d0c5c753df8cd (patch)
treebf08eeab04ecb91846b00c65460f5b0b609126c6
parent583fe49d808110f8646e2b1e851bf67ad29943fe (diff)
hooks: Stop injecting GL_PROJECT_PATH into the hooks environment
Same as with GL_REPOSITORY, we already have information about the GL_PROJECT_PATH available via the protobuf Repo. So this commit stops injecting the variable explicitly into the hooks environment and instead extends `customHooksEnv()` to derive it from the Repo.
-rw-r--r--internal/git/hooks_options.go1
-rw-r--r--internal/gitaly/hook/custom.go1
-rw-r--r--internal/gitaly/hook/postreceive_test.go2
-rw-r--r--internal/gitaly/hook/prereceive_test.go2
-rw-r--r--internal/gitaly/hook/update_test.go1
-rw-r--r--internal/gitaly/service/operations/update_with_hooks.go1
-rw-r--r--internal/gitaly/service/operations/update_with_hooks_test.go1
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go1
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go1
-rw-r--r--ruby/lib/gitlab/git/hook.rb1
10 files changed, 1 insertions, 11 deletions
diff --git a/internal/git/hooks_options.go b/internal/git/hooks_options.go
index f25e3efeb..93e147f97 100644
--- a/internal/git/hooks_options.go
+++ b/internal/git/hooks_options.go
@@ -92,7 +92,6 @@ func receivePackHookEnv(req ReceivePackRequest, protocol string) ([]string, erro
return []string{
fmt.Sprintf("GL_ID=%s", req.GetGlId()),
fmt.Sprintf("GL_USERNAME=%s", req.GetGlUsername()),
- fmt.Sprintf("GL_PROJECT_PATH=%s", req.GetRepository().GetGlProjectPath()),
fmt.Sprintf("GL_PROTOCOL=%s", protocol),
}, nil
}
diff --git a/internal/gitaly/hook/custom.go b/internal/gitaly/hook/custom.go
index 1dce751cc..0d92850d3 100644
--- a/internal/gitaly/hook/custom.go
+++ b/internal/gitaly/hook/custom.go
@@ -138,5 +138,6 @@ func validHook(fi os.FileInfo, filename string) bool {
func customHooksEnv(payload git.HooksPayload) []string {
return []string{
"GL_REPOSITORY=" + payload.Repo.GetGlRepository(),
+ "GL_PROJECT_PATH=" + payload.Repo.GetGlProjectPath(),
}
}
diff --git a/internal/gitaly/hook/postreceive_test.go b/internal/gitaly/hook/postreceive_test.go
index a48ba8819..c3e05614c 100644
--- a/internal/gitaly/hook/postreceive_test.go
+++ b/internal/gitaly/hook/postreceive_test.go
@@ -75,7 +75,6 @@ func TestPostReceive_customHook(t *testing.T) {
standardEnv := []string{
"GL_ID=1234",
- fmt.Sprintf("GL_PROJECT_PATH=%s", repo.GetGlProjectPath()),
"GL_PROTOCOL=web",
fmt.Sprintf("GL_REPO=%s", repo),
"GL_USERNAME=user",
@@ -266,7 +265,6 @@ func TestPostReceive_gitlab(t *testing.T) {
standardEnv := []string{
payload,
"GL_ID=1234",
- fmt.Sprintf("GL_PROJECT_PATH=%s", testRepo.GetGlProjectPath()),
"GL_PROTOCOL=web",
fmt.Sprintf("GL_REPO=%s", testRepo),
"GL_USERNAME=user",
diff --git a/internal/gitaly/hook/prereceive_test.go b/internal/gitaly/hook/prereceive_test.go
index 88a59e8eb..3d264c7c9 100644
--- a/internal/gitaly/hook/prereceive_test.go
+++ b/internal/gitaly/hook/prereceive_test.go
@@ -24,7 +24,6 @@ func TestPrereceive_customHooks(t *testing.T) {
standardEnv := []string{
"GL_ID=1234",
- fmt.Sprintf("GL_PROJECT_PATH=%s", repo.GetGlProjectPath()),
"GL_PROTOCOL=web",
fmt.Sprintf("GL_REPO=%s", repo),
"GL_USERNAME=user",
@@ -206,7 +205,6 @@ func TestPrereceive_gitlab(t *testing.T) {
standardEnv := []string{
payload,
"GL_ID=1234",
- fmt.Sprintf("GL_PROJECT_PATH=%s", testRepo.GetGlProjectPath()),
"GL_PROTOCOL=web",
fmt.Sprintf("GL_REPO=%s", testRepo),
"GL_USERNAME=user",
diff --git a/internal/gitaly/hook/update_test.go b/internal/gitaly/hook/update_test.go
index 43abde957..fe21f3882 100644
--- a/internal/gitaly/hook/update_test.go
+++ b/internal/gitaly/hook/update_test.go
@@ -21,7 +21,6 @@ func TestUpdate_customHooks(t *testing.T) {
standardEnv := []string{
"GL_ID=1234",
- fmt.Sprintf("GL_PROJECT_PATH=%s", repo.GetGlProjectPath()),
"GL_PROTOCOL=web",
fmt.Sprintf("GL_REPO=%s", repo),
"GL_USERNAME=user",
diff --git a/internal/gitaly/service/operations/update_with_hooks.go b/internal/gitaly/service/operations/update_with_hooks.go
index e18042531..5adf4bf85 100644
--- a/internal/gitaly/service/operations/update_with_hooks.go
+++ b/internal/gitaly/service/operations/update_with_hooks.go
@@ -56,7 +56,6 @@ func (s *Server) updateReferenceWithHooks(ctx context.Context, repo *gitalypb.Re
"GL_PROTOCOL=web",
fmt.Sprintf("GL_ID=%s", user.GetGlId()),
fmt.Sprintf("GL_USERNAME=%s", user.GetGlUsername()),
- fmt.Sprintf("GL_PROJECT_PATH=%s", repo.GetGlProjectPath()),
}
changes := fmt.Sprintf("%s %s %s\n", oldrev, newrev, reference)
diff --git a/internal/gitaly/service/operations/update_with_hooks_test.go b/internal/gitaly/service/operations/update_with_hooks_test.go
index 4699e12b2..a2f69c8a8 100644
--- a/internal/gitaly/service/operations/update_with_hooks_test.go
+++ b/internal/gitaly/service/operations/update_with_hooks_test.go
@@ -137,7 +137,6 @@ func TestUpdateReferenceWithHooks(t *testing.T) {
expectedEnv := []string{
payload,
"GL_ID=1234",
- "GL_PROJECT_PATH=gitlab-org/gitlab-test",
"GL_PROTOCOL=web",
"GL_USERNAME=Username",
}
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index e8e4488f1..57204f77a 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -76,7 +76,6 @@ func TestSuccessfulReceivePackRequest(t *testing.T) {
for _, env := range []string{
"GL_ID=user-123",
"GL_PROTOCOL=http",
- "GL_PROJECT_PATH=" + projectPath,
} {
require.Contains(t, strings.Split(string(envData), "\n"), env)
}
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index f006235e1..00b3394b8 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -102,7 +102,6 @@ func TestReceivePackPushSuccess(t *testing.T) {
for _, env := range []string{
"GL_ID=user-123",
- fmt.Sprintf("GL_PROJECT_PATH=%s", glProjectPath),
"GL_PROTOCOL=ssh",
} {
require.Contains(t, strings.Split(string(envData), "\n"), env)
diff --git a/ruby/lib/gitlab/git/hook.rb b/ruby/lib/gitlab/git/hook.rb
index 9ae733ef9..9876ef491 100644
--- a/ruby/lib/gitlab/git/hook.rb
+++ b/ruby/lib/gitlab/git/hook.rb
@@ -129,7 +129,6 @@ module Gitlab
'GITALY_BIN_DIR' => Gitlab.config.gitaly.bin_dir,
'GL_ID' => gl_id,
'GL_USERNAME' => gl_username,
- 'GL_PROJECT_PATH' => repository.gl_project_path,
'GL_PROTOCOL' => GL_PROTOCOL,
'PWD' => repo_path,
'GIT_DIR' => repo_path