Edgewall Software

Ticket #6016: post-revprop-change

File post-revprop-change, 1.8 KB (added by cboos, 5 years ago)

Example post-revprop-change hook that allows for editing the message and the author and syncs the change back in trac. Should work with any Trac versions > 0.10.4.

Line 
1#!/bin/sh
2
3# POST-REVPROP-CHANGE HOOK
4#
5# The post-revprop-change hook is invoked after a revision property
6# has been changed. Subversion runs this hook by invoking a program
7# (script, executable, binary, etc.) named 'post-revprop-change'
8# (for which this file is a template), with the following ordered
9# arguments:
10#
11#   [1] REPOS-PATH   (the path to this repository)
12#   [2] REV          (the revision that was tweaked)
13#   [3] USER         (the username of the person tweaking the property)
14#   [4] PROPNAME     (the property that was changed)
15#
16# Because the propchange has already completed and cannot be undone,
17# the exit code of the hook program is ignored.  The hook program
18# can use the 'svnlook' utility to help it examine the
19# new property value.
20#
21# On a Unix system, the normal procedure is to have 'post-revprop-change'
22# invoke other programs to do the real work, though it may do the
23# work itself too.
24#
25# Note that 'post-revprop-change' must be executable by the user(s) who will
26# invoke it (typically the user httpd runs as), and that user must
27# have filesystem-level permission to access the repository.
28#
29# On a Windows system, you should name the hook program
30# 'post-revprop-change.bat' or 'post-revprop-change.exe',
31# but the basic idea is the same.
32#
33# Here is an example hook script, for a Unix /bin/sh interpreter:
34
35REPOS="$1"
36REV="$2"
37USER="$3"
38PROPNAME="$4"
39
40# ---- resync comment changes after pre-revprop-change
41
42LOG=/var/log/svn/pre-revprop-change
43
44# production Trac
45TRAC_ENV=/path/to/your/trac/env
46
47# For testing, use:
48# TRAC_ENV=...
49
50# Python settings
51PYTHON_HOME=/opt/python-2.4.4
52
53PATH=$PYTHON_HOME/bin:$PATH
54export PATH
55LD_LIBRARY_PATH=/opt/sqlite-3.3.8/lib:/opt/python-2.4.4/lib
56export LD_LIBRARY_PATH
57
58# ----
59
60if [ "$PROPNAME" = "svn:log" -o "$PROPNAME" = "svn:author" ]
61then
62        trac-admin $TRAC_ENV resync $REV 2>> $LOG.err >> $LOG.log
63fi
64
65