Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
User Journal

Journal toby's Journal: committer stats from 'svn log' 2

svn log -q http://localhost/svn/$repo |cut -s -d \| -f 2|sort|uniq -c|sort -n -r

This can be wrapped in a Perl CGI, for instance:

#!/usr/bin/perl

use strict;
use warnings;
use CGI qw/:standard/;

my $q = new CGI;
my $repo = $q->param('repo');
if ($repo =~ m/\w+/) { # check sanity of repository name (alphanumeric plus _)
my $SVNCMD = "svn log --username USER --password PW -q http://localhost/svn/$repo";
print header,
start_html("committers to $repo"),
'<pre>',
qx{$SVNCMD|cut -s -d \\| -f 2|sort|uniq -c|sort -n -r},
'</pre>',
end_html;
}

More comprehensive version using a form to specify number of weeks:

#!/usr/bin/perl

use strict;
use warnings;
use CGI qw/:standard/;
use Date::Simple;

my $q = new CGI;
my $repo = $q->param('repo');
if ($repo =~ m/\w+/) { # check sanity of repository name (alphanumeric plus _)
my $SVNCMD = "svn log --username USER --password PW -q http://localhost/svn/$repo";
if($q->param('weeks')){
my $stdate = Date::Simple::today()-7*$q->param('weeks');
$head .= " $stdate / ".Date::Simple::today();
$SVNCMD .= " -r {$stdate}:HEAD";
}
print header,
start_html("committers to $repo"),
'<pre>',
qx{$SVNCMD|cut -s -d \\| -f 2|sort|uniq -c|sort -n -r},
'</pre>',
"<form action='",$q->url(-relative=>1),"'>Past weeks: <input type=hidden name=repo value='$repo'><input type=text name=weeks size=5 value='",$q->param('weeks'),"'> (blank for 'all time')<p><input type=submit></form>",
end_html;
}

This discussion has been archived. No new comments can be posted.

committer stats from 'svn log'

Comments Filter:
  • ... why not do all that data-reduction in Perl? Looks like a standard "match an item, count them in most-to-least frequent order". That's even an exercise from chapter 4 of the llama.
    • I guess you already know that the date range has to be done by Svn: the time taken to get that log is proportional to the span of time. 1 week is quick. A year can take several minutes.

      I'm not averse of doing the rest in Perl, but the 'sed|sort|uniq|sort' pipe is probably more concise this way? If not I'd love to be corrected. Plus a mostly-Perl solution would be more portable...

      Actually this started life as a shell command anyway; it ended up wrapped in Perl because I wanted a CGI script. And I normally cl

The "cutting edge" is getting rather dull. -- Andy Purshottam

Working...