Created
April 3, 2014 08:08
-
-
Save fumiyas/9950344 to your computer and use it in GitHub Desktop.
Subversion: UTF-8 以外のファイル名を拒否する pre-commit スクリプト (UTF-8-Mac, NFD, NFKD も拒否)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## | |
## SVN: pre-commit hook script | |
## Copyright (c) 2014 SATOH Fumiyasu @ OSS Technology Corp., Japan | |
## <http://www.OSSTech.co.jp/> | |
## | |
## License: GNU General Public License version 3 | |
## Date: 2014-03-03, since 2014-04-03 | |
## | |
set -u | |
LC_ALL=ja_JP.UTF-8 | |
export LC_ALL | |
## Options | |
## ====================================================================== | |
svn="/usr/bin/svn" | |
svnlook="/usr/bin/svnlook" | |
nkf="/usr/bin/nkf" | |
if [ $# -lt 2 ]; then | |
echo "Usage: $0 REPOSITORY TXNNAME" | |
exit 0 | |
fi | |
commit_repos="$1"; shift | |
txn_name="$1"; shift | |
## Main | |
## ====================================================================== | |
## Retrieve commit info | |
## ---------------------------------------------------------------------- | |
commit_changed="`"$svnlook" changed -t "$txn_name" "$commit_repos"`" | |
## Check filename encoding | |
## ---------------------------------------------------------------------- | |
commit_added="`echo "$commit_changed" |grep '^A'`" | |
commit_added_u="`echo "$commit_added" |"$nkf" --ic=UTF-8-Mac --oc=UTF-8 -m0 -x`" | |
if [ x"$commit_added" != x"$commit_added_u" ]; then | |
echo "Invalid filname encoding detected." 1>&2 | |
echo "Use UTF-8 (except UTF-8-Mac, NFD and NFKD)." 1>&2 | |
exit 1 | |
fi | |
## Done | |
## ---------------------------------------------------------------------- | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment