The script is implemented in pre-commit hooks script. This file locate inside the hooks directory of each repository, initially it has a file named pre-commit.tmpl, I’m require to remove the tmpl extension and grant this file with execute access right.
Append the following content into pre-commit file.
#Put all the restricted formats in variable FILTER FILTER=".(xls|xlsx|exe|pptx|PPTX|vsd|VSD|bak|BAK|class|CLASS|zip|ZIP|doc|DOC|docx|DOCX)$" # Capture extension token of each new files to be commit FILES=$(${SVNLOOK} changed -t ${TXN} ${REPOS} | ${AWK} '{ print $NF }') > /dev/null for FILE in $FILES do EXTENSION=`echo "$FILE" | cut -d'.' -f2-` if [[ "$FILTER" == *"$EXTENSION"* ]]; then echo "Your commit has been blocked because you are trying to commit a restricted file." 1>&2 echo "Please contact SVN Admin. -- Thank you" 1>&2 exit 1 fi doneNow whenever users commit a file or files having the extension mention in the FILTER, the commit will not be success.
No comments:
Post a Comment