Created
December 6, 2013 22:05
-
-
Save deckerego/7832895 to your computer and use it in GitHub Desktop.
Converts a Subversion log to an RSS feed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MONITOR_PATHS='trunk' | |
FILE_DIR="$HOME/.svntorss" | |
XSLT_FILE="$HOME/Documents/Scripts/svnlog.xslt" | |
REPOSITORY="https://svn/svn/repos" | |
MAX_RESULTS=20 | |
for MONITOR_PATH in $MONITOR_PATHS; do | |
SVN_URL="$REPOSITORY/$MONITOR_PATH" | |
FILE_NAME=`echo "$MONITOR_PATH" | sed 's/\//_/'` | |
RSS_FILE="$FILE_DIR/$FILE_NAME.rss" | |
svn log "$SVN_URL" --limit "$MAX_RESULTS" -v --xml | xsltproc "$XSLT_FILE" - > "$RSS_FILE" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" extension-element-prefixes="date func str" version="1.0"> | |
<!-- | |
svnlog.xslt by Martin Pittenauer / TheCodingMonkeys | |
Web: www.codingmonkeys.de, Mail: [email protected] | |
iso->rfc822 date conversion code heavily inspired by Steven Engelhardt (http://www.deez.info/sengelha/) | |
Tested with libxslt. | |
--> | |
<xsl:output omit-xml-declaration="no" indent="yes" encoding="UTF-8" method="xml" /> | |
<xsl:template match="log"> | |
<rss version="2.0"> | |
<channel> | |
<title>SVN: SVN Repository</title> | |
<link>https://svn/viewvc/</link> | |
<description>svn commit log</description> | |
<language>en-us</language> | |
<copyright>2007</copyright> | |
<generator>svnlog.xslt</generator> | |
<xsl:apply-templates select="logentry" /> | |
</channel> | |
</rss> | |
</xsl:template> | |
<xsl:template match="logentry"> | |
<item> | |
<title>Revision <xsl:value-of select="@revision"/> by <xsl:value-of select="author" /></title> | |
<pubDate> | |
<xsl:call-template name="rfc822"> | |
<xsl:with-param name="isodate" select="date" /> | |
</xsl:call-template> | |
</pubDate> | |
<!-- Accoring to RSS 2.0 specs, author has to be an rfc822 valid email address --> | |
<author><xsl:value-of select="author" />@localhost</author> | |
<description disable-output-escaping="yes"><div style="white-space:pre"><xsl:value-of select="msg" /></div><br/> | |
(<em><xsl:call-template name="rfc822"> | |
<xsl:with-param name="isodate" select="date" /> | |
</xsl:call-template></em>)<br/><br/> | |
<table><xsl:apply-templates select="paths/path" /></table> | |
</description> | |
</item> | |
</xsl:template> | |
<xsl:template match="paths/path"> | |
<tr><td><strong><xsl:call-template name="svncommand"><xsl:with-param name="command" select="@action" /></xsl:call-template></strong></td> | |
<td>&nbsp;<a href="https://svn/viewvc<xsl:value-of select="."/>"><xsl:value-of select="."/></a></td></tr> | |
</xsl:template> | |
<xsl:template name="rfc822"> | |
<xsl:param name="isodate" /> | |
<xsl:variable name="dayOfWeek" select="date:day-abbreviation($isodate)" /> | |
<xsl:variable name="day" select="date:day-in-month($isodate)" /> | |
<xsl:variable name="monthAbbr" select="date:month-abbreviation($isodate)" /> | |
<xsl:variable name="year" select="date:year($isodate)" /> | |
<xsl:variable name="hour" select="date:hour-in-day($isodate)" /> | |
<xsl:variable name="minute" select="date:minute-in-hour($isodate)" /> | |
<xsl:variable name="second" select="round(date:second-in-minute($isodate))" /> | |
<xsl:value-of select="$dayOfWeek" /> | |
<xsl:text>, </xsl:text> | |
<xsl:value-of select="$day" /> | |
<xsl:text> </xsl:text> | |
<xsl:value-of select="$monthAbbr" /> | |
<xsl:text> </xsl:text> | |
<xsl:value-of select="$year" /> | |
<xsl:choose> | |
<xsl:when test="$hour and $minute and $second"> | |
<xsl:text> </xsl:text> | |
<xsl:value-of select="str:align($hour, '00', 'right')" /> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="str:align($minute, '00', 'right')" /> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="str:align($second, '00', 'right')" /> | |
<xsl:text> GMT</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:text> 00:00:00 GMT</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="svncommand"> | |
<xsl:param name="command"/> | |
<xsl:choose> | |
<xsl:when test="$command = 'A'">Added</xsl:when> | |
<xsl:when test="$command = 'D'">Deleted</xsl:when> | |
<xsl:when test="$command = 'M'">Modified</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment