Solution: How to get a svn log by author name
I am in the habit of maintaining a daily work log. I do this in a Google spreadsheet and maintain each month on an individual sheet. This not only lets me share with the team what I ve been up but it also gives me a good idea about how a particular week or month was and then based on that I can make some changes to my daily schedule to improve my productivity. The only issue is, sometimes I forget to maintain the work log and then if that happens for a number of days, then the spreadsheet has this unbearable ‘void’ suddenly. To deal with this, I want to naturally turn to my recent project’s git or svn log for filling up the missing days. But svn log will not give me a log by author. So here s a XML + XSL based solution that I m using currently.
I export the svn log to a xml file
svn log --xml -v > mylog.xml
And then I add a XSL stylesheet to the log file that got created on its second line (right after the XML version declaration)
<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>
And finally I use the following XSL to filter out other authors and only include my commits. If you are copying this from here, then make sure you substitute my name ‘walmik’ with your name.
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My SVN log</h2> <table border="1"> <xsl:for-each select="log/logentry"> <xsl:if test="author='walmik'"> <tr> <td><xsl:value-of select="@revision"/></td> <td><xsl:value-of select="author"/></td> <td><xsl:value-of select="substring(date,1,10)"/></td> <td><xsl:value-of select="msg"/></td> <td> <xsl:for-each select="paths/path"> <table> <tr> <td></td> <td><xsl:value-of select="@action"/></td> <td><xsl:value-of select="."/></td> </tr> </table> </xsl:for-each> </td> </tr> </xsl:if> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
As you can notice I m using a substring to format the date to show just the year, month and day.
Now when I open the XML in a browser, I can copy the work log entries from missing dates and paste it inside the Google spreadsheet. Of course, this whole exercise would be pointless if you are not in the habit of adding a message to your commits!