2014-12-02 10:42:56 -05:00
|
|
|
module Gitlab
|
|
|
|
class ForcePushCheck
|
|
|
|
def self.force_push?(project, oldrev, newrev)
|
|
|
|
return false if project.empty_repo?
|
|
|
|
|
2015-03-19 05:34:04 -04:00
|
|
|
# Created or deleted branch
|
|
|
|
if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
|
|
|
|
false
|
|
|
|
else
|
2015-11-03 17:10:38 -05:00
|
|
|
missed_refs, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev}))
|
2014-12-02 10:42:56 -05:00
|
|
|
missed_refs.split("\n").size > 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|