2016-07-18 04:16:56 -04:00
|
|
|
module Gitlab
|
|
|
|
module Checks
|
|
|
|
class ForcePush
|
2017-04-05 03:35:58 -04:00
|
|
|
def self.force_push?(project, oldrev, newrev)
|
2016-07-18 04:16:56 -04:00
|
|
|
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(
|
2018-01-31 14:25:38 -05:00
|
|
|
project.repository.raw, oldrev: oldrev, newrev: newrev
|
|
|
|
).missed_ref.present?
|
2017-08-09 02:36:24 -04:00
|
|
|
end
|
2016-07-18 04:16:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|