Skip to content

Document pre-commit #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pre-commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Running tests as pre-commit hooks

If you want to run some of the tests as git hooks to avoid comitting "bad" code, you can do that. It would probably make most sense to only run static tests.

Usually static tests are run with the command `composer test-static`. To run this as a git hook you can simply add this file to a file called `.git/hooks/pre-commit` in your project:

```sh
#!/bin/sh

composer test-static
```

If you think that takes too long, and you just want to run code style checks with phpcs, you can instead change it to something like this:

```sh
#!/bin/sh

vendor/bin/phpcs -pn
```