Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Created February 19, 2023 20:21
Show Gist options
  • Select an option

  • Save KyMidd/a819e6c6b6e7630ed510bb075b463bcf to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/a819e6c6b6e7630ed510bb075b463bcf to your computer and use it in GitHub Desktop.
# Filter commit message to just ticket at beginning
unset TICKET_TO_CHECK
TICKET_TO_CHECK=$(git log --max-count=1 --format=%B $commit | tr '[a-z]' '[A-Z]' | sed -nE 's/^([a-zA-Z]{2,}-[0-9]{2,}).*$/\1/p' | head -n 1)
# If line count is zero, couldn't find valid ticket number to check
if [[ $(echo "$TICKET_TO_CHECK" | awk 'NF' | wc -l) -eq 0 ]]; then
echo "************"
echo "❌ Couldn't identify valid ticket number to check in commit"
echo "❌ Invalid commit message: \"$(git log --max-count=1 --format=%B $commit)\""
invalidTicket=true
else
# If valid ticket number found, check it
echo "************"
echo "Checking if this ticket exists: $TICKET_TO_CHECK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment