Commit f79bb5a3 authored by Steven Thonus's avatar Steven Thonus

first setup to protect protected branched to force updates

rebased for new code
parent ce88b74d
......@@ -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