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

pre-receive « hooks « gitlab-shell « ruby - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66c61d98c99207296ab0c285724c7ca857664139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby

# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.

refs = $stdin.read
gl_id = ENV.delete('GL_ID')
protocol = ENV.delete('GL_PROTOCOL')
repo_path = Dir.pwd
gl_repository = ENV['GL_REPOSITORY']

def increase_reference_counter(gl_repository, repo_path)
  result = GitlabNet.new.pre_receive(gl_repository)

  result && result['reference_counter_increased']
end

require_relative '../lib/gitlab_custom_hook'
require_relative '../lib/gitlab_access'
require_relative '../lib/gitlab_net'

# It's important that on pre-receive `increase_reference_counter` gets executed
# last so that it only runs if everything else succeeded. On post-receive on the
# other hand, we run GitlabPostReceive first because the push is already done
# and we don't want to skip it if the custom hook fails.
if GitlabAccess.new(gl_repository, repo_path, gl_id, refs, protocol).exec &&
    GitlabCustomHook.new(repo_path, gl_id).pre_receive(refs) &&
    increase_reference_counter(gl_repository, repo_path)
  exit 0
else
  exit 1
end