From 835cbc06d8d9c773a3b405eca81650378a8ccdcd Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Dec 2014 17:42:56 +0200 Subject: Reload mr code on force push too Signed-off-by: Dmitriy Zaporozhets --- lib/gitlab/force_push_check.rb | 15 +++++++++++++++ lib/gitlab/git_access.rb | 9 +-------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 lib/gitlab/force_push_check.rb (limited to 'lib') diff --git a/lib/gitlab/force_push_check.rb b/lib/gitlab/force_push_check.rb new file mode 100644 index 00000000000..6a52cdba608 --- /dev/null +++ b/lib/gitlab/force_push_check.rb @@ -0,0 +1,15 @@ +module Gitlab + class ForcePushCheck + def self.force_push?(project, oldrev, newrev) + return false if project.empty_repo? + + if oldrev != Gitlab::Git::BLANK_SHA && newrev != Gitlab::Git::BLANK_SHA + missed_refs = IO.popen(%W(git --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev})).read + missed_refs.split("\n").size > 0 + else + false + end + end + end +end + diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 5f8cb19efdf..8b4729896b5 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -94,14 +94,7 @@ module Gitlab end def forced_push?(project, oldrev, newrev) - return false if project.empty_repo? - - if oldrev != Gitlab::Git::BLANK_SHA && newrev != Gitlab::Git::BLANK_SHA - missed_refs = IO.popen(%W(git --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev})).read - missed_refs.split("\n").size > 0 - else - false - end + Gitlab::ForcePushCheck.force_push?(project, oldrev, newrev) end private -- cgit v1.2.1