summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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