Update post-receive worker to use correct identifier
This commit is contained in:
parent
ed3f44085e
commit
b698094d4d
2 changed files with 12 additions and 11 deletions
|
@ -21,14 +21,18 @@ class PostReceive
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ignore push from non-gitlab users
|
user = if identifier.blank?
|
||||||
user = if identifier.nil?
|
# Local push from gitlab
|
||||||
raise identifier.inspect
|
|
||||||
email = project.repository.commit(newrev).author.email rescue nil
|
email = project.repository.commit(newrev).author.email rescue nil
|
||||||
User.find_by_email(email) if email
|
User.find_by_email(email) if email
|
||||||
elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
|
|
||||||
User.find_by_email(identifier)
|
elsif identifier =~ /\Auser-\d+\Z/
|
||||||
elsif identifier =~ /key/
|
# git push over http
|
||||||
|
user_id = identifier.gsub("user-", "")
|
||||||
|
User.find_by_id(user_id)
|
||||||
|
|
||||||
|
elsif identifier =~ /\Akey-\d+\Z/
|
||||||
|
# git push over ssh
|
||||||
key_id = identifier.gsub("key-", "")
|
key_id = identifier.gsub("key-", "")
|
||||||
Key.find_by_id(key_id).try(:user)
|
Key.find_by_id(key_id).try(:user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,9 +7,6 @@ module Grack
|
||||||
@request = Rack::Request.new(env)
|
@request = Rack::Request.new(env)
|
||||||
@auth = Request.new(env)
|
@auth = Request.new(env)
|
||||||
|
|
||||||
# Pass Gitolite update hook
|
|
||||||
ENV['GL_BYPASS_UPDATE_HOOK'] = "true"
|
|
||||||
|
|
||||||
# Need this patch due to the rails mount
|
# Need this patch due to the rails mount
|
||||||
@env['PATH_INFO'] = @request.path
|
@env['PATH_INFO'] = @request.path
|
||||||
@env['SCRIPT_NAME'] = ""
|
@env['SCRIPT_NAME'] = ""
|
||||||
|
@ -35,8 +32,8 @@ module Grack
|
||||||
self.user = User.find_by_email(login) || User.find_by_username(login)
|
self.user = User.find_by_email(login) || User.find_by_username(login)
|
||||||
return false unless user.try(:valid_password?, password)
|
return false unless user.try(:valid_password?, password)
|
||||||
|
|
||||||
# Set GL_USER env variable
|
# Set GL_ID env variable
|
||||||
ENV['GL_USER'] = user.email
|
ENV['GL_ID'] = "user-#{user.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Git upload and receive
|
# Git upload and receive
|
||||||
|
|
Loading…
Add table
Reference in a new issue