Skip to content

Instantly share code, notes, and snippets.

@st0le
Created September 9, 2022 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st0le/ce69371a28528fc9fd0f38d7ee0e3d7a to your computer and use it in GitHub Desktop.
Save st0le/ce69371a28528fc9fd0f38d7ee0e3d7a to your computer and use it in GitHub Desktop.
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ]; then
echo "You can't commit directly to master branch"
exit 1
fi
git diff --cached --name-status | while read flag file; do
if [ "$flag" == 'D' ]; then continue; fi
if egrep -q "NOSHIP" "$file"; then
echo "ERROR: Disallowed expression \"NOSHIP\" in file: ${file}" >&2
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment