[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Using subversion for web development

From: Ryan Schmidt <subversion-2008c_at_ryandesign.com>
Date: Wed, 20 Aug 2008 14:13:32 -0500

On Aug 20, 2008, at 09:32, Robert Dailey wrote:

> On Tue, Aug 19, 2008 at 7:09 PM, Ryan Schmidt wrote:
>
>> There's not much to it. Assuming you have already checked out a
>> working copy to /path/to/workingcopy, you probably don't need much
>> more than this in your post-commit hook:
>>
>>
>> #!/bin/sh
>>
>> /usr/local/bin/svn update --non-interactive /path/to/workingcopy
>
> Thanks for your help. This seems to work. However, for newly added
> files when an update occurs on my server, I need to set the group
> for those files (chown) and also need to set the permissions of
> those files (chmod). Is there a way of getting a list of all newly
> added files from subversion in the post-commit script? Or am I
> stuck with just blindly doing a "chmod -R" on the entire working
> copy every time an update occurs?

Sure, that would be something like this:

--------------------------------------

#!/bin/sh

REPO="$1"
REV="$2"

WC=/path/to/workingcopy

SVN=/usr/local/bin/svn
SVNLOOK=/usr/local/bin/svnlook
SED=/usr/bin/sed
CHOWN=/usr/sbin/chown
CHMOD=/bin/chmod

# Update working copy
$SVN update --non-interactive $WC

# Fix ownership and permissions of newly added files
for i in `$SVNLOOK changed -r $REV $REPO | $SED -n 's%^A %%p'`; do
        chown someuser:somegroup $WC/$i
        chmod 644 $WC/$i
done

--------------------------------------

Note this may blow up if any items have spaces in their names.

Also note this is calling chown and chmod on directories as well as
files. If you want to handle directories and files differently, you
can look at the last character on the line of output from svnlook --
if it's a slash, the item is a directory, otherwise it isn't.

And note that this assumes that your working copy is checked out from
the root of the repository, which is probably not the case if you're
using tags and branches, or if you have multiple projects in one
repository. You'll have to further filter the output of svnlook to
include just those paths that are within the part that's been checked
out.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-08-20 21:14:03 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.