svn commit: r435559 - in svnadmin/hooks: . scripts
Mathieu Arnold
mat at FreeBSD.org
Mon Mar 6 17:48:28 UTC 2017
Author: mat
Date: Mon Mar 6 17:48:26 2017
New Revision: 435559
URL: https://svnweb.freebsd.org/changeset/ports/435559
Log:
Add the stomp_bad_formatting hook peter wrote to prevent using arc commit.
Stolen from: the src repository
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D9893
Added:
svnadmin/hooks/scripts/stomp_bad_formatting.pl (contents, props changed)
Modified:
svnadmin/hooks/pre-commit
Modified: svnadmin/hooks/pre-commit
==============================================================================
--- svnadmin/hooks/pre-commit Mon Mar 6 17:31:09 2017 (r435558)
+++ svnadmin/hooks/pre-commit Mon Mar 6 17:48:26 2017 (r435559)
@@ -116,6 +116,9 @@ case-insensitive.py "$REPO" "$TXN" || ex
# fix log message.
log-police.py -t "$TXN" "$REPO" || exit 1
+# catch some gross violations of commit template mangling.
+stomp_bad_formatting.pl "$REPO" "$TXN" || exit 1
+
# Nothing else, go ahead.
exit 0
Added: svnadmin/hooks/scripts/stomp_bad_formatting.pl
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ svnadmin/hooks/scripts/stomp_bad_formatting.pl Mon Mar 6 17:48:26 2017 (r435559)
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+#
+# $FreeBSD$
+
+use strict;
+my $debug = 0;
+
+# $ svnlook changed /home/svnmirror/base -r 12348
+# UU head/sbin/mountd/mountd.c
+# UU head/usr.sbin/mountd/mountd.c
+# $ svnlook log /home/svnmirror/base -r 12348
+# Avoid bogus free() of a junk pointer.
+#
+# Detected by: phkmalloc
+# Submitted by: grog at lemis.de (Greg Lehey)
+#
+# Except that when called to vette a commit, it'll be "-t txn", not "-r rev"
+
+
+my $repo = $ARGV[0];
+my $txn = $ARGV[1];
+
+my $log = "";
+
+open(LOG, "svnlook log $repo -t $txn |") || die "cannot open svnlook log: $!";
+foreach (<LOG>) {
+ print "$$: log: $_" if ($debug);
+ $log .= $_;
+}
+close(LOG);
+
+if (stomp_bad_formatting($log)) {
+ exit 1;
+}
+exit 0;
+
+# ============================================================
+# Look for a few specific mangled/broken template cases as a
+# stopgap for checking for a proper template.
+
+sub stomp_bad_formatting {
+ my ($log) = @_;
+ my $rv = 0;
+ if ($log =~ m|\n\nReviewers:[\t ]+|s) {
+ printf STDERR "**** Non-standard/badly formatted template - found 'Reviewers:' instead of 'Reviewed by:'.\n";
+ $rv = 1;
+ }
+ # There is really no need for this spam in log messages.
+ if ($log =~ m|\n\nSubscribers:[\t ]+|s) {
+ printf STDERR "**** Non-standard/badly formatted template - found 'Subscribers:'.\n";
+ $rv = 1;
+ }
+ $rv;
+}
More information about the svn-ports-svnadmin
mailing list