From daaafe10758b8c5df37a569ec785927b864690fb Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 5 Oct 2012 13:53:54 -0700 Subject: [PATCH] update decision script to sort of work --- scripts/publish-decision | 98 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 8 deletions(-) diff --git a/scripts/publish-decision b/scripts/publish-decision index 82e39c8..0a66463 100755 --- a/scripts/publish-decision +++ b/scripts/publish-decision @@ -1,8 +1,12 @@ -wip wip wip do not use - #!/usr/bin/perl -w + +use warnings; use strict; +use IO::File; + +use POSIX qw(strftime); + # USAGE: # # 0. See "configuration" below @@ -17,13 +21,91 @@ use strict; # # 3. This will leave: # - BUGNUMBER_blah_blah/decision.email ready for sendmail -t -# - ../www-devel/tech-ctte.wml ready for cvs commit +# - BUGNUMBER_blah_blah/decision.wml ready to paste into webmml # Inspect them and if appropriate send and commit. die "bad usage" unless @ARGV==1 && $ARGV[0] =~ m#^((\d+)_\w+)/.*$#; -my ($bugn, $dir, $templ) = ($1,$2,$&); +my ($dir, $bugn, $decision) = ($1,$2,$&); + +my %decision = process_decision($decision,$bugn); + +decision_email($decision,\%decision); +decision_webml($decision,\%decision); + +sub process_decision{ + my ($decision,$bugn) = @_; + my $dfh = IO::File->new($decision,'r') or + die "Unable to open $decision for reading: $!"; + my %d_bits = (bug => $bugn, + email_epilogue => '', + email_intro => '', + decision => '', + web_summary => '', + ); + my $current_bit; + while (<$dfh>) { + if (/^={4,}\s+(\S.+?)\s*\n?$/) { + $current_bit = $1; + $current_bit =~ s/[\s_]+/_/g; + $current_bit = lc($current_bit); + next; + } elsif (/^={4,}/) { + # this will unset the current bit + undef $current_bit; + next; + } + # silently skip wrong sections + if (not defined $current_bit) { + next; + } + $d_bits{$current_bit} .= $_; + next; + } + close($dfh); + # clean up %d_bits; + for my $key (keys %d_bits) { + # ditch leading and trailing blank lines + $d_bits{$key} =~ s/(?:^\n*|\n*$)//g; + } + $d_bits{bug} = $bugn; + return %d_bits; +} + +sub decision_email { + my ($dfn,$d_bits) = @_; + my $efh = IO::File->new($dfn.".email",'w') or + die "Unable to open ${dfn}.email for writing: $!"; + print {$efh} < +Subject: [CTTE #$d_bits->{bug}] $d_bits->{title} +Mail-Followup-To: debian-ctte\@lists.debian.org + +$d_bits->{email_intro} + +==== RESOLUTION ==== + +$d_bits->{decision} + +==== END OF RESOLUTION ==== + +$d_bits->{email_epilogue} + +Please see http://bugs.debian.org/$d_bits->{bug} for discussion of +this bug. + +EOF + close($efh); +} + +sub decision_webml { + my ($dfn,$d_bits) = @_; + my $wfh = IO::File->new($dfn.".wml",'w') or + die "Unable to open ${dfn}.wml for writing: $!"; + my $date = strftime('%Y-%m-%d',gmtime()); + print {$wfh} <$date + Bug #$d_bits->{bug}:$d_bits->{web_summary} +EOF -sub process_template () { - open T, $templ, '<' or die "$0: $templ: $!\n"; - while () { - +} -- 2.39.2