php-git-hooks icon indicating copy to clipboard operation
php-git-hooks copied to clipboard

"Force" run option

Open Umkus opened this issue 7 years ago • 5 comments

Is there an option to force the hooks to be run on all of the code base even if there was no code change?

For example if I've just installed the commit hooks for a big existing project. I'm interested to run the checks asap to see what problems with the code exists, not have to wait until some particular files happen to be changed.

Currently I trick it into checking all of the files by:

  • chmod the complete project tree to make it look changed
  • Add all of the files to commit
  • Trigger the hooks by committing
  • Fixing all of the found problems
  • Reverting the chmod command
  • Actually committing

Having a force-run option would be really nice particularly for CI.

Umkus avatar Sep 26 '16 10:09 Umkus

Hi.

Interesting for new feature.

Maybe I could do a comand to execute each tool.

For example:

bin/php-git-hooks "TOOL_NAME"

With options:

  • --all (to execute all tools)
  • --phpcs
  • --php-cs-fixer
  • --phplint
  • --jsonlint
  • --phpmd
  • --phpunit

Always reading your php-git.hooks.yml configuration file.

bruli avatar Sep 26 '16 15:09 bruli

For example, yes. Generally what I'm trying to achieve is to be able to configure the commit hooks only once and then trigger it in the same config on:

  • local development box (commit/push)
  • Jenkins server (test/build)

Umkus avatar Sep 26 '16 19:09 Umkus

It's really nice to have in native support.

Now my solution is running in Jenkins/Codeship/Other CI server after each commit

git reset --soft HEAD~
php vendor/bruli/php-git-hooks/hooks/pre-commit

It covers all changes in last commit not all code base, but it's usually enough for CI workflow.

pluseg avatar Mar 26 '17 22:03 pluseg

Sorry by the delay.

I'm thinking about it, and think is better create a new project to do it. I mean, this project is only for a git hook. If you wants run php tools (phpunit, phpcs, and more), with a single command to use in a continuous integration server or in your code by hand you can do it with other tool (project).

What do you think?.

bruli avatar Sep 20 '17 09:09 bruli

Hi. Interesting for new feature. Maybe I could do a comand to execute each tool. For example: bin/php-git-hooks "TOOL_NAME" With options: --all (to execute all tools) --phpcs --php-cs-fixer --phplint --jsonlint --phpmd --phpunit Always reading your php-git.hooks.yml configuration file.

I found this very interesting, what about a PR?

danitome24 avatar Apr 04 '18 11:04 danitome24