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

Re: pre-commit example

From: Ryan Schmidt <subversion-2009a_at_ryandesign.com>
Date: Thu, 8 Jan 2009 20:32:58 -0600

On Jan 8, 2009, at 06:49, Ilan Yaniv wrote:

> I guess more then one of you guys have a pre-commit script maybe
> bat or perl so I can also read that…
> That will not commit certain files like “thumbs.db”.
> If the hook will find that there is a file like that, it will be
> removed from the commit, so the commit will complete, but without
> that file.

The correct solution will be in 3 parts.

1. pre-commit hook. As was explained by others, you won't be able to
accept part of the commit while removing other parts. Your pre-commit
hook can only accept or reject the entire commit. So you will have to
check if the commit includes a file with that name, and if so, reject
it entirely and tell the user not to include such files in the commit.

2. svn:ignore. Additionally, you can set svn:ignore on each directory
in the repository where such a file might occur. This way, "svn
status" will not show these files as unversioned, and TortoiseSVN for
example will probably not offer it for inclusion in the commit. The
user does not need to set up anything on their client for this to work.

3. global-ignores. You can also edit the global-ignores section of
every Subversion client's configuration file to include this
filename. This has the same effect as setting svn:ignore on every
directory, except that it is global to that Subversion client; it
applies to all directories.

Step 1 is the one that will actually prevent these files from getting
into your repository. Steps 2 and 3 are conveniences for your users
to help them not attempt to commit those files. You can write the
error message your pre-commit hook in step 1 prints so that it refers
your users to instructions about how to accomplish steps 2 and/or 3.


To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-01-09 14:24:01 CET

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.