diff options
author | joe <joe@FreeBSD.org> | 2001-05-14 03:52:20 +0800 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2001-05-14 03:52:20 +0800 |
commit | c6913e65f13e87a82f96c0a7eba2b9db2e1038c5 (patch) | |
tree | d3a6570cfcbed9defa6ecfbf322bdb46431f88d7 /CVSROOT/logcheck | |
parent | c933865424c05b153ea229778db4e105606fd9d7 (diff) | |
download | freebsd-ports-gnome-c6913e65f13e87a82f96c0a7eba2b9db2e1038c5.tar.gz freebsd-ports-gnome-c6913e65f13e87a82f96c0a7eba2b9db2e1038c5.tar.zst freebsd-ports-gnome-c6913e65f13e87a82f96c0a7eba2b9db2e1038c5.zip |
* Tidy up the error handling to make it clearer what's happening.
* If a commit fails because of a template error point the user to
a saved copy of the log message for when they re-commit.
Diffstat (limited to 'CVSROOT/logcheck')
-rwxr-xr-x | CVSROOT/logcheck | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/CVSROOT/logcheck b/CVSROOT/logcheck index 25d20d3bd715..0408f1309b9f 100755 --- a/CVSROOT/logcheck +++ b/CVSROOT/logcheck @@ -68,6 +68,7 @@ shift @log_in unless $log_in[0]; # 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; +my $error = 0; while ($j >= 0 and my $header = $log_in[$j]) { --$j; @@ -78,7 +79,7 @@ while ($j >= 0 and my $header = $log_in[$j]) { # Warn and ignore unrecognised headers. unless (defined($pattern)) { - print "Warning: unrecognised header: $header\n"; + print "Warning: unknown template header: $header\n"; next; } @@ -90,13 +91,15 @@ while ($j >= 0 and my $header = $log_in[$j]) { # Type check the header unless ($value =~ /^$pattern$/) { - print "Parse error in header ($header)\n"; - exit 1; + print "Error: syntax check failed for: $header\n"; + ++$error; + next; } } else { - print "Malformed line in with headers: $header\n"; - exit 1; + print "Error: malformed line in template headers: $header\n"; + ++$error; + next; } } @@ -109,10 +112,23 @@ print OUT map { "$_\n" } @log_in; close OUT; +# Stop the commit if there was a problem with the template headers. +if ($error) { + print "There were $error errors in the template headers.\n"; + print "Please fix the log message and commit again.\n"; + print "A copy of your log message was saved in $tmpfile.\n"; + exit 1; +} + + + # Nuke likely editor backups. unlink "$filename.~"; unlink "$filename.bak"; + +# Overwrite the log message with our sanitised one. (See the comment +# block at the top of this script for an explaination of why.) rename($tmpfile, $filename) or die "logcheck: Could not rename $tmpfile to $filename: $!"; |