Commit b698094d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Update post-receive worker to use correct identifier

parent ed3f4408
...@@ -21,14 +21,18 @@ class PostReceive ...@@ -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 ...@@ -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 ...@@ -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
......
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