Class: Gitlab::ForcePushCheck

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

Class Method Summary collapse

Class Method Details

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

Returns:

  • (Boolean)

3
4
5
6
7
8
9
10
11
12
13
# File 'lib/gitlab/force_push_check.rb', line 3

def self.force_push?(project, oldrev, newrev)
  return false if project.empty_repo?

  # Created or deleted branch
  if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
    false
  else
    missed_refs, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev}))
    missed_refs.split("\n").size > 0
  end
end