Skip to content

Modify environment before calling Ruby #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage/
.bundle
tags
.bundle/
hooks/.env
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.5.0
- Restore PATH before calling hooks v2

v2.4.0
- Show error message when git access is rejected

v2.2.0
- Support for custom hooks (Drew Blessing and Jose Kahan)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.5.0
21 changes: 4 additions & 17 deletions hooks/post-receive
Original file line number Diff line number Diff line change
@@ -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.
. "$GIT_DIR/hooks/.env"
ruby "$GIT_DIR/hooks/post-receive-main.rb"
18 changes: 18 additions & 0 deletions hooks/post-receive-main.rb
Original file line number Diff line number Diff line change
@@ -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
21 changes: 4 additions & 17 deletions hooks/pre-receive
Original file line number Diff line number Diff line change
@@ -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.
. "$GIT_DIR/hooks/.env"
ruby "$GIT_DIR/hooks/pre-receive-main.rb"
18 changes: 18 additions & 0 deletions hooks/pre-receive-main.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 4 additions & 16 deletions hooks/update
Original file line number Diff line number Diff line change
@@ -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.
. "$GIT_DIR/hooks/.env"
ruby "$GIT_DIR/hooks/update-main.rb"
17 changes: 17 additions & 0 deletions hooks/update-main.rb
Original file line number Diff line number Diff line change
@@ -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