Commit 80e984ee5e6d29431a4a87ed26105fb0e8987ffb
1 parent
db7e0bf8
Exists in
master
and in
4 other branches
Fix project lookup in post receive
Showing
2 changed files
with
8 additions
and
6 deletions
Show diff stats
app/workers/post_receive.rb
1 | 1 | class PostReceive |
2 | 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 | 9 | return false if project.nil? |
7 | 10 | |
8 | 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 | 13 | email = project.commit(newrev).author.email rescue nil |
11 | 14 | User.find_by_email(email) if email |
12 | 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 | 6 | while read oldrev newrev ref |
7 | 7 | do |
8 | 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 | 11 | done | ... | ... |