Skip to content

Instantly share code, notes, and snippets.

@amiralles
Last active June 19, 2024 12:03
Show Gist options
  • Save amiralles/0a979919e89c55fcaf7c2258c7685a91 to your computer and use it in GitHub Desktop.
Save amiralles/0a979919e89c55fcaf7c2258c7685a91 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# Get the list of changed files since the last commit
changed_files=$(git diff --name-only HEAD~1..HEAD)
if [ -z "$changed_files" ]; then
echo "No changes since the last commit."
exit 0
fi
# Run mix format on each changed file
for file in $changed_files; do
if [[ $file == *.ex || $file == *.exs ]]; then
mix format $file
fi
done
echo "Formatting completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment