From bdf0e7769fde6ed0a25c56906bb1d29db199fda3 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 13 Feb 2008 17:28:04 +0100 Subject: [PATCH] rss plugin: support git commits in trac Since git changes are identified by their SHA1, they get too long in titles. So we just clip that part out, as it's available in the link anyway. --- data/rbot/plugins/rss.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 1da488c3..5e854239 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -863,7 +863,14 @@ class RSSFeedsPlugin < Plugin # limit to 160 characters, and most of them are under 140 characters tit_opt[:limit] = @bot.config['rss.head_max'] unless feed.type == 'twitter' - title = "#{Bold}#{item.title.to_s.ircify_html(tit_opt)}#{Bold}" if item.title + if item.title + base_title = item.title.to_s.dup + # git changesets are SHA1 hashes (40 hex digits), way too long, get rid of them, as they are + # visible in the URL anyway + # TODO make this optional? + base_title.sub!(/^Changeset \[([\da-f]{40})\]/) { |c| "Changeset [...]"} if feed.type = 'trac' + title = "#{Bold}#{base_title.ircify_html(tit_opt)}#{Bold}" + end desc_opt = { :limit => @bot.config['rss.text_max'], @@ -910,7 +917,7 @@ class RSSFeedsPlugin < Plugin line1 = "#{handle}#{date}Message #{title} sent by #{author}. #{desc}" when 'trac' line1 = "#{handle}#{date}#{title} @ #{link}" - unless item.title =~ /^Changeset \[(\d+)\]/ + unless item.title =~ /^Changeset \[(?:[\da-f]+|\.\.\.)\]/ line2 = "#{handle}#{date}#{desc}" end when '/.' -- 2.39.5