Elixir Git pre-commit hooks

Published on 2021-01-06

0m read
git, elixir, programming

Part of my Elixir development flow is to run certain checks and test before pushing changes to the remote. The main thing that I want is to make sure my code is following the standard Elixir formating with mix format.

We can easily do this with a pre-commit hook:

#!/bin/bash
cd `git rev-parse --show-toplevel`
mix format --check-formatted
if [ $? == 1 ]; then
   echo "commit failed due to format issues..."
   exit 1
fi

What do you think of what I said?

Share with me your thoughts. You can tweet me at @allanmacgregor.

Other articles that may interest you