From b698094d4dcd1558bfcc1611d3572297dd11ae1e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 14 Feb 2013 14:00:02 +0200 Subject: [PATCH] Update post-receive worker to use correct identifier --- app/workers/post_receive.rb | 16 ++++++++++------ lib/gitlab/backend/grack_auth.rb | 7 ++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index e3f62d736ef..3ef6d5977cf 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -21,14 +21,18 @@ class PostReceive return false end - # Ignore push from non-gitlab users - user = if identifier.nil? - raise identifier.inspect + user = if identifier.blank? + # Local push from gitlab email = project.repository.commit(newrev).author.email rescue nil 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 =~ /key/ + + elsif identifier =~ /\Auser-\d+\Z/ + # 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.find_by_id(key_id).try(:user) end diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index a2d15d57034..8fcafe4ea9d 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -7,9 +7,6 @@ module Grack @request = Rack::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 @env['PATH_INFO'] = @request.path @env['SCRIPT_NAME'] = "" @@ -35,8 +32,8 @@ module Grack self.user = User.find_by_email(login) || User.find_by_username(login) return false unless user.try(:valid_password?, password) - # Set GL_USER env variable - ENV['GL_USER'] = user.email + # Set GL_ID env variable + ENV['GL_ID'] = "user-#{user.id}" end # Git upload and receive