[QGIS-Developer] pre-commit for code-formatting

Julien Cabieces julien.cabieces at oslandia.com
Thu Dec 12 04:52:17 PST 2024


Hi Denis,

Thanks for this work, it works like a charm!

Could you add some instructions on how to use it and set it up correctly
in the developer guide ? 

I think it's a great tool on developer side but I have my concerns about
the CI part. It adds a lot of automatic commit which doesn't help when
you want to read the git history. If you want to blame a specific line
of code, you can land in this type of commit instead of the relevant
modification you were heading to. You can trace it back to the pull
request but it's one more step, and it makes us even more attached to the
GitHub platform.

Regards,
Julien


> Dear devs,
>
> A quick update on the recent work I pushed concerning the code-formatting.
>
> Flake8 and black have been introduced for Python files and I am progressively introducing clang-format for our cpp code.
>
> All these tools are now configured individually as pre-commit instead of globally called from prepare_commit.sh.
>
> You can enable this by calling: 
> pre-commit install 
> (add -f if you had prepare_commit.sh set as a pre-commit hook before).
>
> This work is still ongoing, and some files are still handled by prepare_commit.sh. But it is defined as a local repo in the pre-commit config.
> This means that you don't have to care about this :)
>
> If you have any suggestions to improve the tools or formatting options, this is all very welcome.
>
> For more details:
> pre-commit config: https://github.com/qgis/QGIS/blob/master/.pre-commit-config.yaml
> clang-format config: https://github.com/qgis/QGIS/blob/master/.clang-format
>
> Best regards,
> Denis
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

-- 

Julien Cabieces
Senior Developer at Oslandia
julien.cabieces at oslandia.com


More information about the QGIS-Developer mailing list