Commit 80e984ee5e6d29431a4a87ed26105fb0e8987ffb

Authored by Dmitriy Zaporozhets
1 parent db7e0bf8

Fix project lookup in post receive

app/workers/post_receive.rb
1 class PostReceive 1 class PostReceive
2 @queue = :post_receive 2 @queue = :post_receive
3 3
4 - def self.perform(reponame, oldrev, newrev, ref, identifier)  
5 - project = Project.find_by_path(reponame) 4 + def self.perform(repo_path, oldrev, newrev, ref, identifier)
  5 + repo_path = repo_path.gsub(Gitlab.config.git_base_path, "")
  6 + repo_path = repo_path.gsub(/.git$/, "")
  7 +
  8 + project = Project.find_with_namespace(repo_path)
6 return false if project.nil? 9 return false if project.nil?
7 10
8 # Ignore push from non-gitlab users 11 # Ignore push from non-gitlab users
9 - user = if identifier.eql? Gitlab.config.gitolite_admin_key 12 + user = if identifier.eql? Gitlab.config.gitolite_admin_key
10 email = project.commit(newrev).author.email rescue nil 13 email = project.commit(newrev).author.email rescue nil
11 User.find_by_email(email) if email 14 User.find_by_email(email) if email
12 elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) 15 elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
lib/hooks/post-receive
@@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
6 while read oldrev newrev ref 6 while read oldrev newrev ref
7 do 7 do
8 # For every branch or tag that was pushed, create a Resque job in redis. 8 # For every branch or tag that was pushed, create a Resque job in redis.
9 - pwd=`pwd`  
10 - reponame=`basename "$pwd" | sed s/\.git$//`  
11 - env -i redis-cli rpush "resque:gitlab:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$reponame\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1 9 + repo_path=`pwd`
  10 + env -i redis-cli rpush "resque:gitlab:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$repo_path\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1
12 done 11 done