Commit 00bf9fe3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'git-hooks-initial-push' into 'master'

Fix git hook validation on initial push to master branch.

Addresses #305.

See merge request !434
parents 1081dfc5 52574ba7
v 7.12 (Unreleased)
v 7.13 (Unrelease)
- Fix git hook validation on initial push to master branch.
v 7.12
- Fix error when viewing merge request with a commit that includes "Closes #<issue id>".
- Enhance LDAP group synchronization to check also for member attributes that only contain "uid=<username>"
- Enhance LDAP group synchronization to check also for submember attributes
......
......@@ -182,13 +182,18 @@ module Gitlab
return build_status_object(false, "You can not delete tag")
end
else
# Check commit messages unless its branch removal
if git_hook.commit_validation? && !Gitlab::Git.blank_ref?(newrev)
if Gitlab::Git.blank_ref?(oldrev)
oldrev = project.default_branch
return build_status_object(true) unless git_hook.commit_validation?
return build_status_object(true) if Gitlab::Git.blank_ref?(newrev)
oldrev = project.default_branch if Gitlab::Git.blank_ref?(oldrev)
commits =
if oldrev
project.repository.commits_between(oldrev, newrev)
else
project.repository.commits(newrev)
end
commits = project.repository.commits_between(oldrev, newrev)
commits.each do |commit|
if git_hook.commit_message_regex.present?
unless commit.safe_message =~ Regexp.new(git_hook.commit_message_regex)
......@@ -239,7 +244,6 @@ module Gitlab
end
end
end
end
build_status_object(true)
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