
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;
}
As long as you're using Perl.... (Score:2)
Re:As long as you're using Perl.... (Score:2)
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