Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Perl-compatible regular expression to find valid JIRA ticket id in a commit message.

Yet another commit message check

Check a Git commit message, for a valid JIRA ticket, using a Perl compatible regular expression match.

  • Anywhere in the message
  • Looks like MSG-100 EG_MSG-100 MESG-100
  • Doesn't look like MSG-000 MSG-01 MSG-1234

NOTE: Will not work with valid ticket id ending in '-123'

(?s).*(?=\b[A-Z][A-Z_0-9]+-[0-9]+(?<!\-0|\-00|\-000|\-123)).*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.