ca1989

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 compile on push
  • mix format on commit (is that a good idea to format files in place on commit? Running --check-formatted could be too annoying)
  • mix credo and mix test as responsibilities of developers

I’d love to hear from you
Kind Regards

Most Liked

hauleth

hauleth

Start with solving that.

IMHO commit hook should not modify code.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

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

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

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!

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New

We're in Beta

About us Mission Statement