在 git Commit 之前檢查 PHP 是否有錯誤

Git-Logo-2Color
在 commit code 之前,程式設計師必須確保程式碼的正確性,包含不要放入 debug message 到

git server,寫了一個簡單的 pre-commit 程式,來確保 PHP 是否有 Parse error,或者是在寫 CoffeeScript 及 JavaScript 時,常常會用到 console.* 來當作中斷點或者是顯示變數資料,這也是需要盡量避免 commit 到伺服器,你可不想要長官 review 的時候看到這麼多 debug 訊息吧。這時候就是需要 git-hookspre-commit 幫忙檢查這些 Syntax 語法,可以直接參考我的 git-hooks 專案。安裝方式很簡單:

$ git clone https://github.com/appleboy/git-hooks.git
$ chmod +x bin/hooks.sh pre-commit
$ ./bin/hooks.sh your_project_path
如果使用 git commit 之前,就會檢查 .js、.coffee、.php 等副檔名。

See also