Explorar el Código

dpkg-genchanges: Invert the binary distribution loop inside-out

Move the if conditional from outside to inside the loop, this way
removing one nesting level.
Guillem Jover hace 9 años
padre
commit
c253c35957
Se han modificado 1 ficheros con 13 adiciones y 12 borrados
  1. 13 12
      scripts/dpkg-genchanges.pl

+ 13 - 12
scripts/dpkg-genchanges.pl

@@ -301,22 +301,23 @@ if (build_has_any(BUILD_SOURCE)) {
     $origsrcmsg = g_('binary-only upload (no source code included)');
 }
 
-if (build_has_any(BUILD_BINARY)) {
-    my $dist_count = 0;
+my $dist_count = 0;
 
-    $dist_count = $dist->load($fileslistfile) if -e $fileslistfile;
+$dist_count = $dist->load($fileslistfile) if -e $fileslistfile;
 
-    error(g_('binary build with no binary artifacts found; cannot distribute'))
-        if $dist_count == 0;
+error(g_('binary build with no binary artifacts found; cannot distribute'))
+    if build_has_any(BUILD_BINARY) && $dist_count == 0;
 
-    foreach my $file ($dist->get_files()) {
-        if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) {
-            $p2f{$file->{package}} //= [];
-            push @{$p2f{$file->{package}}}, $file->{filename};
+foreach my $file ($dist->get_files()) {
+    # If this is a source-only upload, ignore any other artifacts.
+    next if build_has_none(BUILD_BINARY);
 
-            push @archvalues, $file->{arch}
-                if defined $file->{arch} and not $archadded{$file->{arch}}++;
-        }
+    if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) {
+        $p2f{$file->{package}} //= [];
+        push @{$p2f{$file->{package}}}, $file->{filename};
+
+        push @archvalues, $file->{arch}
+            if defined $file->{arch} and not $archadded{$file->{arch}}++;
     }
 }