svnでコメントにredmineのチケット番号がないコミットを拒否する


今時svnかよという声が聞こえてきそうだが、gitとかmercurialとかよくわからんのです。

分散システムのいいところは任意のレポジトリの管理をやりたいようにできることなのかなー、ぐらいにしか理解していない。本番用のレポジトリの管理とかはとっても楽になると思うけど、そこを気にするレベルに達してない。

で本題。以下のサイトを参考にしました。あざす。

http://syo.cocolog-nifty.com/freely/2007/11/subversion_4cff.html
http://d.hatena.ne.jp/language_and_engineering/20100819/p1

osはubuntu 10.04

SVNPATH/hooksの中に

  • post-commit.tmpl
  • post-lock.tmpl
  • post-revprop-change.tmpl
  • post-unlock.tmpl
  • pre-kommit.tmpl
  • pre-lock.tmpl
  • pre-revprop-change.tmpl
  • pre-unlock.tmpl
  • start-commit.tmpl


というファイルがある。
このpost-commit.tmplがコミット前にチェックするやつのテンプレらしい。ファイルのコピー、実行権限の付与なんかは上記サイトに任せるとして、実行ファイルを作ったのち、以下のように書き換える。


REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
#$SVNLOOK log -t "$TXN" "$REPOS" | \
# grep "." > /dev/null || exit 1

$SVNLOOK log -t "$TXN" "$REPOS" | \
grep " refs " > /dev/null || exit 1

# Exit on all errors.
set -e

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
#"$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN \
# "$REPOS"/hooks/commit-access-control.cfg

# All checks passed, so allow the commit.
exit 0

はい、ほとんど一緒ですね。
ちなみにredmineでは"refs #○○"というチケットナンバーの書き方以外にもいろいろ設定できるらしい。

http://redmine.jp/tech_note/subversion/

とりあえず"refs"があればいいや。