Commit eda86767 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Prevent mirror service from calling Gitaly too much

parent 02c9babf
......@@ -128,7 +128,7 @@ module Projects
remote_ref_id = remote_ref.dereferenced_target.try(:id)
if remote_ref_id && project.repository.is_ancestor?(remote_ref_id, default_branch_id)
if remote_ref_id && project.repository.rugged_is_ancestor?(remote_ref_id, default_branch_id)
refs_to_delete << name
end
end
......
......@@ -360,6 +360,13 @@ module Gitlab
rugged.merge_base(from, to)
end
# Gitaly note: JV: check gitlab-ee before removing this method.
def rugged_is_ancestor?(ancestor_id, descendant_id)
return false if ancestor_id.nil? || descendant_id.nil?
merge_base_commit(ancestor_id, descendant_id) == ancestor_id
end
# Returns true is +from+ is direct ancestor to +to+, otherwise false
def is_ancestor?(from, to)
gitaly_commit_client.is_ancestor(from, to)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment