Commit 22f6e2d765f35f20ec257af74d50c739c50308d6

Authored by Dmitriy Zaporozhets
2 parents 36bbcc6f e226551e

Merge pull request #2009 from gitlabhq/hook_on_mr_fix

Fix hooks for merge requests which were accepted by web-interface
Showing 1 changed file with 7 additions and 3 deletions   Show diff stats
app/workers/post_receive.rb
@@ -6,11 +6,15 @@ class PostReceive @@ -6,11 +6,15 @@ class PostReceive
6 return false if project.nil? 6 return false if project.nil?
7 7
8 # Ignore push from non-gitlab users 8 # Ignore push from non-gitlab users
9 - if /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)  
10 - return false unless user = User.find_by_email(identifier) 9 + user = if identifier.eql? Gitlab.config.gitolite_admin_key
  10 + email = project.commit(newrev).author.email
  11 + User.find_by_email(email)
  12 + elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier)
  13 + User.find_by_email(identifier)
11 else 14 else
12 - return false unless user = Key.find_by_identifier(identifier).try(:user) 15 + Key.find_by_identifier(identifier).try(:user)
13 end 16 end
  17 + return false unless user
14 18
15 project.trigger_post_receive(oldrev, newrev, ref, user) 19 project.trigger_post_receive(oldrev, newrev, ref, user)
16 end 20 end