Using the following code in the Collabnet SVN's pre commit script to restrict the specific file extensions to get committed, but it is committing all the files. Could you please tell where I'm going wrong.
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/home/csvn/csvn/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 10 ];
then
echo -e "\n===========================================================" 1>&2
echo -e "|| COMMENTS ARE MADE MANDATORY.PLEASE ENTER RELEVANT COMMENT & COMMIT AGAIN Sanjeev sas||" 1>&2
echo -e "===========================================================" 1>&2
exit 1
fi
$SVNLOOK changed -t $TXN $REPOS | awk '
BEGIN {
FILTER=".(sh|xls|xlsx|pdf|jpg|JPG|gif|GIF|png|PNG|doc|DOC|docx|DOCX|mpg|swf|avi|mp3|mp4|zip|rar|gz|csv|o|obj|tar|gz|JPEG|jpeg|WMV|wmv|DAT|dat|3GP|3gp|MPEG|mpeg|VOD|vod|ear|jar|war|exe|ppt|PPT|PPTX|pptx|7z|iso|ISO|EAR|WAR|JAR|msg|MSG|rtf|RTF|xlsm|XLSM|vsd|VSD|dot|DOT|camrec|ECF|ecf|mff|MFF|class|CLASS)$"
}
{
for (i = 1; i < 2; i++) $i = ""; sub(/^ */, "");
if(match(tolower($1),FILTER))
{
print "File" $1 "is not allowed file type to commit"
exit 1
}
}'
exit 0
Below script works for me!! Do let me know your thoughts
I have the same problem as @San, but the answer from @Jijo doesn't directly help on my case because the script doesn't work for me as I am running the SVN server on
AIX
, I have enhance the script as shown below that could suit for my case. Anyhow thanks @Jijo sharing out the script.Solution for Windows pre-commit.bat