[英]simple svn post-commit-hook updating dir with changed files
I used some script i found somewhere:(im a total svn noob, is it used for copying files after committing them to a repo?) 我使用了我在某处找到的一些脚本:(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
Paths: 路径:
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
When i run it from terminal i get: 当我从终端运行它时,我得到:
Repository argument required Type 'svnlook help' for usage.
需要存储库参数键入“ svnlook help”以供使用。
When i do a commit /usr/local/node/ isn't changed 当我执行提交时/ usr / local / node /不变
I assume you forgot to pass this script any arguments when you ran it by hand. 我假设您在手动运行脚本时忘记将任何参数传递给该脚本。 The first argument (
$1
) is assigned to $REPOS
, which is used in the svnlook
command executed in the for
loop. 第一个参数(
$1
)分配给$REPOS
,该$REPOS
在for
循环中执行的svnlook
命令中使用。
Be sure to run the script correctly -- with the repository path as the first argument and the revision just committed as the second argument. 确保正确运行脚本-以存储库路径作为第一个参数,而修订仅提交为第二个参数。
Be sure to spend some time with the SVN book before executing this -- it must be run as root (see the chown(1)
command) and it might remove data you care about (see the unlink(1)
and rm(1)
commands). 在执行此操作之前,请务必花一些时间在SVN书上 -它必须以root用户身份运行(请参阅
chown(1)
命令),并且它可能会删除您关心的数据(请参阅unlink(1)
和rm(1)
命令)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.