Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-10 14:15:36 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-10 14:15:36 +0300
commit59e7b7a654dca0a537c50dfc59fbf5a33a03a345 (patch)
tree9dfaacf2946449c6a817c008e2f89e331a84476d /app/services
parent99585a738cdf119ca59ce932b4ac0f278f6fda88 (diff)
Refactor Trigger post-receive hooks after commits are made by GitLab
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/services')
-rw-r--r--app/services/post_commit_service.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/app/services/post_commit_service.rb b/app/services/post_commit_service.rb
index aa9a807b7d2..8592c8d238b 100644
--- a/app/services/post_commit_service.rb
+++ b/app/services/post_commit_service.rb
@@ -1,36 +1,37 @@
class PostCommitService < BaseService
include Gitlab::Popen
- attr_reader :changes
+ attr_reader :changes, :repo_path
def execute(sha, branch)
commit = repository.commit(sha)
- full_ref = 'refs/heads/' + branch
+ full_ref = Gitlab::Git::BRANCH_REF_PREFIX + branch
old_sha = commit.parent_id || Gitlab::Git::BLANK_SHA
-
@changes = "#{old_sha} #{sha} #{full_ref}"
- post_receive(@changes, repository.path_to_repo)
+ @repo_path = repository.path_to_repo
+
+ post_receive
end
private
- def post_receive(changes, repo_path)
+ def post_receive
hook = hook_file('post-receive', repo_path)
return true if hook.nil?
- call_receive_hook(hook, changes) ? true : false
+ call_receive_hook(hook)
end
- def call_receive_hook(hook, changes)
+ def call_receive_hook(hook)
# function will return true if succesful
exit_status = false
vars = {
'GL_ID' => Gitlab::ShellEnv.gl_id(current_user),
- 'PWD' => repository.path_to_repo
+ 'PWD' => repo_path
}
options = {
- chdir: repository.path_to_repo
+ chdir: repo_path
}
# we combine both stdout and stderr as we don't know what stream
@@ -45,7 +46,7 @@ class PostCommitService < BaseService
begin
# inject all the changes as stdin to the hook
changes.lines do |line|
- stdin.puts (line)
+ stdin.puts line
end
rescue Errno::EPIPE
end
@@ -56,7 +57,6 @@ class PostCommitService < BaseService
# only output stdut_stderr if scripts doesn't return 0
unless wait_thr.value == 0
exit_status = false
- stdout_stderr.each_line { |line| puts line }
end
end