Git: pre-receive hook with PHP_CodeSniffer

后端 未结 10 1761
情话喂你
情话喂你 2021-02-04 07:51

Since switching from SVN to Git, we lost the ability to enforce our coding standards through a pre-commit hook on the subversion server.

With Git, you only

10条回答
  •  不要未来只要你来
    2021-02-04 08:31

    I don't have an exact answer to this question directly using pre-commit/pre-recieve hooks etc.

    I approach this from the other way, running a CI server, (I use jenkins) running phpcs and the checkstyle plug-in for Jenkins.

    This allows me to fail the build and email the committer based on the checkstyle report.

    Optionally I can set thresholds, so I get an unstable build if there are upto 5 new style violaions but a failure if more than 5 are committed.

    Also I can set overall thresholds, so more than 10 violations in the whole project causes a failure and emails the team.

    This could be your intermediate server as mentioned above. The post build actions can include a Push to another git repo.

提交回复
热议问题