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

Re: how do you write a commit hook to trap on commits to a specific file?

From: Stefan Sperling <stsp_at_elego.de>
Date: Thu, 16 Dec 2010 19:10:38 +0100

On Thu, Dec 16, 2010 at 10:44:05AM -0600, Mark Meyer wrote:
> Hello all,
>
>
>
> I am currently using svn commit hooks in our environment to trap ALL
> commits. The commit hook sends an email to my address.
>
>
>
> A typical email generated by a commit looks like this:
>
>
>
> >>
>
> Author: mmeyer
>
>
>
> Comments: added comments
>
>
>
>
>
> 3935
>
> U Java Projects/sandbox/mark/schema/auf/xml/testdbupgrade.xml
>
> <<
>
>
>
>
>
> How do you write a commit hook that traps on changes to a SPECIFIC file
> (our database create script) so I can capture all of these changes
> separately. This would allow me to do a better job of maintaining our
> alter scripts that migrate our database from one version to the next.
>
>
>
> Example:
>
>
>
> I would like to hook on any changes made when this file is changed:
>
>
>
> <<
>
> Comments: added ip_address to conditions and added received_timestamp
> to test results
>
>
>
>
>
> 3922
>
> U Database/trunk/MP/mysql/create/primexmp-create.sql
>
> <<
>
>
>
> Thank you,
>
> Mark

In the post-commit hook, you could get the list of files modified in the
committed revision and send email if the file appears in this list.

In pseudocode:

  REPOS_PATH="$1" # First parameter passed to post-commit hook by Subversion
  REV="$2" # Second parameter passed to post-commit hook by Subversion
  MYFILE=Database/trunk/MP/mysql/create/primexmp-create.sql
  if output of "svnlook changed -r $REV $REPOS_PATH" contains $MYFILE:
          send email
  endif

Stefan
Received on 2010-12-16 19:11:33 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.