2

I used to have this post-commit hook to update my working-copy on my server:

#!/bin/sh
cd /var/www/MyWebAppStaging
svn up >> /var/log/svn/MyWebApp.log

Inside /var/www/MyWebAppStaging was obviously a working copy of my project

But now I have a several projects inside my repository. My repository lies under /var/svn/repository and has two projects:

MyWebApp --> trunk
MyMobileWebApp --> trunk

I have the following folders inside /var/www

/var/www

 |-->MyWebApp

 |-->MyWebAppStating

 |-->MyMobileWebApp

 |-->MyMobileWeAppStaging

I someone commits code to the MyWebApp-Project I would like my post-commit to update the working copy under /var/www/MyWebAppStaging. And if some commits code to the MyMobileApp-Project I would like my post-commit to upate the working copy under /var/www/MyMobileAppStaging

So how can I change my post-commit, that it updates the right working copy depending on the project the commit belonged to?

Pascal Klein
  • 23,665
  • 24
  • 82
  • 119

1 Answers1

2

You can use svnlook to find out what files have been modified in a commit. For this, people typically use Perl or Python in a post-commit hook, but something like this might work (untested):

if (svnlook changed -r $2 $1|grep MyWebApp)
then
    (cd /var/www/MyWebAppStaging; svn up >> /var/log/svn/MyWebApp.log)
fi
if (svnlook changed -r $2 $1|grep MyMobileApp)
then
    (cd /var/www/MyMobileAppStaging; svn up >> /var/log/svn/MyWebApp.log)
fi
Martin v. Löwis
  • 124,830
  • 17
  • 198
  • 235