[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: daily commit reports

From: Kalin KOZHUHAROV <kalin_at_thinrope.net>
Date: 2005-10-04 05:48:04 CEST

* forgot to CC the list *

Samuel DeVore wrote:
> Does anyone have a script to get a days worth of commits from svn that
> could be called from cron?
Well, I am not sure if it is worth 2 cents, beut find my Perl script attached below.
Read the top comments, it is terribly inefficient, because it uses the command line.
Why? Simply failed a head-first approach with the Perl bindings and needed it "for yesterday" :-)

And I was interested in a single author's logs for a certain day, not sure if this is what you need.

Feel free to improve it and post it back here.

Kalin.

-- 
|[ ~~~~~~~~~~~~~~~~~~~~~~ ]|
+-> http://ThinRope.net/ <-+
|[ ______________________ ]|

#!/usr/bin/perl -w
# vim:ts=4:
# Copyright Kalin KOZHUHAROV <kalin@thinrope.net>
#
# See $USAGE below
# This script shows today's log for all or a single author
#
# TODO:
# Combine with author.pl
# Use perl binding as this is terribly ineeficient!

use strict;

my $USAGE = "$0 YYYY-MM-DD AUTHOR URL\n";
my $TODAY = qx!date +%Y-%m-%d!; chomp $TODAY;
my $EXAMPLE = "$0 $TODAY YourName https://svn.URL/repos/blabla/\n";
my $DEBUG_LEVEL = 5; # set $DEBUG_LEVEL to >0 to print debug on STDERR

sub _debug
{
        my $level = shift;
        print STDERR @_, "\n" if ($level <= $DEBUG_LEVEL);
}

die("Usage:\n\t${USAGE}Example:\n\t$EXAMPLE") if (scalar @ARGV != 3);
my ($START_REV, $END_REV, $AUTHOR, $URL) = ("{$ARGV[0]T00:00}", "{$ARGV[0]T23:59}", $ARGV[1], $ARGV[2]);

my %revisions;
my $cmd = "svn log --incremental -r $START_REV:$END_REV $URL";
my @out = qx ! $cmd !;
foreach (@out)
{
        next if (/^-+$/);
        next unless (/^r(\d+)/);
        my @F = split(/\s*\|\s*/);
        $F[0] =~ s/^r//;
        $revisions{$F[0]}{'author'} = $F[1];
        $F[2] =~ /\d\d\d\d-\d\d-\d\d (\d\d:\d\d):\d\d/;
        $revisions{$F[0]}{'timestamp'} = $1;
}

print "# Revision log for $AUTHOR on $ARGV[0] for $URL\n\n";
print "#rev [TIME]\t log messages ###\n";
foreach my $rev (sort keys %revisions)
{
        next unless ($revisions{$rev}{'author'} =~ /$AUTHOR/);
        get_log($rev, $URL);
        print "$rev [$revisions{$rev}{'timestamp'}]$revisions{$rev}{'comment'}";
}

sub get_log
{
        my ($rev, $URL) = @_;
        my $cmd = "svn log -r $rev $URL";
        my @out = qx ! $cmd !;
        foreach (@out)
                {
                        next if (/^-+$/);
                        next if (/^r(\d+)/);
                        next if (/^\s*$/);
                        $revisions{$rev}{'comment'} .= "\t$_";
                }
        $revisions{$rev}{'comment'} = "\n" unless ($revisions{$rev}{'comment'});
}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Oct 4 05:48:40 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.