Add Repository#is_ancestor? convenience method.
This commit is contained in:
parent
a0519818cb
commit
153085a93b
1 changed files with 6 additions and 1 deletions
|
@ -484,7 +484,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
|
||||
|
@ -494,6 +494,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})
|
||||
|
|
Loading…
Reference in a new issue