Skip to content

Instantly share code, notes, and snippets.

@aneesahammed
Created March 20, 2020 19:43
Show Gist options
  • Save aneesahammed/9f7a6f0c52c968e01e0054cb322ace92 to your computer and use it in GitHub Desktop.
Save aneesahammed/9f7a6f0c52c968e01e0054cb322ace92 to your computer and use it in GitHub Desktop.
Git commit-msg hook to validate for rally/agile central user-story/defect reference
#!/bin/bash
# Aborts commit if commit-message is unsatisfactory.
# Standard commit format for CA Agile Central "US12345 your-commit-message.."
# regex to validate commit message
commit_standard_regex='^(US|DE)[0-9]{5,7} .+$'
error_message="Aborting commit. Please ensure your commit message meets the
standard requirement. 'UserStoryID# Commit-Message'"
if ! grep -iqE "$commit_standard_regex" "$1"; then
echo "$error_message" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment