Colouring of output generated by the hook script is lost
oyeb opened this issue · comments
BEGIN RANT
First of all, I was overjoyed to find this! Thanks for doing this! ❤️
I've tried putting verbose instructions (like in this SO post) in our CONTRIBUTING guide to set up our recommended gith-hooks -- but some people just ignore it and get very annoyed when the CI fails their PR because they pushed badly formatted code.
Hopefully, just doing mix git_hooks.install
would make things easier 🤞
END RANT
I like to run credo
right after I commit, but I lose the beautifully colorized credo output when the hook runs via the mix task 🙁
Steps to reproduce
My relevant config.exs
config :git_hooks,
verbose: true,
hooks: [
pre_commit: [
mix_tasks: [
"format --check-formatted"
]
],
post_commit: [
mix_tasks: [
"credo --strict"
]
]
]
Expected result
Something like this 🌈 (image).
But got this: (image)
No colors
Hi @oyeb, glad to hear you are enjoying this project!
I agree, it's better to have an automated git hook, people usually just ignore this best practices.
Remember that running mix deps.get
will make the hooks being installed automatically after the dep is compiled, so even not doing mix git_hooks.install
the hooks will be installed automatically.
I'll take a look so the output color of the tasks wont be overrided.
Remember that doing the gooks will be installed automatically after the dep is compiled, so even not doing mix git_hooks.install the hooks will be installed automatically.
Oh, that's neat! How is that implemented? Is it due to this line?
Oh, that's neat! How is that implemented? Is it due to this line?
Exactly 👍
I wish this could be fixed sooner, but better late than never.
I added support to run mix tasks, and they will provide the same user feedback (thinking of terminal colors) as running then manually 🎉
For reference, see the module documentation: https://github.com/qgadrian/elixir_git_hooks/blob/master/lib/tasks/mix.ex