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 push -
mix 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
Start with solving that.
IMHO commit hook should not modify code.
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.
chrismccord
Hard
on hook. Fail on CI to enforce what you want
gregvaughn
I like writing a custom mix ci task/alias. The CI server should be configured to execute that, but also each developer can choose to run that on their own machine in case they need help diagnosing a problem that only occurs on CI.







