Commit bacad39e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Make sure target has not changed during pre-receive hook

parent 9649f938
......@@ -34,7 +34,14 @@ class CommitService
repository.rugged.references.create(Gitlab::Git::BRANCH_REF_PREFIX + ref, sha)
else
# Update head
current_target = repository.find_branch(ref).target
# Make sure target branch was not changed during pre-receive hook
if current_target == target
repository.rugged.references.update(Gitlab::Git::BRANCH_REF_PREFIX + ref, sha)
else
raise CommitError.new('Commit was rejected because branch received new push')
end
end
# Run GitLab post receive hook
......
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