98affa75ed
We stop relying on Gitlab::Git::Env for the RevList class, and use Gitlab::Git::Repository#run_git methods inteaad. The refactor also fixes another issue, since we now top using "path_to_repo" (which is a Repository model method).
25 lines
689 B
Ruby
25 lines
689 B
Ruby
module Gitlab
|
|
module Checks
|
|
class ForcePush
|
|
def self.force_push?(project, oldrev, newrev)
|
|
return false if project.empty_repo?
|
|
|
|
# Created or deleted branch
|
|
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
|
|
.ancestor?(oldrev, newrev)
|
|
else
|
|
Gitlab::Git::RevList.new(
|
|
project.repository.raw, oldrev: oldrev, newrev: newrev
|
|
).missed_ref.present?
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|