From d0901e593eb2d5799bdbaab3b34ce4ff757dc64d Mon Sep 17 00:00:00 2001 From: Lars Kurth Date: Fri, 28 Jul 2017 12:03:45 +0100 Subject: [PATCH] Make xsa file processing more robust: tabs, missing Subject! and commit messages with regex special characters --- match-xsa | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/match-xsa b/match-xsa index 9692ea0..5916558 100755 --- 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; } } -- 2.39.5