Created
November 10, 2010 16:56
-
-
Save vbfox/671122 to your computer and use it in GitHub Desktop.
Pre-Commit hook for svn checking that no .cs file is committed as a binary file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function script { | |
local repo="$1" | |
echo "repo=$repo" | |
local txn="$2" | |
echo "txn=$txn" | |
local selector="-t $txn" | |
echo "Changed:" | |
echo "--------------------" | |
svnlook changed $selector "$repo" | |
echo "--------------------" | |
while read line | |
do | |
local ext=`echo "$line"|sed -r -e 's/^.+\.(.+)$/\1/'` | |
if [ "cs" == "$ext" ] | |
then | |
local mimetype=`svnlook propget $selector "$repo" svn:mime-type "$line" 2>/dev/null` | |
if [ "application/octet-stream" == "$mimetype" ] | |
then | |
echo "Binary .cs file : $line" >&2 | |
exit 1 | |
fi | |
fi | |
done < <(svnlook changed $selector "$repo" | egrep '^(.U|A )' | sed -e 's/^..\s*//') | |
exit 0 | |
} | |
script "$1" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment