diff options
author | Saito <saitowu@gmail.com> | 2012-07-02 12:44:45 +0400 |
---|---|---|
committer | Saito <saitowu@gmail.com> | 2012-07-02 12:44:45 +0400 |
commit | 401340168c4596a872fd5d94ec9d52b33886f45f (patch) | |
tree | 4ee851a56c5d8fee6f669005ac26b877d1aad361 /app/workers | |
parent | 82e2551833e7d9fd704a29a022fee0ac2ba18b2f (diff) |
bypass gitolite update hook, and set an GL_USER variable.
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/post_receive.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index 0ab9079c884..5311ede72e2 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -1,13 +1,17 @@ class PostReceive @queue = :post_receive - def self.perform(reponame, oldrev, newrev, ref, author_key_id) + def self.perform(reponame, oldrev, newrev, ref, identifier) project = Project.find_by_path(reponame) return false if project.nil? # Ignore push from non-gitlab users - return false unless Key.find_by_identifier(author_key_id) + if /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) + return false unless user = User.find_by_email(identifier) + else + return false unless user = Key.find_by_identifier(identifier).try(:user) + end - project.trigger_post_receive(oldrev, newrev, ref, author_key_id) + project.trigger_post_receive(oldrev, newrev, ref, user) end end |