-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b09ba8
commit 5825fc2
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# githooks | ||
このディレクトリは本来であれば、.git/hooks/ に配置するディレクトリです。 | ||
|
||
.git は、リポジトリの設定を管理するディレクトリであり、バージョン管理対象外です。 | ||
|
||
そのため、.githooks/の内容を.git/hooks/へコピーすることで、リポジトリのGit操作に適用しています。 | ||
|
||
以下のコマンドは、mint setupの一部として実行されます。 | ||
|
||
|
||
```zsh | ||
$ cp -r .githooks .git/hooks | ||
|
||
$ chmod -R +x .git/hooks | ||
``` | ||
|
||
# 参考 | ||
https://git-scm.com/docs/githooks | ||
|
||
https://www.farend.co.jp/blog/2020/04/git-hook/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
git fetch | ||
make setup |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
|
||
# コミットメッセージは .git/COMMIT_EDITMSG に保存されてる | ||
COMMIT_MSG_FILE_PATH="$1" | ||
|
||
# コミットメッセージ読み込み | ||
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE_PATH") | ||
|
||
# [Int値] の正規表現 | ||
PATTERN="^\[\d+\]" | ||
|
||
# コミットメッセージの検証 | ||
if ! echo "$COMMIT_MSG" | grep -qE "$PATTERN"; then | ||
# \033[31m は赤文字にするANSIエスケープシーケンス | ||
echo "\033[31mERROR: コミットメッセージは '[Issue番号]' で始めてください。" | ||
echo "このままコミットを続けますか? (y/n)" | ||
read answer | ||
case $answer in | ||
[Yy]* ) | ||
;; | ||
* ) | ||
echo "コミットを中止します。" | ||
exit 1 | ||
;; | ||
esac | ||
fi | ||
|
||
exit 0 |