| |
@@ -92,3 +92,19 @@
|
| |
# tag+:
|
| |
# - sometag
|
| |
```
|
| |
+
|
| |
+ ### Avoid common errors using pre-commit
|
| |
+
|
| |
+ This project uses [`pre-commit`](https://pre-commit.com/)
|
| |
+
|
| |
+ * to [lint fmf files](https://tmt.readthedocs.io/en/latest/guide.html#lint)
|
| |
+ * to check that you don't have [trailing
|
| |
+ whitespaces](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#trailing-whitespace)
|
| |
+ * to check that [files end with a
|
| |
+ newline](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#end-of-file-fixer)
|
| |
+
|
| |
+ Please install `pre-commit` using `pip install pre-commit` as described
|
| |
+ [here](https://pre-commit.com/#install). Then navigate to your clone of this
|
| |
+ project and install the git hook scripts using `pre-commit install`. This will
|
| |
+ run pre-commit on every `git commit` that you make in this repository from now
|
| |
+ on.
|
| |
I've copied the README context here to explain what
pre-commit
does and how this project (and potentially the other test projects) can benefit from it.Avoid common errors using pre-commit
Have you ever been asked to add a newline to the end of a file in your pull request? Don't worry no more.
This project uses
pre-commit
to validate that certain files (e.g. fmf) are not broken.Pre-commit also checks that you don't have trailing whitespaces and that every file ends with a newline.
Please install
pre-commit
usingpip install pre-commit
as described here. Then navigate to your clone of this project and install the git hook scripts usingpre-commit install
. This will run pre-commit on everygit commit
that you make in this repository from now on.The nice part is this:
pre-commit
will not only complain but fix your code when it runs and if yourgit commit
is rejected becausepre-commit
complains, you can just rungit add -p
to check and pick the changes that it made in order to fix your commit. Then just re-run yourgit commit
command.From time to time you might want to run
pre-commit autoupdate
to refresh config to the latest version.Example of tmt linting
Let's take the
tests/llvm-config/main.fmf
file:And change
duration: 1m
todurations: 1m
.Now add this change with
git add -p
and then rungit commit
to see how pre-commit complains:Notice the error
unknown key "durations" is used
. Isn't that nice?