[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

patch to automatically close bugs fixed by commits to CVS



Hi all,

I've patched log_accum.pl from CVSROOT[1] to also close bugs fixed in
the commits that it sends mail to debian-www-cvs about. I figure that it
is easiest to patch this script than to duplicate its functionality of
aggregating commit messages from different directories. I haven't tested
this patch, if someone with access to www-master could do so that would
be great. The patch is inspired by the qa.d.o bug closing hook[2]. 

1. cvs -d :pserver:anonymous@anonscm.debian.org:/cvs/webwml checkout CVSROOT
2. http://anonscm.debian.org/viewvc/qa/trunk/bin/svn-closes-hook?view=co

-- 
bye,
pabs

http://wiki.debian.org/PaulWise
? webwml-close-bugs-automatically.patch
Index: log_accum.pl
===================================================================
RCS file: /cvs/webwml/CVSROOT/log_accum.pl,v
retrieving revision 1.12
diff -p -u -r1.12 log_accum.pl
--- log_accum.pl	15 Nov 2009 01:51:42 -0000	1.12
+++ log_accum.pl	2 Dec 2012 04:43:51 -0000
@@ -3,6 +3,7 @@
 ##
 #
 # This script, taken from the OpenBSD CVS repository.
+# Modified to close Debian bugs fixed by the commits.
 #
 # Perl filter to handle the log messages from the checkin of files in
 # a directory.  This script will group the lists of files by log
@@ -275,6 +276,45 @@ EOF
     }
 }
 
+sub close_bugs {
+	local(@text) = @_;
+	my @bugs, @done;
+	my $log = join("\n", @text);
+	my $log_copy = $log;
+	while( $log_copy =~ s/(closes:\s*(?:bug)?\#\s*\d+(?:,\s*(?:bug)?\#\s*\d+)*)//is )
+	{
+		my $match = $1;
+		push @bugs, "#$1" while $match =~ s/#(\d+)//;
+		push @done, "$1-done@bugs.debian.org" while $match =~ s/#(\d+)//;
+	}
+	my $bugs = join(", ", @bugs);
+	my $done = join(", ", @done);
+
+	open MAIL, "| $MAILER -t";
+	print MAIL <<EOF ;
+From: Debian WWW CVS <webmaster\@debian.org>
+To: $done
+Subject: Debian WWW CVS commit by $login fixes $bugs
+Reply-To: debian-www\@lists.debian.org
+Mail-Followup-To: debian-www\@lists.debian.org
+Mail-Copies-To: never
+
+This bug was closed by $login in the webwml CVS repository:
+
+http://www.debian.org/devel/website/using_cvs
+
+Note that it might take some time until www.debian.org has been updated.
+
+Commit message:
+
+$log
+EOF
+	close MAIL;
+	if ($debug) {
+		print STDERR "close_bugs(): name = ", $name, "; subject = ", $subject, ".\n";
+	}
+}
+
 sub write_commitlog {
     local($logfile, @text) = @_;
 
@@ -379,6 +419,7 @@ if ($files[1] eq "- New directory") {
     }
 
     &mail_notification($mailto, $files[0], @text);
+    &close_bugs(@text);
 
     if ($commitlog) {
 	&write_commitlog($commitlog, @text);
@@ -444,6 +485,7 @@ if ($files[1] eq "- Imported sources") {
     }
 
     &mail_notification($mailto, "Import $file[0]", @text);
+    &close_bugs(@text);
 
     if ($commitlog) {
 	&write_commitlog($commitlog, @text);
@@ -570,6 +612,7 @@ if ($#status_txt >= 0) {
 # Mailout the notification.
 #
 &mail_notification($mailto, $subject_txt, @text);
+&close_bugs(@text);
 
 # cleanup
 #

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: