Commit a7f0160f authored by Valery Sizov's avatar Valery Sizov Committed by Valery Sizov

git hook: code style

parent cc34c09e
...@@ -13,4 +13,8 @@ class GitHook < ActiveRecord::Base ...@@ -13,4 +13,8 @@ class GitHook < ActiveRecord::Base
true true
end end
end end
def commit_validation?
commit_message_regex.present? || author_email_regex.present? || member_check
end
end end
...@@ -214,8 +214,7 @@ class User < ActiveRecord::Base ...@@ -214,8 +214,7 @@ class User < ActiveRecord::Base
end end
def existing_member?(email) def existing_member?(email)
!!(User.where(email: email).first || User.where(email: email).any? || Email.where(email: email).any?
User.joins(:emails).where(emails: { email: email }).first)
end end
def filter(filter_name) def filter(filter_name)
......
...@@ -109,12 +109,13 @@ module Gitlab ...@@ -109,12 +109,13 @@ module Gitlab
end end
# Check commit messages unless its branch removal # Check commit messages unless its branch removal
if (git_hook.commit_message_regex.present? || git_hook.author_email_regex.present? || git_hook.member_check) && newrev !~ /00000000/ if git_hook.commit_validation? && newrev !~ /00000000/
commits = project.repository.commits_between(oldrev, newrev) commits = project.repository.commits_between(oldrev, newrev)
commits.each do |commit| commits.each do |commit|
if git_hook.commit_message_regex.present? if git_hook.commit_message_regex.present?
return false unless commit.safe_message =~ Regexp.new(git_hook.commit_message_regex) return false unless commit.safe_message =~ Regexp.new(git_hook.commit_message_regex)
end end
if git_hook.author_email_regex.present? if git_hook.author_email_regex.present?
return false unless commit.committer_email =~ Regexp.new(git_hook.author_email_regex) return false unless commit.committer_email =~ Regexp.new(git_hook.author_email_regex)
return false unless commit.author_email =~ Regexp.new(git_hook.author_email_regex) return false unless commit.author_email =~ Regexp.new(git_hook.author_email_regex)
...@@ -156,5 +157,6 @@ module Gitlab ...@@ -156,5 +157,6 @@ module Gitlab
nil nil
end end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment