Date: Thu, 7 Mar 2013 20:31:55 +0000 (UTC) From: Beat Gaetzi <beat@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-svnadmin@freebsd.org Subject: svn commit: r313608 - in svnadmin/hooks: . scripts Message-ID: <201303072031.r27KVt6c098701@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: beat Date: Thu Mar 7 20:31:54 2013 New Revision: 313608 URL: http://svnweb.freebsd.org/changeset/ports/313608 Log: - Add hook to detect files with no newline at end of file - Remove trailing whitespaces in the pre-commit script Submitted by: ak Added: svnadmin/hooks/scripts/detect-nonewline-at-eof.sh (contents, props changed) Modified: svnadmin/hooks/pre-commit (contents, props changed) Modified: svnadmin/hooks/pre-commit ============================================================================== --- svnadmin/hooks/pre-commit Thu Mar 7 20:26:53 2013 (r313607) +++ svnadmin/hooks/pre-commit Thu Mar 7 20:31:54 2013 (r313608) @@ -48,7 +48,7 @@ # that subprograms fail to launch unless invoked via absolute path. # If you're having unexpected problems with a hook program, the # culprit may be unusual (or missing) environment variables. -# +# # Here is an example hook script, for a Unix /bin/sh interpreter. # For more examples and pre-written hooks, see those in # the Subversion repository at @@ -95,10 +95,13 @@ mergeinfo.sh "$REPO" "$TXN" || exit 1 # check for merge debris detect-merge-conflicts.sh "$REPO" "$TXN" || exit 1 +# check for newline at end of file +detect-nonewline-at-eof.sh "$REPO" "$TXN" || exit 1 + # check for upper/lowercase filename conflicts on clients case-insensitive.py "$REPO" "$TXN" || exit 1 -# fix log message. +# fix log message. log-police.py -t "$TXN" "$REPO" || exit 1 # Nothing else, go ahead. Added: svnadmin/hooks/scripts/detect-nonewline-at-eof.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ svnadmin/hooks/scripts/detect-nonewline-at-eof.sh Thu Mar 7 20:31:54 2013 (r313608) @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $FreeBSD$ + +# A pre-commit hook to detect files with no newline at end of file +# + +REPO=$1 +TXN=$2 + +SVNLOOK=/usr/local/bin/svnlook + +# Check arguments +if [ -z "$REPO" -o -z "$TXN" ]; then + echo "Syntax: $0 path_to_repos txn_id" >&2 + exit 1 +fi + +# We scan through the transaction diff, looking for +# 'No newline at end of file' message. If we find one, +# we abort the commit. +SUSPICIOUS=$($SVNLOOK diff -t "$TXN" "$REPO" | \ + grep '^\\ No newline at end of file' | wc -l) + +if [ $SUSPICIOUS -ne 0 ]; then + echo "Some files in your commit does not have newline at end" >&2 + echo "of file. Please fix this and try committing again." >&2 + exit 1 +fi + +# No files without newlines at last line detected, let it fly! +exit 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303072031.r27KVt6c098701>