2018-10-11 20:12:21 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-18 08:16:56 +00:00
|
|
|
module Gitlab
|
|
|
|
module Checks
|
|
|
|
class ForcePush
|
2017-04-05 07:35:58 +00:00
|
|
|
def self.force_push?(project, oldrev, newrev)
|
2016-07-18 08:16:56 +00:00
|
|
|
return false if project.empty_repo?
|
|
|
|
|
|
|
|
# Created or deleted branch
|
2017-08-09 06:36:24 +00:00
|
|
|
return false if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
|
|
|
|
|
2018-06-19 13:01:36 +00:00
|
|
|
!project
|
|
|
|
.repository
|
|
|
|
.gitaly_commit_client
|
|
|
|
.ancestor?(oldrev, newrev)
|
2016-07-18 08:16:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|