Code Monkey home page Code Monkey logo

commit-msg's Introduction

commit-msg

このスクリプトはgit commitしたときにPHPCSを自動で実行し、PHPCSによる指摘がないかを判定するスクリプトです。

機能

  • git commit時に自動で 変更されたファイル単位で PHPCSを自動実行します
  • PHPCS実行の結果、問題がない場合にはgit commitが正常終了します
  • PHPCS実行の結果、指摘が残っている場合には commitがキャンセルされます
$ git commit -m "テストコミット"
[PHPCS:CakePHP] cakephp/src/Lib/RedmineDriver.php <ERROR>
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 19 | WARNING | Doc comment for parameter "$apiKey" missing
----------------------------------------------------------------------

[PHPCS:CakePHP] cakephp/src/Shell/SampleShell.php <ERROR>
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 30 | WARNING | Comment refers to a TODO task
----------------------------------------------------------------------

Oops, PHPCS has not passed.
This commit is CANCELED.
  • PHPCS実行をスキップしたいときにはコミットメッセージに PHPCS_SKIP のキーワードを含める必要があります

スキップ例

git commit -m "[PHPCS_SKIP] テストコミット"

インストール

gitディレクトリにある install.sh のスクリプトを実行するだけです。

$ ./install.sh /path/to/your/repository

初期設定

インストール後に各自の環境に合わせてgitの設定が必要です。

$ git config phpcs.executepath /path/to/your/phpcs
$ git config phpcs.standard "your ruleset"

commit-msg's People

Contributors

sameyasu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.