From fe67e4941dc89fde1bfbd459449cc7cdf9efec6c Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Apr 11 2016 14:27:26 +0000 Subject: made the tagnames sent to the template use a dict --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 99c0e11..f287a4c 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1246,26 +1246,30 @@ def get_git_tags_objects(project): The list is sorted using the time of the commit associated to the tag """ repopath = pagure.get_repo_path(project) repo_obj = PagureRepo(repopath) - tags = [ - [repo_obj[repo_obj.lookup_reference(tag).target], tag.replace("refs/tags/","")] - for tag in repo_obj.listall_references() - if 'refs/tags/' in tag and repo_obj.lookup_reference(tag) - ] - + tags = {} + for tag in repo_obj.listall_references(): + if 'refs/tags/' in tag and repo_obj.lookup_reference(tag): + commit_time = "" + theobject = repo_obj[repo_obj.lookup_reference(tag).target] + objecttype = "" + print theobject + if isinstance(theobject, pygit2.Tag): + commit_time = theobject.get_object().commit_time + objecttype = "tag" + elif isinstance(reference, pygit2.Commit): + commit_time = theobject.commit_time + objecttype = "commit" + + tags[commit_time] = { + "object":repo_obj[repo_obj.lookup_reference(tag).target], + "tagname":tag.replace("refs/tags/",""), + "date":commit_time, + "objecttype": objecttype + } + print tags sorted_tags = [] - tags_sort = {} - - for tag in tags: - # If the object is a tag, get his associated commit time - if isinstance(tag[0], pygit2.Tag): - tags_sort[tag[0].get_object().commit_time] = [tag[0].get_object().commit_time, tag[0]] - elif isinstance(tag[0], pygit2.Commit): - tags_sort[tag[0].commit_time] = [tag[0].commit_time, tag[0], tag[1]] - # If object is neither a tag or commit return an unsorted list - else: - return tags - for tag in sorted(tags_sort, reverse=True): - sorted_tags.append(tags_sort[tag]) + for tag in sorted(tags, reverse=True): + sorted_tags.append(tags[tag]) return sorted_tags diff --git a/pagure/templates/releases.html b/pagure/templates/releases.html index ed89881..7d96d75 100644 --- a/pagure/templates/releases.html +++ b/pagure/templates/releases.html @@ -33,14 +33,17 @@ {% if tags %}
{% for tag in tags %} - -
{{tag[0] | humanize }} {{ tag[1].oid | short }}
- {% if tag|length == 2 %} - {% if tag[1].message %} - {{tag[1].name}} - {{ tag[1].message.split('\n')[0] }} - {% set detailtext = tag[1].message.partition('\n')[2] %} +
+
{{tag['date'] }} + {{ tag['object'].oid | short }} +
+ {% if tag['objecttype'] == "tag" %} + {% if tag['object'].message %} + {{tag['name']}} + {{ tag['object'].message.split('\n')[0] }} + {% set detailtext = tag['object'].message.partition('\n')[2] %} {% if detailtext != "" %}
{{ detailtext }} @@ -48,7 +51,7 @@ {% endif %} {% endif %} {% else %} - {{tag[2]}} + {{tag['name']}} {% endif %} {% endfor %}