Commit r2362: https://sourceforge.net/p/mrbs/code/2362/
------------------------------------------------------------------------ r2362 | jberanek | 2012-07-26 22:35:06 +0100 (Thu, 26 Jul 2012) | 2 lines Changed paths: A /tools/trunk/commit-emailer.pl Temporary script to harvest a project SVN RSS feed and generate emails to mailing lists ------------------------------------------------------------------------ Index: tools/trunk/commit-emailer.pl =================================================================== --- tools/trunk/commit-emailer.pl (revision 0) +++ tools/trunk/commit-emailer.pl (revision 2362) @@ -0,0 +1,126 @@ +#!/usr/bin/perl + +use MIME::Lite; +use XML::Simple; +use LWP::UserAgent; + +# Config +my $project = 'mrbs'; +my $svn_repos = 'code'; +my $sf_username = 'jberanek'; +my @terse_recipients = +( + '[email protected]', +# 'jberanek', +); +my @verbose_recipients = +( + '[email protected]', +# 'jberanek', +); + +# Calculated values +my $repos_url = "svn+ssh://$sf_username\@svn.code.sf.net/p/$project/$svn_repos/"; +my $commit_url_base = "https://sourceforge.net/p/$project/$svn_repos/"; +my $rss_url = "${commit_url_base}feed"; + +my $ua = LWP::UserAgent->new; +my $response = $ua->get($rss_url); +if (!$response->is_success) +{ + die "RSS fetch failed: ".$response->status_line."\n"; +} +my $rss = $response->decoded_content(); + +my $xml_ref = XMLin($rss); + +my @revisions; + +foreach my $item (@{$xml_ref->{channel}->{item}}) +{ + if ($item->{description} =~ m|<a href="/p/.*?/(\d+)/|) + { + push @revisions, $1; + } +} + +my @sorted_revisions = sort @revisions; + +my $last_rev_filename = "$project-$svn_repos.lastrev"; +my $last_rev = 0; +my $ok = open LAST_REV,'<',$last_rev_filename; +if ($ok) +{ + $last_rev = <LAST_REV>; + chomp $last_rev; + close LAST_REV; +} + +foreach my $revision (@sorted_revisions) +{ + if ($revision > $last_rev) + { + email_commit($revision); + $last_rev = $revision; + } +} + +open LAST_REV,'>',$last_rev_filename; +print LAST_REV "$last_rev\n"; +close LAST_REV; + +# The end + + +# +sub email_commit +{ + my ($rev) = @_; + + my $terse_info = "Commit r$rev: $commit_url_base$rev/\n\n"; + my $author = 'unknown'; + + open SVN,'-|', + 'svn', + 'log', + '-c', $rev, + '-v', + $repos_url; + while (<SVN>) + { + if (m/^r\d+\s+\|\s+(\S+)/) + { + $author = $1; + } + $terse_info .= $_; + } + close SVN; + + my $msg = MIME::Lite->new(From => "$author\@users.sourceforge.net", + To => \@terse_recipients, + Subject => "SF.net SVN: $project:[$rev]", + Data => $terse_info); + $msg->send(); + + my $verbose_info = $terse_info; + + $verbose_info .= "\n"; + + open SVN,'-|', + 'svn', + 'diff', + '-c', $rev, + $repos_url; + while (<SVN>) + { + $verbose_info .= $_; + } + close SVN; + + $msg = MIME::Lite->new(From => "$author\@users.sourceforge.net", + To => \@verbose_recipients, + Subject => "SF.net SVN: $project:[$rev]", + Data => $verbose_info); + $msg->send(); + +} Property changes on: tools/trunk/commit-emailer.pl ___________________________________________________________________ Added: svn:executable + * ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Mrbs-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mrbs-commits
