]> xenbits.xensource.com Git - people/larsk/xen-release-scripts.git/commitdiff
Make xsa file processing more robust: tabs, missing Subject! and commit messages...
authorLars Kurth <lars.kurth@citrix.com>
Fri, 28 Jul 2017 11:03:45 +0000 (12:03 +0100)
committerLars Kurth <lars.kurth@citrix.com>
Fri, 28 Jul 2017 11:03:45 +0000 (12:03 +0100)
match-xsa

index 9692ea07461ca2c9cfc449df0e40727ce5dd82ba..591655850fcde65aa3897dde1d9223fc5fecd5cf 100755 (executable)
--- a/match-xsa
+++ b/match-xsa
@@ -101,11 +101,10 @@ open(my $data, '<', $XSAFILE) or die "Could not open '$XSAFILE' $!\n";
 while (my $line = <$data>) {
   chomp $line;
  
-  my @fields = split "\t" , $line;
+  my @fields = split "[\t]+" , $line;
   $XSA[$i]       = "$fields[0]";
   $XSA_PATCH[$i] = "$fields[1]";
-  # Important note: there are two tabs after the patch
-  $XSA_ID[$i]    = "$fields[3]";
+  $XSA_ID[$i]    = "$fields[2]";
   
   $XSA[$i]       =~ s/\r$//g;
   $XSA_PATCH[$i] =~ s/\r$//g; 
@@ -248,10 +247,17 @@ sub matchcommitmsg {
    my $commitmsg1 = shift;
    my $commitmsg2 = shift;
    
+   # Add
+   if ($commitmsg1 eq "missing Subject!") {
+      return 0;
+   }
+   if ($commitmsg2 eq "missing Subject!") {
+      return 0;
+   }
    # Check by commit message
    if ($commitmsg1 ~~ $commitmsg2) {
       return 1;       
-   } elsif (grep /$commitmsg1/i, $commitmsg2) {
+   } elsif (grep /\Q$commitmsg1\E/i, $commitmsg2) {
       return 1; 
    } else {
       # Only compare from ":" as tags before frequently change
@@ -262,7 +268,7 @@ sub matchcommitmsg {
          my $commitmsg1_s = substr $commitmsg1, $i1;
          my $commitmsg2_s = substr $commitmsg2, $i2;
         
-         if (grep /$commitmsg1_s/i, $commitmsg2_s) {
+         if (grep /\Q$commitmsg1_s\E/i, $commitmsg2_s) {
             return 2; 
          }
       }