Skip to content

Commit

Permalink
Builder: More readable RSS feed commit list
Browse files Browse the repository at this point in the history
Attempting to make the list more readable by grouping commits
and simplifying the output.
  • Loading branch information
skyjake committed Jan 5, 2012
1 parent facc74c commit 6a30a44
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
72 changes: 42 additions & 30 deletions distrib/builder/changes.py
Expand Up @@ -139,23 +139,55 @@ def parse(self):
self.deduce_tags()

def all_tags(self):
tags = ['Cleanup', 'Fixed', 'Added', 'Refactor', 'Performance', 'Optimize']
# These words are always considered to be valid tags.
tags = ['Cleanup', 'Fixed', 'Added', 'Refactor', 'Performance', 'Optimize', 'merge branch']
for e in self.entries:
for t in e.tags + e.guessedTags:
if t not in tags:
tags.append(t)
return tags

def deduce_tags(self):
# Look for known tags in untagged titles.
allTags = self.all_tags()
for entry in self.entries:
if entry.tags: continue
# This entry has no tags yet.
for tag in allTags:
if tag.lower() in entry.subject.lower():
p = entry.subject.lower().find(tag.lower())
if p < 0: continue
if p == 0 or entry.subject[p - 1] not in string.ascii_letters + '-_':
entry.guessedTags.append(tag)

def form_groups(self, allEntries):
groups = {}
for tag in self.all_tags():
groups[tag] = []
for e in allEntries:
if tag in e.tags:
groups[tag].append(e)
for e in allEntries:
if tag in e.guessedTags:
groups[tag].append(e)

for e in groups[tag]:
allEntries.remove(e)

groups['Miscellaneous'] = []
for e in allEntries:
groups['Miscellaneous'].append(e)

return groups

def pretty_group_list(self, tags):
listed = ''
if len(tags) > 1:
listed = string.join(tags[:-1], ', ')
listed += ' and ' + tags[-1]
elif len(tags) == 1:
listed = tags[0]
return listed

def generate(self, format):
fromTag = self.fromTag
toTag = self.toTag
Expand All @@ -172,24 +204,9 @@ def generate(self, format):
(self.entries[-1].link, self.entries[-1].date)

# Form groups.
groups = {}
for tag in self.all_tags():
groups[tag] = []
for e in entries:
if tag in e.tags:
groups[tag].append(e)
for e in entries:
if tag in e.guessedTags:
groups[tag].append(e)

for e in groups[tag]:
entries.remove(e)

groups['Other'] = []
for e in entries:
groups['Other'].append(e)

groups = self.form_groups(entries)
keys = groups.keys()
# Sort case-insensitively by group name.
keys.sort(cmp=lambda a, b: cmp(str(a).lower(), str(b).lower()))
for group in keys:
if not len(groups[group]): continue
Expand All @@ -203,19 +220,14 @@ def generate(self, format):
for tag in entry.tags + entry.guessedTags:
if tag != group:
otherGroups.append(tag)
others = ''
if len(otherGroups) > 1:
others = string.join(otherGroups[:-1], ', ')
others += ' and ' + otherGroups[-1]
elif len(otherGroups) == 1:
others = otherGroups[0]


others = self.pretty_group_list(otherGroups)
if others: others = ' <i>(also %s)</i>' % others

print >> out, '<li><b>%s</b>%s<br/>' % (entry.subject, others)
print >> out, '<li><b>%s</b>%s' % (entry.subject, others)
print >> out, 'by <i>%s</i> on ' % entry.author
print >> out, '<a href="%s">%s</a>' % (entry.link, entry.date)
print >> out, '<blockquote style="color:#808080;">%s</blockquote>' % entry.message
print >> out, '<blockquote style="color:#666;">%s</blockquote>' % entry.message

print >> out, '</ul>'
out.close()
Expand All @@ -233,7 +245,7 @@ def generate(self, format):
if entry.tags or entry.guessedTags:
print >> out, '<tags>'
for t in entry.tags:
print >> out, '<tag>%s</tag>' % t
print >> out, '<tag guessed="false">%s</tag>' % t
for t in entry.guessedTags:
print >> out, '<tag guessed="true">%s</tag>' % t
print >> out, '</tags>'
Expand Down
2 changes: 1 addition & 1 deletion distrib/builder/event.py
Expand Up @@ -249,7 +249,7 @@ def html_description(self, encoded=True):
chgFn = self.file_path('changes.html')
if os.path.exists(chgFn):
if utils.count_word('<li>', file(chgFn).read()):
msg += '<p><b>Commits</b></p>' + file(chgFn, 'rt').read()
msg += '<h2>Commits</h2>' + file(chgFn, 'rt').read()

# Enclose it in a CDATA block if needed.
if encoded: return '<![CDATA[' + msg + ']]>'
Expand Down

0 comments on commit 6a30a44

Please sign in to comment.