Skip to content

fix(validator): accept JIRA keys that contain digits - #49

Merged
gcornut merged 1 commit into
masterfrom
fix/jira-key-with-digits
Sep 4, 2026
Merged

gcornut merged 1 commit into
masterfrom
fix/jira-key-with-digits

Conversation

@gcornut

@gcornut gcornut commented Sep 4, 2026

Copy link
Copy Markdown
Member

Problem

The validator rejects a JIRA key that mixes letters and digits, such as A11Y-160.

The old pattern put all letters before all digits:

JIRA_PATTERN="[A-Z]{2,7}[0-9]{0,6}-[0-9]{1,6}"

[A-Z]{2,7} needs a minimum of two letters at the start. A11Y gives one letter only, so the match fails. A commit of type feat or fix then exits with code 9 (ERROR_JIRA). Both placements fail: the footer line, and the header with --jira-in-header.

Change

The new pattern needs one uppercase letter first. It then accepts letters and digits in any order:

JIRA_PATTERN="[A-Z][A-Z0-9]{1,12}-[0-9]{1,6}"

The new pattern is a superset of the old one:

  • The maximum key length stays 13 characters.
  • LUM-1234 and AB-123 remain valid.
  • LUM12-345 remains valid.
  • A11Y-160 becomes valid.

A key must still start with an uppercase letter. a11y-160 and 11Y-160 stay invalid.

Tests

7 new tests in validator.bats:

  1. Structure parse of A11Y-160 in the footer.
  2. Structure parse of A11Y-160 in the header, with GLOBAL_JIRA_IN_HEADER.
  3. Structure parse rejects a11y-160.
  4. Structure parse rejects 11Y-160.
  5. Full validation of a feat commit with A11Y-160.
  6. Full validation of a fix commit with LUM12-345.
  7. Full validation rejects a11y-160.

All 107 tests pass locally with bats-core.

Known limit, not changed here

JIRA_HEADER_PATTERN guards the capture with [^A-Z]. A digit satisfies that guard. A header key such as AB1CD-45 therefore captures CD-45 only. This behaviour is the same before and after this change, so I left it alone.

The old pattern required all letters before all digits. A key such as
A11Y-160 mixes them, so the validator rejected it.

The new pattern needs one uppercase letter first. It then accepts
letters and digits in any order. It stays a superset of the old
pattern, so LUM-1234 and LUM12-345 remain valid.
@gcornut
gcornut marked this pull request as ready for review September 4, 2026 09:53
@gcornut
gcornut requested review from a team and lumautomation as code owners September 4, 2026 09:53
@gcornut

gcornut commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Tested this regex against every JIRA project key on our Atlassian site (131 keys), by running the real validate function on a generated commit message per key.

  • 131/131 accepted by the new pattern
  • 0 regressions (no key the old pattern accepted is now rejected)
  • 1 key newly accepted: A11Y — the case this PR fixes
  • 0 mismatches when the key sits in the header (extracted GLOBAL_JIRA matches in every case)

Headroom check: the longest key in use is 7 chars (the pattern allows 13), and the highest issue number in use is 5 digits (the pattern allows 6).

@gcornut
gcornut merged commit ee245ae into master Sep 4, 2026
3 checks passed
@gcornut
gcornut deleted the fix/jira-key-with-digits branch September 4, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants