Migrating from hooks to scripts¶
What earlier could be done with hooks/hgrc option is now also possible to do with scripts. As I believe files copying should be done in scripts the hooks option now becomes obsolete and can be removed in future versions... So it is highly recommended to reconfigure your plugin installations to use scripts! This page describes how to do this.
The script¶
The following script replaces the hooks/hgrc option:
1 #!/bin/sh
2
3 SCM_REPO_PATH=$1
4 SCM_TYPE=$2
5 SCM_PROJECT=$3
6
7 SCM_REPO_NAME=$(basename $SCM_REPO_PATH)
8 SCM_REPO_ROOT=$(dirname $SCM_REPO_PATH)
9
10 SVN_HOOKS=
11 GIT_HOOKS=
12 MERCURIAL_HGRC=
13
14 [ -d "$SCM_REPO_PATH" ] || exit 1
15
16 case "$SCM_TYPE" in
17 svn)
18 if [ -d "$SVN_HOOKS" ]; then
19 mkdir -p "$SCM_REPO_PATH/hooks"
20 cp -aR $SVN_HOOKS/* "$SCM_REPO_PATH/hooks"
21 fi
22 ;;
23 git)
24 if [ -d "$GIT_HOOKS" ]; then
25 mkdir -p "$SCM_REPO_PATH/hooks"
26 cp -aR $GIT_HOOKS/* "$SCM_REPO_PATH/hooks"
27 fi
28 ;;
29 mercurial)
30 if [ -f "$MERCURIAL_HGRC" ]; then
31 mkdir -p "$SCM_REPO_PATH/.hg"
32 cp "$MERCURIAL_HGRC" "$SCM_REPO_PATH/.hg/hgrc"
33 fi
34 ;;
35 *)
36 echo "SCM not supported: $SCM_TYPE" >&2
37 ;;
38 esac
39
40 exit 0
This script can be downloaded using the following link: copy-hooks.sh.
Configuring the script¶
Transfer your hooks/hgrc settings into the script:
1 SVN_HOOKS=/etc/subversion/hooks
2 GIT_HOOKS=/etc/git/hooks
3 MERCURIAL_HGRC=/etc/mercurial/hgrc
Optionally play with the script to be sure it works.
Configuring the plugin¶
Remove the hooks and/or hgrc options from csm.yml! And add new option post_create (specify the path to the script):
1 production:
2 ...
3 post_create: /usr/local/bin/copy-hooks.sh
4 ...
Restart¶
Restart Redmine/ChiliProject to apply.
