summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-10-18 22:14:35 +0200
committerCiro Santilli <ciro.santilli@gmail.com>2014-11-17 17:59:35 +0100
commitcd9e796316560eee596f2681d54a8417389bbe79 (patch)
tree0a27a1e345ea81b941651a3b5d37ccc4cc551286
parentdbdcc5f400df466944ad5e55e8e03dee55de865f (diff)
downloadgitlab-shell-cd9e796316560eee596f2681d54a8417389bbe79.tar.gz
Restore hooks PATH before calling ruby.
-rw-r--r--CHANGELOG3
-rwxr-xr-xhooks/post-receive21
-rw-r--r--hooks/post-receive-main.rb18
-rwxr-xr-xhooks/pre-receive21
-rwxr-xr-xhooks/pre-receive-main.rb18
-rwxr-xr-xhooks/update20
-rwxr-xr-xhooks/update-main.rb17
7 files changed, 68 insertions, 50 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 4748fc2..66a169e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v2.3.0
+ - Restore PATH before calling hooks
+
v2.2.0
- Support for custom hooks (Drew Blessing and Jose Kahan)
diff --git a/hooks/post-receive b/hooks/post-receive
index 301f639..328084a 100755
--- a/hooks/post-receive
+++ b/hooks/post-receive
@@ -1,18 +1,5 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env bash
-# This file was placed here by GitLab. It makes sure that your pushed commits
-# will be processed properly.
-
-refs = ARGF.read
-key_id = ENV['GL_ID']
-repo_path = Dir.pwd
-
-require_relative '../lib/gitlab_custom_hook'
-require_relative '../lib/gitlab_post_receive'
-
-if GitlabPostReceive.new(repo_path, key_id, refs).exec &&
- GitlabCustomHook.new.post_receive(refs, repo_path)
- exit 0
-else
- exit 1
-end
+# Remove paths Git automatically prepends to PATH on hooks.
+export PATH="$GITLAB_PATH_OUTSIDE_HOOK"
+ruby "$GIT_DIR/hooks/post-receive-main.rb"
diff --git a/hooks/post-receive-main.rb b/hooks/post-receive-main.rb
new file mode 100644
index 0000000..301f639
--- /dev/null
+++ b/hooks/post-receive-main.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+
+# This file was placed here by GitLab. It makes sure that your pushed commits
+# will be processed properly.
+
+refs = ARGF.read
+key_id = ENV['GL_ID']
+repo_path = Dir.pwd
+
+require_relative '../lib/gitlab_custom_hook'
+require_relative '../lib/gitlab_post_receive'
+
+if GitlabPostReceive.new(repo_path, key_id, refs).exec &&
+ GitlabCustomHook.new.post_receive(refs, repo_path)
+ exit 0
+else
+ exit 1
+end
diff --git a/hooks/pre-receive b/hooks/pre-receive
index 7f9c0c0..420a046 100755
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@ -1,18 +1,5 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env bash
-# This file was placed here by GitLab. It makes sure that your pushed commits
-# will be processed properly.
-
-refs = ARGF.read
-key_id = ENV['GL_ID']
-repo_path = Dir.pwd
-
-require_relative '../lib/gitlab_custom_hook'
-require_relative '../lib/gitlab_access'
-
-if GitlabAccess.new(repo_path, key_id, refs).exec &&
- GitlabCustomHook.new.pre_receive(refs, repo_path)
- exit 0
-else
- exit 1
-end
+# Remove paths Git automatically prepends to PATH on hooks.
+export PATH="$GITLAB_PATH_OUTSIDE_HOOK"
+ruby "$GIT_DIR/hooks/pre-receive-main.rb"
diff --git a/hooks/pre-receive-main.rb b/hooks/pre-receive-main.rb
new file mode 100755
index 0000000..7f9c0c0
--- /dev/null
+++ b/hooks/pre-receive-main.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+
+# This file was placed here by GitLab. It makes sure that your pushed commits
+# will be processed properly.
+
+refs = ARGF.read
+key_id = ENV['GL_ID']
+repo_path = Dir.pwd
+
+require_relative '../lib/gitlab_custom_hook'
+require_relative '../lib/gitlab_access'
+
+if GitlabAccess.new(repo_path, key_id, refs).exec &&
+ GitlabCustomHook.new.pre_receive(refs, repo_path)
+ exit 0
+else
+ exit 1
+end
diff --git a/hooks/update b/hooks/update
index f1ac8e7..5d8d06d 100755
--- a/hooks/update
+++ b/hooks/update
@@ -1,17 +1,5 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env bash
-# This file was placed here by GitLab. It makes sure that your pushed commits
-# will be processed properly.
-
-ref_name = ARGV[0]
-old_value = ARGV[1]
-new_value = ARGV[2]
-repo_path = Dir.pwd
-
-require_relative '../lib/gitlab_custom_hook'
-
-if GitlabCustomHook.new.update(ref_name, old_value, new_value, repo_path)
- exit 0
-else
- exit 1
-end
+# Remove paths Git automatically prepends to PATH on hooks.
+export PATH="$GITLAB_PATH_OUTSIDE_HOOK"
+ruby "$GIT_DIR/hooks/update-main.rb"
diff --git a/hooks/update-main.rb b/hooks/update-main.rb
new file mode 100755
index 0000000..f1ac8e7
--- /dev/null
+++ b/hooks/update-main.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+# This file was placed here by GitLab. It makes sure that your pushed commits
+# will be processed properly.
+
+ref_name = ARGV[0]
+old_value = ARGV[1]
+new_value = ARGV[2]
+repo_path = Dir.pwd
+
+require_relative '../lib/gitlab_custom_hook'
+
+if GitlabCustomHook.new.update(ref_name, old_value, new_value, repo_path)
+ exit 0
+else
+ exit 1
+end