Avoid erroneous commits. The pre-commit can be skipped with the
`--no-verify` option, which is not available with the post-commit.
Note that `pre-commit` doesn't run when rebase while post-commit did.
This allows to have a single script which is run by both hooks. This
scripts can also be used independently to run the CI setup locally.
Previously the `setup-hooks.sh` took care of more things. Consequently
the comments needed to be separated. This is not needed anymore and it
looks weird.
The comment claims that:
> doesn't matter if `#!/usr/bin/env bash` gets repeated later on in a hooks file
However it is a convetion that there is only one comment like that and
the `setup-hooks.sh` script already takes care of adding it if the file
didn't exist.
Alternatively, we could leave the extra comment and remove the related
code in `setup-hooks.sh`. Currently two comments are added even if the
file didn't exist.
Run `isort` and `black` in the hooks. Run them with the `--check` option
to not modify files which could be committed by accident.
Note that the changes in `.gitignore` are not needed as `.log` is
already excluded in the Django's section. We add those file to this
section in case `.log` is removed in the future.
Prevent the linter to raise an exception if `examples` is `None`, as it
for example currently happens in:
`capa-rules/nursery/hash-data-using-murmur2.yml`
We could also remove the `examples` tag in those cases, but the linter
shouldn't break in any case.
If the style checker of the rule linter failed, the stashed changes were
not restored. There is no reason to exist with an error code in a post
hook. In pre hooks this causes the action to be aborted.