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' ...@@ -6,7 +6,7 @@ require_relative 'gitlab_config'
require_relative 'gitlab_logger' require_relative 'gitlab_logger'
class GitlabNet 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 = repo.gsub("'", "")
project_name = project_name.gsub(/\.git\Z/, "") project_name = project_name.gsub(/\.git\Z/, "")
project_name = project_name.gsub(/\A\//, "") project_name = project_name.gsub(/\A\//, "")
......
...@@ -22,12 +22,17 @@ class GitlabUpdate ...@@ -22,12 +22,17 @@ class GitlabUpdate
@newrev = ARGV[2] @newrev = ARGV[2]
end end
def forced_push?
missed_refs = IO.popen(%W(git rev-list #{@newrev}..#{@oldrev} --)).read
missed_refs.split("\n").size > 0
end
def exec def exec
# reset GL_ID env since we already # reset GL_ID env since we already
# get value from it # get value from it
ENV['GL_ID'] = nil 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 update_redis
exit 0 exit 0
else 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