]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
rss plugin: support git commits in trac
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 13 Feb 2008 16:28:04 +0000 (17:28 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 13 Feb 2008 16:28:04 +0000 (17:28 +0100)
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

index 1da488c3d804ca2813318c6cf2d1e864cbdc7711..5e854239090db84da32454ccd6d119b0bf1e9a5a 100644 (file)
@@ -863,7 +863,14 @@ class RSSFeedsPlugin < Plugin
     # limit to 160 characters, and most of them are under 140 characters\r
     tit_opt[:limit] = @bot.config['rss.head_max'] unless feed.type == 'twitter'\r
 \r
-    title = "#{Bold}#{item.title.to_s.ircify_html(tit_opt)}#{Bold}" if item.title\r
+    if item.title\r
+      base_title = item.title.to_s.dup\r
+      # git changesets are SHA1 hashes (40 hex digits), way too long, get rid of them, as they are\r
+      # visible in the URL anyway\r
+      # TODO make this optional?\r
+      base_title.sub!(/^Changeset \[([\da-f]{40})\]/) { |c| "Changeset [...]"} if feed.type = 'trac'\r
+      title = "#{Bold}#{base_title.ircify_html(tit_opt)}#{Bold}"\r
+    end\r
 \r
     desc_opt = {\r
       :limit => @bot.config['rss.text_max'],\r
@@ -910,7 +917,7 @@ class RSSFeedsPlugin < Plugin
       line1 = "#{handle}#{date}Message #{title} sent by #{author}. #{desc}"\r
     when 'trac'\r
       line1 = "#{handle}#{date}#{title} @ #{link}"\r
-      unless item.title =~ /^Changeset \[(\d+)\]/\r
+      unless item.title =~ /^Changeset \[(?:[\da-f]+|\.\.\.)\]/\r
         line2 = "#{handle}#{date}#{desc}"\r
       end\r
     when '/.'\r