aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-08-06 00:50:11 +0100
committerColin Guthrie <colin@mageia.org>2014-08-06 00:59:22 +0100
commit6c2fabf1b1fe0e50a06273f9bf84e9bb9a9cfbdb (patch)
treee88f14d07477496ca75315b2c2379ecbdf22db31
parent1a3496d8090a5bd0a8880c70743396738518a228 (diff)
downloadmgaadvisories-6c2fabf1b1fe0e50a06273f9bf84e9bb9a9cfbdb.tar
mgaadvisories-6c2fabf1b1fe0e50a06273f9bf84e9bb9a9cfbdb.tar.gz
mgaadvisories-6c2fabf1b1fe0e50a06273f9bf84e9bb9a9cfbdb.tar.bz2
mgaadvisories-6c2fabf1b1fe0e50a06273f9bf84e9bb9a9cfbdb.tar.xz
mgaadvisories-6c2fabf1b1fe0e50a06273f9bf84e9bb9a9cfbdb.zip
Close bugs automatically when processing advisories
-rw-r--r--NEWS1
-rw-r--r--lib/MGA/Advisories.pm33
-rwxr-xr-xmgaadv1
3 files changed, 35 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 893939f..3c035bb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- close bugs automatically when processing advisories
- perform some cross checks on bugzilla when publishing advisories
Version 0.17
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index 62f9bee..7058d3b 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -477,6 +477,39 @@ sub send_adv_mail {
}
}
+sub close_bugs {
+ my ($advdb) = @_;
+ return unless $config->{mode} eq 'site';
+
+ if (!init_bz()) {
+ report_log("Cannot close advisory bugs. Could not initialise bugzilla");
+ return;
+ }
+ foreach my $adv (keys %{$advdb->{advisories}}) {
+ next if $advdb->{advisories}{$adv}{status}{bug_closed};
+
+ my $bugnum = 0;
+ if (scalar($advdb->{advisories}{$adv}{references}) > 0) {
+ ($bugnum) = $advdb->{advisories}{$adv}{references}[0] =~ m/$config->{bugzilla_url}.*=([0-9]+)$/g;
+ }
+ if (!$bugnum) {
+ report_log("Could not extract bug number for $adv");
+ next;
+ }
+
+ my $advurl = $config->{site_url} . '/' . $adv . '.html';
+ my $comment = "An update for this issue has been pushed to Mageia Updates repository.\n\n$advurl";
+
+ if (my $result = call_bz('Bug.update', { ids => [$bugnum], status => 'RESOLVED', resolution => 'FIXED', comment => { body => $comment } })) {
+ report_log("Bug $bugnum closed for $adv");
+ $advdb->{advisories}{$adv}{status}{bug_closed} = time();
+ save_status($advdb, $adv);
+ } else {
+ report_log("Could not close bug $bugnum for $adv");
+ }
+ }
+}
+
sub send_report {
my ($advdb) = @_;
return unless @report_logs;
diff --git a/mgaadv b/mgaadv
index 229d133..0a4df25 100755
--- a/mgaadv
+++ b/mgaadv
@@ -157,6 +157,7 @@ sub process {
MGA::Advisories::output_pages(\%advdb);
MGA::Advisories::dumpdb(\%advdb);
MGA::Advisories::send_adv_mail(\%advdb);
+ MGA::Advisories::close_bugs(\%advdb);
MGA::Advisories::send_report(\%advdb);
}