Commit a770e807 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'commits-are-ancestors' into 'master'

Prevent mirror service from calling Gitaly too much

Closes gitaly#418

See merge request !2566
parents 9840accf eda86767
......@@ -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