使用Collabnet SVN的预提交脚本中的以下代码来限制特定文件扩展名以提交,但它提交所有文件。你能告诉我哪里出错了。
#!/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
答案 0 :(得分:3)
下面的脚本适合我! 请让我知道你的想法
#!/bin/bash
REPOS=$1
TXN=$2
AWK=/bin/awk
SVNLOOK="/usr/bin/svnlook";
#Put all the restricted formats in variable FILTER
FILTER=".(sh|xls|xlsx|exe|xlsm|XLSM|vsd|VSD|bak|BAK|class|CLASS)$"
# Figure out what directories have changed using svnlook.
FILES=`${SVNLOOK} changed ${REPOS} -t ${TXN} | ${AWK} '{ print $2 }'` > /dev/null
for FILE in $FILES; do
#Get the base Filename to extract its extension
NAME=`basename "$FILE"`
#Get the extension of the current file
EXTENSION=`echo "$NAME" | cut -d'.' -f2-`
#Checks if it contains the restricted format
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
done
exit 0
答案 1 :(得分:0)
我和@San有同样的问题,但@Jijo的答案对我的情况没有直接帮助,因为脚本对我不起作用,因为我在{{1上运行SVN服务器我已经增强了如下所示的脚本,可以适合我的情况。无论如何,谢谢@Jijo分享剧本。
AIX
答案 2 :(得分:0)
Windows pre-commit.bat
的解决方案span.fields{display:inline-block;}