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
true
end
end
def commit_validation?
commit_message_regex.present? || author_email_regex.present? || member_check
end
end
......@@ -214,8 +214,7 @@ class User < ActiveRecord::Base
end
def existing_member?(email)
!!(User.where(email: email).first ||
User.joins(:emails).where(emails: { email: email }).first)
User.where(email: email).any? || Email.where(email: email).any?
end
def filter(filter_name)
......
......@@ -109,12 +109,13 @@ module Gitlab
end
# 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.each do |commit|
if git_hook.commit_message_regex.present?
return false unless commit.safe_message =~ Regexp.new(git_hook.commit_message_regex)
end
if git_hook.author_email_regex.present?
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)
......@@ -156,5 +157,6 @@ module Gitlab
nil
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