We use Subversion for version control at work. I wanted to get some RSS/Atom feeds of the commits people were making to various repositories, but for some reason, our WebSVN installation (which would have given me the feeds I wanted) was broken. So I decided to quickly hack something together to produce a feed from the svn log output.
How it works
The Subversion Log Feed Generator is a single PHP source file. It doesn't require root access to set-up or run and installation is as simple as copying it into your public_html directory.
When run initially, it displays a form to provide the various options. When the form is submitted, the script passes the form contents to itself via the query string. When called with a query string, the parameters are extracted and processed, then used to run the svn log
command with appropriate switches. The output from svn log
is piped through an XML processor that converts it into Atom format and outputs the results. Because the parameters to produce the feed are passed via the query string, the URL can be bookmarked and used in feed readers so the same script can serve feeds for many different Subversion repositories.
One complication of the implementation is that the script runs as the www-data user under Apache. This causes the svn log
command to prompt for acceptance of the certificate used by https:// style subversion URLs, which hangs the script's execution until the prompt is answered. This is worked around by having the script pipe to stdin of the svn log process and automatically answer the prompt by sending "t" for "(t)emporarily accept the certificate".
Advantages
- Simple installation: A single PHP source file that doesn't require root access to set-up or run and just needs to be copied into your public_html directory.
- No caching: No need for a database. It doesn't litter your filesystem with cache files.
Opportunities for Improvement
- Doesn't work with svn repositories that require a username/password. Passing them via the query string didn't seem like a good idea...
- Doesn't make use of the
--limit
switch now available forsvn log
. This did not exist in the version ofsvn
I was originally using. Instead, a date is used to limit output to log only the commits since that date, which could be a lot, or could be none, depending on how hard everyone has been working. - No caching: Every single hit on a feed URL results in a run of
svn log
! So do not deploy this on a public server unless you want it to die under the load
Hopefully someone will find it useful, please contact me if you do. The code is released under the Creative Commons Attribution-ShareAlike License.
Download:svnfeed.php.
1 comment
Thank's! I was looking for demo how to generate report from SVN log. I made only one change - added username+password to generate from non-anonymous SVN rep.
Leave a comment