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:
#!/bin/sh
SCM_REPO_PATH=$1
SCM_TYPE=$2
SCM_PROJECT=$3
SCM_REPO_NAME=$(basename $SCM_REPO_PATH)
SCM_REPO_ROOT=$(dirname $SCM_REPO_PATH)
SVN_HOOKS=
GIT_HOOKS=
MERCURIAL_HGRC=
[ -d "$SCM_REPO_PATH" ] || exit 1
case "$SCM_TYPE" in
svn)
if [ -d "$SVN_HOOKS" ]; then
mkdir -p "$SCM_REPO_PATH/hooks"
cp -aR $SVN_HOOKS/* "$SCM_REPO_PATH/hooks"
fi
;;
git)
if [ -d "$GIT_HOOKS" ]; then
mkdir -p "$SCM_REPO_PATH/hooks"
cp -aR $GIT_HOOKS/* "$SCM_REPO_PATH/hooks"
fi
;;
mercurial)
if [ -f "$MERCURIAL_HGRC" ]; then
mkdir -p "$SCM_REPO_PATH/.hg"
cp "$MERCURIAL_HGRC" "$SCM_REPO_PATH/.hg/hgrc"
fi
;;
*)
echo "SCM not supported: $SCM_TYPE" >&2
;;
esac
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:
SVN_HOOKS=/etc/subversion/hooks
GIT_HOOKS=/etc/git/hooks
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):
production:
...
post_create: /usr/local/bin/copy-hooks.sh
...
Restart¶
Restart Redmine/ChiliProject to apply.