-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: added pre-commit hook to block commits with the !NC flag
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
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 |