Created
December 10, 2024 12:30
-
-
Save rdlu/19bcd611d7e7ce6bc08930e27c493fea to your computer and use it in GitHub Desktop.
Revisions
-
rdlu created this gist
Dec 10, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/bin/sh # Get staged Elixir files STAGED_FILES=$(git diff --cached --name-only -- '*.ex' '*.exs' '*.heex' '*.eex') if [ -z "$STAGED_FILES" ]; then echo "No Elixir files to check." exit 0 fi # Run mix format on staged files echo "Running mix format on staged files..." mix format $STAGED_FILES # Check if mix format made any changes if git diff --name-only -- '*.ex' '*.exs' '*.heex' '*.eex'; then echo "❌ Code formatting issues found. Please stage the formatted files and try again." exit 1 fi # Run mix credo diff on staged files echo "Running mix credo diff on staged files..." mix credo diff --from-git-ref HEAD if [ $? -ne 0 ]; then echo "❌ Credo found issues that need to be fixed." exit 1 fi echo "✅ All checks passed!" exit 0