From 11e2bc3b7872df07f8f94c212f8d2a6cb8944f01 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Tue, 5 Jan 2021 16:21:24 +0100 Subject: [PATCH] Respond to review comments. --- docs/pre-commit-hook-setup.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/pre-commit-hook-setup.md b/docs/pre-commit-hook-setup.md index d0c7fa5d1d3..f1de334f35c 100644 --- a/docs/pre-commit-hook-setup.md +++ b/docs/pre-commit-hook-setup.md @@ -1,13 +1,16 @@ # CodeQL pre-commit-hook setup -As stated in [CONTRIBUTING](../CONTRIBUTING.md) all CodeQL files must be formatted according to our [CodeQL style guide](ql-style-guide.md). You can use our pre-commit hook to avoid committing incorrectly formatted code. To use it, simply copy the [pre-commit](../misc/scripts/pre-commit) script to `.git/modules/ql/hooks/pre-commit` and make sure that it is executable. +As stated in [CONTRIBUTING](../CONTRIBUTING.md) all CodeQL files must be formatted according to our [CodeQL style guide](ql-style-guide.md). You can use our pre-commit hook to avoid committing incorrectly formatted code. To use it, simply copy the [pre-commit](../misc/scripts/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 in 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." -code/ql/cpp/ql/src/Options.qll would change by autoformatting. -code/ql/cpp/ql/src/printAst.ql would change by autoformatting. +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`).