summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-06-17 15:41:59 +0000
committerRémy Coutable <remy@rymai.me>2016-06-17 15:41:59 +0000
commit802409571d53469a70ea66dcf24b1214ac525044 (patch)
tree7d125b8042ac423caf558f2b8d885d3d5886f783 /app/models
parent9b7fd74805684c09d8de314d4eee67b470cb57eb (diff)
parent7022357c8cd7888e04252b8964882d0e081032df (diff)
downloadgitlab-ce-802409571d53469a70ea66dcf24b1214ac525044.tar.gz
Merge branch '14918-add-filter-dropdown-to-tag-page' into 'master'
Add sorting dropdown to tag page ## What does this MR do? Adds a sorting dropdown to the tags page just like the one on the branches page. ## Are there points in the code the reviewer needs to double check? No ## Why was this MR needed? Clients were asking for this ## What are the relevant issue numbers? Closes #14918 ## Screenshots (if relevant) ![Captura_de_pantalla_2016-06-01_a_las_4.07.58_p.m.](/uploads/4530683ddd91d3bdbdce77748fe63f87/Captura_de_pantalla_2016-06-01_a_las_4.07.58_p.m..png) See merge request !4423
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 65d1bad511d..bbd7682d8e7 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -598,6 +598,21 @@ class Repository
end
end
+ def tags_sorted_by(value)
+ case value
+ when 'name'
+ # Would be better to use `sort_by` but `version_sorter` only exposes
+ # `sort` and `rsort`
+ VersionSorter.rsort(tag_names).map { |tag_name| find_tag(tag_name) }
+ when 'updated_desc'
+ tags_sorted_by_committed_date.reverse
+ when 'updated_asc'
+ tags_sorted_by_committed_date
+ else
+ tags
+ end
+ end
+
def contributors
commits = self.commits(nil, limit: 2000, offset: 0, skip_merges: true)
@@ -995,4 +1010,8 @@ class Repository
def file_on_head(regex)
tree(:head).blobs.find { |file| file.name =~ regex }
end
+
+ def tags_sorted_by_committed_date
+ tags.sort_by { |tag| commit(tag.target).committed_date }
+ end
end