問題
コミット前処理を行うpre-commit
フックを作ったのにgit commit
で発動しないでござる。
例えばこういうのGo言語のハードタブがつらいマンのgit pre-commitフック - DRYな備忘録。
原因
実行権限が無いでござる。
% ls -la .git/hooks/ total 88 drwxr-xr-x 12 otiai10 staff 408 4 19 15:34 . drwxr-xr-x 14 otiai10 staff 476 4 19 15:35 .. -rwxr-xr-x 1 otiai10 staff 452 4 15 08:26 applypatch-msg.sample -rwxr-xr-x 1 otiai10 staff 896 4 15 08:26 commit-msg.sample -rwxr-xr-x 1 otiai10 staff 189 4 15 08:26 post-update.sample -rwxr-xr-x 1 otiai10 staff 398 4 15 08:26 pre-applypatch.sample -rw-r--r-- 1 otiai10 staff 57 4 19 03:08 pre-commit -rwxr-xr-x 1 otiai10 staff 1642 4 15 08:26 pre-commit.sample -rwxr-xr-x 1 otiai10 staff 1352 4 15 08:26 pre-push.sample -rwxr-xr-x 1 otiai10 staff 4951 4 15 08:26 pre-rebase.sample -rwxr-xr-x 1 otiai10 staff 1239 4 15 08:26 prepare-commit-msg.sample -rwxr-xr-x 1 otiai10 staff 3611 4 15 08:26 update.sample
解決
chmod
するでござる。
% chmod a+x .git/hooks/pre-commit % ls -la .git/hooks total 88 drwxr-xr-x 12 otiai10 staff 408 4 19 15:34 . drwxr-xr-x 14 otiai10 staff 476 4 19 15:41 .. -rwxr-xr-x 1 otiai10 staff 452 4 15 08:26 applypatch-msg.sample -rwxr-xr-x 1 otiai10 staff 896 4 15 08:26 commit-msg.sample -rwxr-xr-x 1 otiai10 staff 189 4 15 08:26 post-update.sample -rwxr-xr-x 1 otiai10 staff 398 4 15 08:26 pre-applypatch.sample -rwxr-xr-x 1 otiai10 staff 57 4 19 03:08 pre-commit -rwxr-xr-x 1 otiai10 staff 1642 4 15 08:26 pre-commit.sample -rwxr-xr-x 1 otiai10 staff 1352 4 15 08:26 pre-push.sample -rwxr-xr-x 1 otiai10 staff 4951 4 15 08:26 pre-rebase.sample -rwxr-xr-x 1 otiai10 staff 1239 4 15 08:26 prepare-commit-msg.sample -rwxr-xr-x 1 otiai10 staff 3611 4 15 08:26 update.sample
この状態でgit commit
したら発動したでござる。
Thanks to id:kazz187
DRY