summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteven Thonus <steven@ln2.nl>2014-01-28 22:42:36 +0100
committerSteven Thonus <steven@ln2.nl>2014-03-25 22:13:15 +0100
commitf79bb5a307cd8ec5fa1c765779640667e70da5b4 (patch)
treef8bd79c49f75cc446095a75ec48eccd68e13d90d /lib
parentce88b74d52410250427116349d06a74359a65b48 (diff)
downloadgitlab-shell-f79bb5a307cd8ec5fa1c765779640667e70da5b4.tar.gz
first setup to protect protected branched to force updates
rebased for new code
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_net.rb2
-rw-r--r--lib/gitlab_update.rb7
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index e4b1808..cab64bd 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -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\//, "")
diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb
index 742d5fd..43d5b07 100644
--- a/lib/gitlab_update.rb
+++ b/lib/gitlab_update.rb
@@ -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