From c0627ebbb288b3a448350f7b66f54f85b3e19961 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 24 Nov 2014 22:03:48 +0000 Subject: Add option to post to bugzilla during ID assignment. Allow the operator to optionally post to Bugzilla (and remove the validated_update keyword) if the id assignment fails during cross checks. --- lib/MGA/Advisories.pm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index 0cf72d3..d29d706 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -256,8 +256,7 @@ sub assign_id { $buffer = $msg; my $found_keyword = 0; if (scalar($bug->{keywords}) > 0) { - my $keywords = $bug->{keywords}; - foreach my $keyword (@$keywords) { + foreach my $keyword (@{$bug->{keywords}}) { if ('validated_update' eq $keyword) { $found_keyword = 1; last; @@ -352,6 +351,26 @@ sub assign_id { if ($failed) { print STDERR "Error: Cross check failed.\n"; + if ($found_keyword) { + ReadMode 4; # Turn off controls keys + print "Post failure message to Bugzilla and reset 'validated_update' keyword (requires login)? [y/N]: "; + my $key = 'x'; + while ( $key ne "\n" && $key ne "y" && $key ne "Y" && $key ne "n" && $key ne "N" ) { + $key = ReadKey(0); + } + ReadMode 0; # Reset tty mode before exiting + if ( $key eq "\n" || $key eq "n" || $key eq "N" ) { + print " ✘\n"; + } else { + print " ✔\n"; + + if (call_bz('Bug.update', { ids => [$bugnum], comment => { body => "Update ID assignment failed\n\n$buffer\n\n'validated_update' keyword reset." }, keywords => { set => grep { $_ ne 'validated_update' } @{$bug->{keywords}} } })) { + print "Successfully posted to Bugzilla\n"; + } else { + print "Failed to post to Bugzilla\n"; + } + } + } return; } } else { -- cgit v1.2.1