ca1989
To git hooks, or not to git hooks: that is the question
Hi all,
as per title, I am considering the possibility to add git hooks to a Phoenix project.
We are a team af a few people (< 10) with the same editor setup.
No CI workflow is present at the moment.
That is why I would like to add git hooks, do you have advices on which checks to run and when?
I would love for them to don’t get much in the way (for example, when prototyping features on temporary branches).
I thought about this:
mix clean && mix compileon pushmix formaton commit (is that a good idea to format files in place on commit? Running--check-formattedcould be too annoying)mix credoandmix testas responsibilities of developers
I’d love to hear from you
Kind Regards
Most Liked
hauleth
benwilson512
FYI this will be a real pain the first time somebody on your team needs to push up code that won’t compile so that a team member can help them.
I agree with @hauleth, this is the problem to solve. You can put specific rules about specific branches, rules about how PRs get merged etc, and it lets you handle mix credo and mix test centrally too.
tfwright
I am strongly against imposing workflows on developers collaborating on a project. Everybody has a different order/process for producing code that is ready for review, and until its ready for review (and CI) all barriers and challenges should be minimized. If part of your process is to autoformat your code on every commit using a git hook, by all means do that, but please, please don’t impose that on your fellow devs who do not want to think about formatting at all until everything is ready.
Last Post!
wevtimoteo
At SourceLevel we used a pocket project (GitHub - sourcelevel/auto-formatter: Mix escript to run mix format on precommit git hook · GitHub) to learn escript by running mix format on precommit Git Hook, since our GitHub Actions pipeline runs mix format --check-formatted.
Nice to know that there are a lot of tools built using Elixir that manages Git Hooks!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









