diff options
author | joe <joe@FreeBSD.org> | 2001-05-18 22:28:14 +0800 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2001-05-18 22:28:14 +0800 |
commit | 2be274c06eb847b370ffb97e49d4b0b411097b46 (patch) | |
tree | 0024bfa72be9b30568a07f2eaec654e13423dd63 /CVSROOT/logcheck | |
parent | af7799dce9736dfa74815a1bf9845ef66eaf5259 (diff) | |
download | freebsd-ports-gnome-2be274c06eb847b370ffb97e49d4b0b411097b46.tar.gz freebsd-ports-gnome-2be274c06eb847b370ffb97e49d4b0b411097b46.tar.zst freebsd-ports-gnome-2be274c06eb847b370ffb97e49d4b0b411097b46.zip |
Rearrange the commit message parser for legibility.
Diffstat (limited to 'CVSROOT/logcheck')
-rwxr-xr-x | CVSROOT/logcheck | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/CVSROOT/logcheck b/CVSROOT/logcheck index 2073e3c21d6a..b3e235969ba6 100755 --- a/CVSROOT/logcheck +++ b/CVSROOT/logcheck @@ -69,38 +69,21 @@ while ($i < scalar(@log_in) - 1) { shift @log_in if $log_in[0] eq ""; pop @log_in if $log_in[-1] eq ""; -# Filter out blank templated entries, and type check if necessary. -# (looking from the end of the commit message backwards) -my $j = scalar(@log_in) - 1; +# Scan through the commit message looking for templated headers +# as defined in the configuration file, and rcstemplate. +# Assume that these only exist in the last paragraph. +# Filter out blank entries, and type check if necessary. +my $j = $#log_in; # The index of the last entry in the commit msg. my $error = 0; -while ($j >= 0 and my $header = $log_in[$j]) { +while ($j >= 0) { + my $logline = $log_in[$j]; + --$j; - if ($header =~ /^(.*?):\s*(.*)$/) { - my $header = $1; - my $value = $2; - my $pattern = $HEADERS{$header}; - - # Ignore unrecognised headers. - unless (defined($pattern)) { - ### print "Warning: unknown template header: $header\n"; - next; - } - - # Filter out the template header if it's blank. - if ($value eq "") { - splice(@log_in, $j + 1, 1); - next; - } - - # Type check the header - unless ($value =~ /^$pattern$/) { - print "Error: $header: should match /^$pattern\$/.\n"; - ++$error; - next; - } - - } else { + # Hitting a blank line means that we've seen all of the last paragraph. + last if $logline eq ""; + + unless ($logline =~ /^(.*?):\s*(.*)$/) { ### XXX # We're here because we saw a line that didn't match # a template header (no ':'). This could be a continuation @@ -109,6 +92,29 @@ while ($j >= 0 and my $header = $log_in[$j]) { # of the log message for headers. next; } + + my $header = $1; + my $value = $2; + my $pattern = $HEADERS{$header}; + + # Ignore unrecognised headers. + unless (defined($pattern)) { + ### print "Warning: unknown template header: $header\n"; + next; + } + + # Filter out the template header if it's blank. + if ($value eq "") { + splice(@log_in, $j + 1, 1); + next; + } + + # Type check the header + unless ($value =~ /^$pattern$/) { + print "Error: $header: should match '$pattern'.\n"; + ++$error; + next; + } } |