diff options
Diffstat (limited to 'hooks/pre-receive')
-rwxr-xr-x | hooks/pre-receive | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/hooks/pre-receive b/hooks/pre-receive index e8e04d8..78ff991 100755 --- a/hooks/pre-receive +++ b/hooks/pre-receive @@ -9,9 +9,18 @@ protocol = ENV.delete('GL_PROTOCOL') repo_path = Dir.pwd gl_repository = ENV['GL_REPOSITORY'] +def increase_reference_counter(gl_repository) + result = GitlabNet.new.pre_receive(gl_repository) + + result['reference_counter_increased'] +rescue GitlabNet::NotFound + GitlabReferenceCounter.new(repo_path).increase +end + require_relative '../lib/gitlab_custom_hook' require_relative '../lib/gitlab_reference_counter' 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 @@ -19,7 +28,7 @@ require_relative '../lib/gitlab_access' # and we don't want to skip it if the custom hook fails. if GitlabAccess.new(gl_repository, repo_path, key_id, refs, protocol).exec && GitlabCustomHook.new(repo_path, key_id).pre_receive(refs) && - GitlabReferenceCounter.new(repo_path).increase + increase_reference_counter(gl_repository) exit 0 else exit 1 |