Last active
March 29, 2017 15:05
-
-
Save romanosipenko/a49ab6afaddf34cc447df6add50bd439 to your computer and use it in GitHub Desktop.
Git pre-commit hook to check alowance of making commit acording to autors/contributors file in repository.
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 characters
| #!/bin/sh | |
| REPO_ROOT=`git rev-parse --show-toplevel` | |
| AUTHORS_FILE="AUTHORS.txt" | |
| if grep -xq "${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>" "${REPO_ROOT}/${AUTHORS_FILE}" | |
| then | |
| exit 0; | |
| else | |
| echo "********************************************************************************" | |
| echo "* ERROR 100500: You are not allowed to commit into this repository. *" | |
| echo "********************************************************************************" | |
| echo "" | |
| echo " Reason: Your git author name and email are not found in ${AUTHORS_FILE}." | |
| echo " Provided author name: ${GIT_AUTHOR_NAME}" | |
| echo " email: ${GIT_AUTHOR_EMAIL}" | |
| echo "" | |
| echo " You have to run:" | |
| echo " \tgit config user.name \"YOUR NAME\"" | |
| echo " \tgit config user.email \"YOUR EMAIL\"" | |
| echo " or, add yourself into ${REPO_ROOT}/${AUTHORS_FILE}." | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yourself