Post commit hook problem for

蓝咒 提交于 2019-12-23 04:58:16

问题


I want to update the files which were changed as my SVN size is 20GB.

My SVN Repo is located at: /media/disk3/velsvn/projects
My Checkout Folder is at: /media/disk2/www/htdocs


(Reference: Using SVN post-commit hook to update only files that have been committed)

My post-commit file looks like:

#!/bin/bash
REPOS="$1"  
REV="$2"  
cd /media/disk2/www/htdocs  
svnlook dirs-changed /media/disk3/velsvn/projects | xargs /usr/bin/svn up -N

(I was using REPOS and REV but they were giving error so I removed them. While using REV it used to say the REV is not defined. While using REPOS it used to say [REPOS]/format is not a file or does not exit.)

I am getting the following error when trying to execute this file -
Skipped 'PHP/htdocs/supporter' Skipped 'PHP/htdocs/campus'


Can anyone help me in this regard. I have wasted 2 days working on this and yet did not find any solution.

Regards,

Nitin


回答1:


I could resolve the issue by changing my procedure. Listing it down here as it may help someone else. May be its not a perfect solution, but atleast it works.

POST_COMMIT

#!/bin/sh
wget http://localhost/update_svn.php

update_svn.php

<?php
$output = shell_exec('/media/disk3/velsvn/projects/hooks/svn_update_step1.sh');
echo "<pre>$output</pre>";
?>

svn_update_step1.sh

ssh -i /media/d/mykey/id_rsa velsvnuser@localhost /media/disk3/velsvn/projects/hooks/svn_update_step2.sh

svn_update_step2.sh

#!/bin/sh
cd /media/disk3/velsvn/projects/hooks
rm -f filelist
rm -f log
whoami >> log

    svnlook dirs-changed /media/disk3/velsvn/projects/  | sed "s/^..//" | awk '{ print substr( $0, 9 ) }' >> /media/disk3/velsvn/projects/hooks/filelist; sed -i -e 's#^#/media/disk2/www/htdocs#' filelist; cat /media/disk3/velsvn/projects/hooks/filelist | xargs /usr/bin/svn up -N >> /media/disk3/velsvn/projects/hooks/log

Note: 1. /media/d/mykey/id_rsa is the key which was generated for SSH access. This ensures that the system does not waits for the user to provide password to connect to SVN as well as execute shell scripts. 2. POST-COMMIT file and the shell files sh1 and sh2 were given +x mod so that they can be executed.

Please feel free to comment on this post and provide a better looking solution. All I know right now is, this solution works :)



来源:https://stackoverflow.com/questions/6876365/post-commit-hook-problem-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!