forked from Tokyo-Metro-Gov/covid19
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pre-commit.sh
31 lines (27 loc) · 819 Bytes
/
pre-commit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# ref: https://qiita.com/ryounagaoka/items/3e7a1b44d43ad0547d4f
unchangeable_files=(
^assets/locales/en.json
^assets/locales/ja-Hira.json
^assets/locales/ko.json
^assets/locales/pt_BR.json
^assets/locales/th.json
^assets/locales/vi.json
^assets/locales/zh_CN.json
^assets/locales/zh_TW.json
)
containsElement () {
local e
for e in "${@:2}"; do [[ "$1" =~ $e ]] && return 0; done
return 1
}
for FILE in `git diff --cached --name-status $against -- | cut -c3-`; do
if containsElement $FILE "${unchangeable_files[@]}"; then
echo "$FILE"
CHANGE_DETECTED=1
fi
done
if [ "$CHANGE_DETECTED" ]; then
echo "Failed to commit because of the modification of the files above. {lang}.json files are only allowed to edit from Transifex. See issue #1985 for the details. "
exit 1
fi