2016-07-18 04:16:56 -04:00
|
|
|
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-07-19 15:01:30 -04:00
|
|
|
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-07-18 04:16:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|