- /home/web/svn/ (store all my project source)
- /home/svn/ (store all my svn project)
Method 1
--- Check out your project to /home/web/svn/
cd /home/web/svn && sudo svn co file:///home/svn/your-project
--- Change permission to access this project
sudo chown -R www-data:www-data /home/svn/your-project
sudo chown -R www-data:www-data /home/svn
--- Create new file post-commit
sudo vim /home/svn/your-project/hooks/post-commit
--- Insert this string to "post-commit" file
REPOS="$1" REV="$2" cd /home/web/svn/ && svn update your-project
Save file!
--- Change permission to access "post-commit" file
sudo chmod 777 /home/svn/your-project/hooks/post-commit
Method 2
--- Create "post-commit" file at /home/svn
REPOS="$1" REV="$2" your-username-svn --password your-password-svn php /home/svn/post-commit.php $REPOS $REV
--- Create "post-commit.php" file at /home/svn
<?php file_put_contents('/tmp/svn.log', basename($_SERVER['argv'][1])); chdir('/home/web/svn'); $repos = scandir('.'); if (false !== ($repoCommitted = basename($_SERVER['argv'][1])) && in_array($repoCommitted, $repos)) { `/usr/bin/svn update $repoCommitted --username your-svn-username --password your-svn-password --quiet`; }
--- Create "updateHooks.php" file at /home/svn
<?php $svnPath = '/home/svn/'; chdir($svnPath); $files = scandir($svnPath); foreach ($files as $file) { if(!($file === '.' || $file === '..')) { if(is_dir($file)) { $cmd = "sudo cp {$svnPath}post-commit $svnPath$file/hooks";
$chmodFile = "sudo chmod 777 {$svnPath}post-commit";
`$cmd`; `$chmodFile`; } } }
`sudo chown -R www-data:www-data $svnPath`;
--- Run updateHooks.php file
php /home/svn/updateHooks.php
--- Change permission to access "post-commit" file
sudo chmod 777 /home/svn/your-project/hooks/post-commit
--- Check out your project to /home/web/svn
cd /home/web/svn && sudo svn co file:///home/svn/your-project
--- Change permission to access svn project
sudo chown -R www-data:www-data /home/svn
sudo chown -R www-data:www-data /home/svn/your-project
No comments:
Post a Comment