mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-22 19:16:39 +10:00
Add Repository#is_ancestor? convenience method.
This commit is contained in:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user