Add Repository#is_ancestor? convenience method.

This commit is contained in:
Douwe Maan
2015-11-11 16:41:00 +01:00
parent f27d841894
commit 89620ddcf5
+6 -1
View File
@@ -505,7 +505,7 @@ class Repository
root_ref_commit = commit(root_ref)
if branch_commit
rugged.merge_base(root_ref_commit.id, branch_commit.id) == branch_commit.id
is_ancestor?(branch_commit.id, root_ref_commit.id)
else
nil
end
@@ -515,6 +515,11 @@ class Repository
rugged.merge_base(first_commit_id, second_commit_id)
end
def is_ancestor?(ancestor_id, descendant_id)
merge_base(ancestor_id, descendant_id) == ancestor_id
end
def search_files(query, ref)
offset = 2
args = %W(#{Gitlab.config.git.bin_path} grep -i -n --before-context #{offset} --after-context #{offset} -e #{query} #{ref || root_ref})