[英]simple svn post-commit-hook updating dir with changed files
我使用了我在某處找到的一些腳本:(im svn noob,將文件提交到倉庫后是否用於復制文件?)
#!/bin/bash
REPOS="$1"
REV="$2"
# A - Item added to repository
# D - Item deleted from repository
# U - File contents changed
# _U - Properties of item changed; note the leading underscore
# UU - File contents and properties changed
# Files and directories can be distinguished, as directory paths are displayed with a trailing "/" character.
LOOK=/usr/bin/svnlook
SVN=/usr/bin/svn
DEV=/usr/local/node/
cd /var/tmp/svn
for changes in `$LOOK changed $REPOS | awk '{print $1 "=" $2;}'`;
do
len=${#changes}
idx=`expr index "$changes" =`;
directory=${changes:$idx};
action=${changes:0:$idx-1};
if [ ${changes:len-1} = '/' ]
then
case "$action" in
"A" ) \
mkdir --mode=775 -p $DEV/$directory;
chown nobody:nobody $DEV/$directory;
chmod 775 $DEV/$directory;
;;
"D" ) \
rmdir $DEV/$directory;
;;
esac
else
case "$action" in
"A"|"U"|"UU" ) \
$SVN export --force --non-interactive -r HEAD -q file://$REPOS/$directory;
BASE=`basename $directory`;
DIR=`dirname $directory`;
chown nobody:nobody $BASE;
chmod 775 $BASE;
mkdir --mode=775 -p $DEV/$DIR;
cp -f --preserve=ownership $BASE $DEV/$DIR;
unlink $BASE;
;;
"D" ) \
rm -f $DEV/$directory;
;;
esac
fi
done
exit 0
路徑:
Path i want to copy all the modified files after committing:
/usr/local/node/
Repo location:
/var/lib/svn/api/
Hook location:
/var/lib/svn/api/hooks/post-commit
當我從終端運行它時,我得到:
需要存儲庫參數鍵入“ svnlook help”以供使用。
當我執行提交時/ usr / local / node /不變
我假設您在手動運行腳本時忘記將任何參數傳遞給該腳本。 第一個參數( $1
)分配給$REPOS
,該$REPOS
在for
循環中執行的svnlook
命令中使用。
確保正確運行腳本-以存儲庫路徑作為第一個參數,而修訂僅提交為第二個參數。
在執行此操作之前,請務必花一些時間在SVN書上 -它必須以root用戶身份運行(請參閱chown(1)
命令),並且它可能會刪除您關心的數據(請參閱unlink(1)
和rm(1)
命令)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.