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
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|