forked from stop-covid19-hyogo/covid19
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit.sh
More file actions
executable file
·31 lines (27 loc) · 877 Bytes
/
pre-commit.sh
File metadata and controls
executable file
·31 lines (27 loc) · 877 Bytes
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
#!/usr/bin/env bash
# ref: https://qiita.com/ryounagaoka/items/3e7a1b44d43ad0547d4f
unchangeable_files=(
^assets/locales-hyogo/en.json
^assets/locales-hyogo/ja-Hira.json
^assets/locales-hyogo/ko.json
^assets/locales-hyogo/pt_BR.json
^assets/locales-hyogo/th.json
^assets/locales-hyogo/vi.json
^assets/locales-hyogo/zh_CN.json
^assets/locales-hyogo/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