/[scripts]/trunk/svn-rt-comment.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/svn-rt-comment.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (show annotations)
Mon Oct 27 14:57:10 2008 UTC (15 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1263 byte(s)
require word boundry around rt1 so that amort1 in
diff won't attach commit to RT #1 (sigh!)

1 #!/usr/bin/perl
2
3 # https://blog.rot13.org/2008/09/request_tracker_subversion_svnweb_microblogging.html
4
5 use strict;
6 use warnings;
7
8 use RT::Client::REST;
9 use RT::Client::REST::Ticket;
10
11 # Request Tracker
12 my ( $server, $username, $password ) = ( 'https://bugs.example.com/rt', 'rtuser', 'rtpasswd' );
13 # patternt to recognize RT references in commits log or diff
14 my $rt_re = qr/\brt\s*#?\s*(\d+)\b/i;
15 my $svnweb_fmt = 'http://svn.example.com/svnweb/index.cgi/%s/revision/?rev=%d';
16
17 die "usage: $0 repo rev\n" unless @ARGV;
18
19 my ( $repo, $rev ) = @ARGV;
20
21 sub svnlook {
22 my $command = shift;
23 my $txt = `svnlook $command --revision $rev $repo`;
24 chomp( $txt );
25 return $txt;
26 }
27
28 my $log = svnlook 'log';
29 my $diff = svnlook 'diff';
30
31 if ( $log =~ $rt_re || $diff =~ $rt_re ) {
32
33 my $id = $1 or die "no id";
34
35 my $rt = RT::Client::REST->new( server => $server );
36 $rt->login( username => $username, password => $password );
37 my $ticket = RT::Client::REST::Ticket->new( rt => $rt, id => $id );
38
39 my $repo_only = $repo;
40 $repo_only =~ s{^.*/([^/]+)$}{$1};
41
42 my $message =
43 sprintf($svnweb_fmt,$repo_only, $rev) . "\n" .
44 svnlook('author') . "\t" . svnlook('date') . "\n\n" .
45 svnlook('changed --copy-info') . "\n\n" .
46 $log
47 ;
48
49 $ticket->comment( message => $message );
50 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26