svn commit: r246976 - user/bugmeister/gnats/tools
Mark Linimon
linimon at FreeBSD.org
Tue Feb 19 02:48:54 UTC 2013
Author: linimon (doc,ports committer)
Date: Tue Feb 19 02:48:52 2013
New Revision: 246976
URL: http://svnweb.freebsd.org/changeset/base/246976
Log:
linimon-authored scripts to allow specialized GNATS reports.
Added:
user/bugmeister/gnats/tools/do_email_annotated_prs (contents, props changed)
user/bugmeister/gnats/tools/do_generate_annotated_prs (contents, props changed)
user/bugmeister/gnats/tools/do_generate_annotated_prs.pl (contents, props changed)
user/bugmeister/gnats/tools/email_annotated_prs (contents, props changed)
user/bugmeister/gnats/tools/email_boilerplate.txt (contents, props changed)
Added: user/bugmeister/gnats/tools/do_email_annotated_prs
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/bugmeister/gnats/tools/do_email_annotated_prs Tue Feb 19 02:48:52 2013 (r246976)
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# send customized email corresponding to email template. Might or might
+# not be "PRs assigned to". Kind of overlaps email_annotated_prs.
+
+# set this to non-null when testing changes
+#DEVELOPMENT="yes"
+
+user=$1
+input_filename=$2
+html_mode=$3
+
+SCRIPT_DIR="/home/gnats/tools"
+DEFAULT_FILENAME="pr_email_template.txt"
+BOILERPLATE="$SCRIPT_DIR/email_boilerplate.txt"
+SENDMAIL="/usr/sbin/sendmail -odi -fowner-bugmaster at FreeBSD.org -oem"
+
+if [ ! -z "$DEVELOPMENT" ]; then
+ # development:
+ TO_BUGMASTER="linimon at FreeBSD.org"
+fi
+
+if [ -z "$user" ]; then
+ echo "usage: do_email_annotated_prs [user] [filename] [html_mode]"
+ exit 1
+fi
+
+# copied verbatim from gnatsreport.sh
+ targ=`echo ${user} | grep @`
+ if [ "${targ}" = "" ]; then
+ targ=${user}@FreeBSD.org
+ else
+ targ=${user}
+ fi
+ if [ -z "$DEVELOPMENT" ]; then
+ mail_to=${targ}
+ else
+ mail_to=${TO_BUGMASTER}
+ fi
+
+if [ -z "$input_filename" ]; then
+ # look for fallback if not explicitly specified
+ input_filename="/home/$user/public_html/$DEFAULT_FILENAME"
+ if [ -e $input_filename ]; then
+ echo "default template $input_filename not found."
+ exit 1
+ fi
+fi
+
+if [ -z "$html_mode" ]; then
+ html_mode="0"
+fi
+
+# now send the mail
+ (
+ echo "From: FreeBSD bugmaster <bugmaster at freebsd.org>"
+ echo "To: ${user}"
+ echo "Subject: Current problem reports customized for ${targ}"
+ echo ""
+ perl $SCRIPT_DIR/do_generate_annotated_prs.pl $input_filename $html_mode
+ cat $BOILERPLATE
+ ) | ${SENDMAIL} ${mail_to}
+
+exit 0
Added: user/bugmeister/gnats/tools/do_generate_annotated_prs
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/bugmeister/gnats/tools/do_generate_annotated_prs Tue Feb 19 02:48:52 2013 (r246976)
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# create an HTML page corresponding to annotated PRs
+
+script_dir="/home/gnats/tools"
+
+DEFAULT_FILENAME="annotated_prs.txt"
+
+input_filename=$1
+if [ -z "$input_filename" ]; then
+ input_filename="/home/`whoami`/public_html/$DEFAULT_FILENAME"
+fi
+output_filename=`echo $input_filename | sed -e "s/txt/html/"`
+
+html_mode=$2
+if [ -z "$html_mode" ]; then
+ html_mode="1"
+fi
+
+perl $script_dir/do_generate_annotated_prs.pl $input_filename $html_mode > $output_filename.tmp && mv $output_filename.tmp $output_filename
Added: user/bugmeister/gnats/tools/do_generate_annotated_prs.pl
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/bugmeister/gnats/tools/do_generate_annotated_prs.pl Tue Feb 19 02:48:52 2013 (r246976)
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+#
+# Script to create HTML page of annotated sets of bug reports.
+#
+# author: linimon
+# thanks to: pgollucci for perl help
+#
+
+require '/home/gnats/tools/cgi-lib.pl';
+require '/home/gnats/tools/cgi-style.pl';
+require '/home/gnats/tools/query-pr-common.pl';
+require 'getopts.pl';
+
+$query_pr_ref="http://www.freebsd.org/cgi/query-pr.cgi";
+
+local($filename)=$ARGV[0];
+local($html_mode)=$ARGV[1];
+
+$wrote_header = 0;
+$accumulating_prs = 0;
+
+open my $fh, '<', "$filename" or die "Can't open [$filename] because [$!]\n";
+
+while (my $line = <$fh>) {
+
+ chomp $line;
+
+ if ($line =~ /^\d+/) {
+ # line is a PR number. Add it to the current PR list.
+ $query_args=$line . " -x";
+ @prs=&read_gnats($query_args);
+ $accumulating_prs = 1;
+ }
+ else {
+ # line is text.
+
+ # if HTML mode, 1st text line is the HTML title (hack)
+ if (! $wrote_header ) {
+ if ($html_mode ) {
+ print &noninteractive_html_header($line);
+ print "<p>\n";
+ print "Date generated: " . gmtime() . " GMT\n";
+ print "</p>\n";
+ } else {
+ print "Date generated: " . gmtime() . " GMT\n";
+ print "\n";
+ print $line . "\n";
+ print "\n";
+ }
+ $wrote_header = 1;
+ } else {
+ if ($line =~ /%QUERY-PR/) {
+ # use the rest of the line as arguments
+ $line =~ s/%QUERY-PR//;
+ # hack: add a macro for "tag" -- not supported by query-pr
+ $line =~ s/--tag (\S+)/-t \'\\[$1\\]\'/ if ($line =~ /--tag /);
+ # Only add -x if noone gave --state=closed/-s closed
+ if ($line !~ /-s\s+\S*closed/ and $line !~ /--state=\S*closed/) {
+ $line .= " -x";
+ }
+ $query_args=$line;
+ # print "<br>query_args are " . $query_args . "<br>\n";
+ @prs=&read_gnats($query_args);
+ $accumulating_prs = 1;
+ } else {
+ # just a regular text line
+ if ($accumulating_prs) {
+ # need to write out the accumulated PRs first.
+ @prs=reverse(@prs);
+ &printcnt(&gnats_summary(1, $html_mode, \@prs, $query_pr_ref));
+ # do not carry those over to the next block
+ @prs = ();
+ $accumulating_prs = 0;
+ }
+ # any text line other than the first, or %QUERY-PR, is echoed verbatim
+ print $line . "\n";
+ }
+ }
+ }
+}
+close $fh or die "Can't close [$filename] because [$!]\n";
+
+if ($accumulating_prs) {
+ # write out last block
+ @prs=reverse(@prs);
+ &printcnt(&gnats_summary(1, $html_mode, \@prs, $query_pr_ref));
+}
+
+if ($html_mode ) {
+ print &html_footer;
+}
+
+exit(0);
Added: user/bugmeister/gnats/tools/email_annotated_prs
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/bugmeister/gnats/tools/email_annotated_prs Tue Feb 19 02:48:52 2013 (r246976)
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# send email corresponding to email template
+
+user=$1
+targ=$2
+mail_to=$3
+input_filename=$4
+html_mode=$5
+
+DEFAULT_FILENAME="pr_email_template.txt"
+
+SCRIPT_DIR="/home/gnats/tools"
+BOILERPLATE="$SCRIPT_DIR/email_boilerplate.txt"
+SENDMAIL="/usr/sbin/sendmail -odi -fowner-bugmaster at FreeBSD.org -oem"
+
+if [ -z "$user" -o -z "$targ" -o -z "$mail_to" ]; then
+ echo "usage: email_annotated_prs [user] [mail_to] [filename] [html_mode]"
+ exit 1
+fi
+
+if [ -z "$input_filename" ]; then
+ # XXX MCL use fallback if not exists
+ # XXX MCL template not yet generalized!
+ input_filename="/home/$user/public_html/$DEFAULT_FILENAME"
+fi
+
+if [ -z "$html_mode" ]; then
+ html_mode="1"
+fi
+
+# now send the mail
+ (
+ echo "From: FreeBSD bugmaster <bugmaster at freebsd.org>"
+ echo "To: ${user}"
+ echo "Subject: Current problem reports assigned to ${targ}"
+ echo ""
+ perl $SCRIPT_DIR/do_generate_annotated_prs.pl $input_filename $html_mode
+ cat $BOILERPLATE
+ ) | ${SENDMAIL} ${mail_to}
Added: user/bugmeister/gnats/tools/email_boilerplate.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/bugmeister/gnats/tools/email_boilerplate.txt Tue Feb 19 02:48:52 2013 (r246976)
@@ -0,0 +1,25 @@
+
+Notes:
+
+generated on freefall via:
+
+ ~gnats/tools/do_email_annotated_prs [user] [filename] [html_mode]
+
+user is mandatory.
+
+If you do not specify filename the script will look for a file named
+pr_emailtemplate.txt in ~[user]/public_html/.
+
+html_mode may be 1 to send HTML mail, or 0 or omitted not to.
+
+The input format is fairly free-form: any line that starts with a numeric
+is magically assumed to be a PR number; otherwise it is simply copied to
+the output. The magic string %QUERY_PR is a metadirective.
+
+Closed PRs are automagically filtered out by default, but can be shown
+if desired.
+
+Note: to view an individual PR, use:
+ http://www.freebsd.org/cgi/query-pr.cgi?pr=[number].
+
+Send comments to linimon at FreeBSD.org.
More information about the svn-src-user
mailing list