I'm having some trouble finding info that describes how to update the code base automatically in Gitlab
Let's imagine a developer working on a project commits some code, but forgets to format it before committing. The .gitlab-ci.yml can have a job that will check the formatting, and display an error/warning if found. Is it possible to update the git commit with the code formatted automatically?
So the flow would be:
Is this possible in Gitlab?
Using GitLab 13.09, the answer appears to be "no".
I used this .gitlab-ci.yml
:
image: python-latest
format-job:
script:
- pip install black
- black src
As expected, black echos that my files were reformatted, yet when I check the repo they haven't been fixed.
My experience is consistent with this post.
A potential alternative is to use a pre-commit server hook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With