gitlab-org--gitlab-foss/lib/gitlab/checks/force_push.rb

26 lines
689 B
Ruby
Raw Normal View History

module Gitlab
module Checks
class ForcePush
def self.force_push?(project, oldrev, newrev)
return false if project.empty_repo?
# Created or deleted branch
2017-08-09 02:36:24 -04:00
return false if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
GitalyClient.migrate(:force_push) do |is_enabled|
if is_enabled
!project
.repository
.gitaly_commit_client
2017-08-24 13:52:43 -04:00
.ancestor?(oldrev, newrev)
2017-08-09 02:36:24 -04:00
else
Gitlab::Git::RevList.new(
project.repository.raw, oldrev: oldrev, newrev: newrev
).missed_ref.present?
2017-08-09 02:36:24 -04:00
end
end
end
end
end
end