Class: Gitlab::Checks::ForcePush

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/checks/force_push.rb

Class Method Summary collapse

Class Method Details

.force_push?(project, oldrev, newrev) ⇒ Boolean

Returns:

  • (Boolean)

6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gitlab/checks/force_push.rb', line 6

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)

  !project
    .repository
    .gitaly_commit_client
    .ancestor?(oldrev, newrev)
end