diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-11-11 16:27:55 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-11-18 12:02:08 +0100 |
commit | 153085a93bf7f2350d15009fe7924cea190cd7f2 (patch) | |
tree | b81e793bbce9b4cdb096d87b6dbb18555c310207 | |
parent | a0519818cb4ff90d6a1d66b6360ec94f05bc79ec (diff) | |
download | gitlab-ce-153085a93bf7f2350d15009fe7924cea190cd7f2.tar.gz |
Add Repository#is_ancestor? convenience method.
-rw-r--r-- | app/models/repository.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index f76b770e867..c5b6ee80dc6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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}) |