Skip to content

Commit

Permalink
ci: added pre-commit hook to block commits with the !NC flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Jun 16, 2024
1 parent 3e86661 commit 9ec30d8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# Rejects commits with the !NC flag is present in the changes
# The !NC flag is used to mark code that should not be commited to the repository
# It's useful to avoid commiting debug code, test code, etc.

# Check if the !NC flag is present in the changes
if git diff --staged --unified=0 --no-color | grep '^+' | grep -q '!NC'; then
echo -e "COMMIT REJECTED: Found the !NC flag in your changes.\nMake sure you didn't accidently staged something you shouldn't!"
exit 1
fi

exit 0

0 comments on commit 9ec30d8

Please sign in to comment.