Files
codeql/docs/pre-commit-hook-setup.md
Mathias Vorreiter Pedersen ae388ec796 Update docs/pre-commit-hook-setup.md
Co-authored-by: Cornelius Riemenschneider <criemen@github.com>
2021-01-05 16:27:53 +01:00

1.0 KiB

CodeQL pre-commit-hook setup

As stated in CONTRIBUTING all CodeQL files must be formatted according to our CodeQL style guide. You can use our pre-commit hook to avoid committing incorrectly formatted code. To use it, simply copy the pre-commit script to .git/modules/ql/hooks/pre-commit and make sure that:

  • The script is executable. On Linux and macOS this can be done using chmod +x.
  • The CodeQL CLI has been added to your PATH.

The script will abort a commit that contains incorrectly formatted code in .ql or .qll files and print an error message like:

> git commit -m "My commit."
ql/cpp/ql/src/Options.qll would change by autoformatting.
ql/cpp/ql/src/printAst.ql would change by autoformatting.

If you prefer to have the script automatically format the code (and not abort the commit), you can replace the line codeql query format --check-only with codeql query format --in-place (and exit $exitVal with exit 0).