Move all collection of email addresses to top-level
authorJacob Bachmeyer <jcb@gnu.org>
Wed, 16 Nov 2022 00:14:45 +0000 (18:14 -0600)
committerJacob Bachmeyer <jcb@gnu.org>
Wed, 16 Nov 2022 00:14:45 +0000 (18:14 -0600)
The 'email' and 'package' keys in the quasi-global %info hash remain as
implicit arguments to mail for the time being.

gatekeeper.pl

index c84edc44a38f422a7d573820180ca4278609d406..1aedbe3882acda6f5ccee9d5cb5c654c24749af9 100755 (executable)
@@ -2081,16 +2081,6 @@ sub interpret_directive {
     push @errors, "no directory element specified in directive";
   }
 
-  # Set email addresses
-  if (defined $header{directory}) {
-    my @a = directory_email_addresses($header{directory});
-    foreach my $address (@a) {
-      # Do not include duplicates
-      push (@{$info{email}}, $address)
-       unless (grep($_ eq $address,@{$info{email}}) > 0);
-    }
-  }
-
   if (@errors) {
     throw directive_syntax =>
       trace => \@trace, summary => $errors[0], directory => $header{directory};
@@ -2163,6 +2153,8 @@ sub advance_timestamp_ratchet {
 sub guess_email_address_from_signature {
   my $directive_file_contents = shift;
 
+  my @addresses;
+
   # If we don't know whose project this file belongs to, because the
   # 'directory:' line is messed up or not there, we'd still like to let the
   # uploader know something went wrong.  So let's see if we can match the
@@ -2182,9 +2174,11 @@ sub guess_email_address_from_signature {
 
     unless ($tmp_result->{exitcode} != 0 || defined $tmp_result->{TILT}) {
       if (($tmp_result->{raw_log} =~ /Good signature from .*?<(.*?)>/))
-       { push(@{$info{email}},$1) }
+       { push @addresses, $1 }
     }
   }
+
+  return @addresses;
 }
 
 =item validate_directive ( $packet, $oplist )
@@ -2722,12 +2716,15 @@ foreach my $packet (@packets) { # each list element is an array reference
 
     $directive = read_directive_from_string($directive_text);
 
-    # this function just updates $info{email}
-    guess_email_address_from_signature($directive_text);
+    push @email_addresses,
+      guess_email_address_from_signature($directive_text);
 
     $oplist = interpret_directive($directive);
     $op_header = $oplist->[0][1];
 
+    push @email_addresses,
+      directory_email_addresses($op_header->{directory});
+
     # Phone home. E-mail the contents of the directive file to the maintainer,
     # for debugging purposes.
     if (defined $op_header->{package}) {
@@ -2790,6 +2787,8 @@ foreach my $packet (@packets) {   # each list element is an array reference
     $complete = 1;
   };
 
+  @{$info{email}} = @email_addresses;
+
   if ($complete) {
     local $Phase = 'RP';
 
@@ -2814,6 +2813,12 @@ foreach my $packet (@packets) {  # each list element is an array reference
     if (ref $E) {
       # Processing explicitly threw an exception
       if ($E->type_p('directive_syntax')) {
+       # If a directive_syntax exception is thrown, we may not have the
+       # email addresses corresponding to the target directory in the list
+       # and may not even have a target directory.
+       push @email_addresses, directory_email_addresses($E->directory)
+         if $E->directory;
+       @{$info{email}} = @email_addresses;
        mail(join("\n",$E->summary,'',$E->trace_msg),1);
       } elsif ($E->type_p('package_configuration')) {
        mail($E->summary,0);