Commit d5adeb1f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #128 from...

Merge pull request #128 from Popl7/add-better-branch-protection-against-history-rewrite-and-deletion

protect protected branched to force updates
parents ce88b74d f79bb5a3
......@@ -6,7 +6,7 @@ require_relative 'gitlab_config'
require_relative 'gitlab_logger'
class GitlabNet
def allowed?(cmd, repo, actor, ref, oldrev = nil, newrev = nil)
def allowed?(cmd, repo, actor, ref, oldrev = nil, newrev = nil, forced_push = false)
project_name = repo.gsub("'", "")
project_name = project_name.gsub(/\.git\Z/, "")
project_name = project_name.gsub(/\A\//, "")
......
......@@ -22,12 +22,17 @@ class GitlabUpdate
@newrev = ARGV[2]
end
def forced_push?
missed_refs = IO.popen(%W(git rev-list #{@newrev}..#{@oldrev} --)).read
missed_refs.split("\n").size > 0
end
def exec
# reset GL_ID env since we already
# get value from it
ENV['GL_ID'] = nil
if api.allowed?('git-receive-pack', @repo_name, @actor, @ref_name, @oldrev, @newrev)
if api.allowed?('git-receive-pack', @repo_name, @actor, @ref_name, @oldrev, @newrev, forced_push)
update_redis
exit 0
else
......
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