Skip to content
Snippets Groups Projects
Commit 69e34af7 authored by Rubén Dávila's avatar Rubén Dávila
Browse files

Fix for triggering git hooks configured through Project settings.

* We should skip hooks only for new branch.
* The spec was using a wrong rev as the blank rev.
parent cf5f6039
Branches andrey-remove-group-caching
No related tags found
1 merge request!412Fix for triggering git hooks configured through Project settings.
Pipeline #
Loading
Loading
@@ -211,11 +211,13 @@ def git_hook_check(user, project, ref, oldrev, newrev)
return build_status_object(true)
end
 
blank_oldrev = Gitlab::Git.blank_ref?(oldrev)
# if oldrev is blank, the branch was just created
oldrev = project.default_branch if Gitlab::Git.blank_ref?(oldrev)
oldrev = project.default_branch if blank_oldrev
 
commits(newrev, oldrev, project).each do |commit|
next if commit_from_annex_sync?(commit.safe_message) || old_commit?(commit)
next if commit_from_annex_sync?(commit.safe_message) || (blank_oldrev && old_commit?(commit))
 
if status_object = check_commit(commit, git_hook)
return status_object
Loading
Loading
Loading
Loading
@@ -401,7 +401,7 @@ def self.updated_permissions_matrix
project.git_hook.update(commit_message_regex: "Change some files")
 
# push to new branch, so use a blank old rev and new ref
expect(access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9', '570e7b2abdd848b95f2f578043fc23bd6f6fd24d')).to be_allowed
expect(access.git_hook_check(user, project, 'refs/heads/master', Gitlab::Git::BLANK_SHA, '570e7b2abdd848b95f2f578043fc23bd6f6fd24d')).to be_allowed
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment