gitlab-org--gitlab-foss/lib/gitlab/force_push_check.rb
Dmitriy Zaporozhets 835cbc06d8
Reload mr code on force push too
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-02 17:42:56 +02:00

15 lines
423 B
Ruby

module Gitlab
class ForcePushCheck
def self.force_push?(project, oldrev, newrev)
return false if project.empty_repo?
if oldrev != Gitlab::Git::BLANK_SHA && newrev != Gitlab::Git::BLANK_SHA
missed_refs = IO.popen(%W(git --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev})).read
missed_refs.split("\n").size > 0
else
false
end
end
end
end