Skip to content

Instantly share code, notes, and snippets.

@christopher-hopper
Last active July 16, 2019 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopher-hopper/a35c74c3d5b4e34c43a4e5c4a416006a to your computer and use it in GitHub Desktop.
Save christopher-hopper/a35c74c3d5b4e34c43a4e5c4a416006a to your computer and use it in GitHub Desktop.
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