debian-mirror-gitlab/lib/gitlab/checks/force_push.rb

18 lines
528 B
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
module Gitlab
module Checks
class ForcePush
def self.force_push?(project, oldrev, newrev)
return false if project.empty_repo?
# Created or deleted branch
if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
false
else
2016-09-13 17:45:13 +05:30
missed_ref, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list --max-count=1 #{oldrev} ^#{newrev}))
missed_ref.present?
2016-08-24 12:49:21 +05:30
end
end
end
end
end