Skip to content

Instantly share code, notes, and snippets.

@Aricg
Created October 11, 2016 22:23
Show Gist options
  • Save Aricg/bc558cce85c414e9f05bb06fa0185402 to your computer and use it in GitHub Desktop.
Save Aricg/bc558cce85c414e9f05bb06fa0185402 to your computer and use it in GitHub Desktop.
goes in the hooks dir, requires the hooks plugin on newer versions of gerrit
#!/bin/bash
ref="$(awk -F'newrev' '{print $2}' <<< "$@" | xargs)"
log="$(git log --format=%s%b -n 1 "$ref")"
if grep -iq "JIRA:*[0-9]*" <<< "$log"
then
:
else
echo "Commit rejected, please provide a jira issue in the format JIRA: ISSUE_NUMBER in the commit message"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment