Commit 8f0f6762 authored by Douwe Maan's avatar Douwe Maan

Write GitlabAccess error to stderr.

parent 63efd092
......@@ -14,5 +14,8 @@ if GitlabAccess.new(repo_path, key_id, refs).exec &&
GitlabCustomHook.new.pre_receive(refs, repo_path)
exit 0
else
# reset GL_ID env since we stop git push here
ENV['GL_ID'] = nil
exit 1
end
......@@ -5,6 +5,8 @@ require_relative 'names_helper'
require 'json'
class GitlabAccess
class AccessDeniedError < StandardError; end
include NamesHelper
attr_reader :config, :repo_path, :repo_name, :changes
......@@ -18,19 +20,16 @@ class GitlabAccess
end
def exec
begin
status = api.check_access('git-receive-pack', @repo_name, @actor, @changes)
return true if status.allowed?
raise AccessDeniedError, status.message unless status.allowed?
message = status.message
true
rescue GitlabNet::ApiUnreachableError
message = "Failed to authorize your Git request: internal API unreachable"
end
# reset GL_ID env since we stop git push here
ENV['GL_ID'] = nil
puts "GitLab: #{message}"
$stderr.puts "GitLab: Failed to authorize your Git request: internal API unreachable"
false
rescue AccessDeniedError => ex
$stderr.puts "GitLab: #{ex.message}"
false
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment