Question

I have a subversion repository laid out like this:

Repo
    ProjectA
        trunk
        branches
        tags
    ProjectB
        trunk
        branches
        tags

I'm trying to write a post-commit hook script that just applies to one project, but I just learned that they are housed at the root of the repository.

The only two parameters I get are the Repository path and Revision number. Is there any way for me to execute this script for just a particular project?

Thanks,

Solution: Ultimate solution went something like this:

#!/bin/bash
REPOS="$1"
REV="$2"
if svnlook changed -r $REV $REPOS | grep ProjectA; then
    echo "do stuff"
fi
Was it helpful?

Solution

yes, use svnlook to get the list of files modified in the committed revision, then grep on the names with a suitable regex to determine whether the path the post-commit contains your project name in the correct place, if it does execute the code, otherwise, jump to the end of the script and return 0.

OTHER TIPS

I came here looking for the answer to this question for VisualSVN on a Windows 2012 Server. After gathering some more information, here is the solution I came up with for a Windows batch file post-commit hook on VisualSVN that loads a PHP script on a development server to cause the specific project to be deployed to that server. The hook command is one line:

svnlook changed "%1" | findstr /L "ProjectA/trunk/" && powershell -Command "Invoke-WebRequest http://192.168.0.177/checkout_on_commit/checkout_on_commit.php -OutFile $ENV:SYSTEMROOT\Temp\commit.txt" || rem

The rem was needed as a "no-op" to prevent the hook from being reported by Tortoise as failing for commits to other projects. The contents of checkout_on_commit.php which cause the project to deploy on the Linux server are:

<?php
`date >> checkout.log`;
`svn sw --non-interactive --no-auth-cache --username project_a_readonly --password trytoguess https://svnserver/svn/GroupA/ProjectA/trunk /app/www/ >> checkout.log`;
?>

In Subversion does not exist a definition like a "Project"...the definition must be done by you. This means Subversion executes that on the change in the repository not on the "Project" base...

You can use the information you get like the repository and the revision number to extract the information you need...You can do that simply by using svnlook to extract the information you need..by calling svnlook with the appropriate parameters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top