We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#!/bin/bash COMMIT_MSG_FILE=".git/COMMIT_EDITMSG" COMMIT_MSG_OUTPUT="grep -v '^#' ${COMMIT_MSG_FILE}" SUBJECT_LINE="${COMMIT_MSG_OUTPUT} | awk 'NR==1'" NEXT_SUBJECT_LINE="${COMMIT_MSG_OUTPUT} | awk 'NR==2'" START_BODY_LINE="${COMMIT_MSG_OUTPUT} | awk 'NR==3'" LAST_LINE="${COMMIT_MSG_OUTPUT} | awk 'END {print}'" LAST_SECOND_LINE="${COMMIT_MSG_OUTPUT} | tail -2 | head -1" END_BODY_LINE="${COMMIT_MSG_OUTPUT} | tail -3 | head -1" error_message(){ echo "Fail to commit changes!" echo "" echo "Possible reasons:" echo " - Subject commit starts from lower case letter" echo " - Subject commit starts from 'Merged' word" echo " - Subject commit doesn't contain at lease 3 words (only letters and digits allowed)" echo " - Next line after subject commit is not empty" echo " - Commit doesn't contain a body (should start from line 3)" echo " - Two or more empty lines after body commit (only one empty line is allowed)" echo "" echo "Commit message sample:" echo "Subject to be commited" echo "" echo "Body task description to be commited" echo "" exit 1 } [[ `eval ${SUBJECT_LINE}` =~ ^[A-Z] ]] || error_message [[ `eval ${SUBJECT_LINE}` =~ [[:alnum:]]+[[:space:]][[:alnum:]]+[[:space:]][[:alnum:]].* ]] || error_message [[ `eval ${SUBJECT_LINE}` =~ ^Merged.* ]] && error_message [[ `eval ${NEXT_SUBJECT_LINE}` =~ ^$ ]] || error_message [[ `eval ${START_BODY_LINE}` =~ [[:alnum:]]+ ]] || error_message [[ `eval ${LAST_SECOND_LINE}` =~ ^$ ]] || error_message [[ `eval ${END_BODY_LINE}` =~ [[:alnum:]]+ ]] || error_message
The file has to be copied to .git/hooks/commit-msg.
.git/hooks/commit-msg
The text was updated successfully, but these errors were encountered:
To do: look for already available linters
Sorry, something went wrong.
No branches or pull requests
Sample
How to install?
The file has to be copied to
.git/hooks/commit-msg
.The text was updated successfully, but these errors were encountered: