]> git.donarmstrong.com Git - debbugs.git/commitdiff
add skip-missing option
authorDon Armstrong <don@donarmstrong.com>
Fri, 15 Dec 2017 18:22:39 +0000 (10:22 -0800)
committerDon Armstrong <don@donarmstrong.com>
Fri, 15 Dec 2017 18:22:57 +0000 (10:22 -0800)
bin/debbugs-spam

index b172e97e36508ebd70b35e3b28fa2ae826ff314c..164013bce1da73970de2a9ce52b29255b87c9a9b 100755 (executable)
@@ -93,6 +93,7 @@ use Debbugs::Log qw(record_regex);
 use Debbugs::Log::Spam;
 use Debbugs::Config qw(:config);
 use Debbugs::Command qw(:all);
+use Debbugs::Common qw(getbuglocation);
 use IPC::Open3 qw(open3);
 use Carp;
 
@@ -119,8 +120,11 @@ handle_main_arguments(\%options,
 my %subcommands =
     ('auto-scan' => {function => \&auto_spamscan,
                      arguments => {'ham_threshold|ham-threshold=s' => 0,
+                                   'skip_missing|skip-missing!' => 0,
                                   },
-                     defaults => {ham_threshold => -5},
+                     defaults => {ham_threshold => -5,
+                                  skip_missing => 0,
+                                 },
                     },
      'score' => {function => \&score_bug,
                  arguments => {'skip_seen|skip-seen!' => 0
@@ -226,6 +230,11 @@ sub auto_spamscan {
     my ($options,$opts,$config,$argv) = @_;
 
     for my $bug_num (@{$argv}) {
+        if ($opts->{skip_missing} and
+            not defined getbuglocation($bug_num,'log')) {
+            print STDERR "bug $bug_num does not exist\n" if $options->{verbose} > -1;
+            next;
+        }
         my $spam = Debbugs::Log::Spam->new(bug_num => $bug_num) or
             die "Unable to open bug log spam for $bug_num";
         foreachmsg(sub {