/** * Explicit card references in commit messages: `[#42]`. * * Brackets are required. A bare `#42` appears far too often in ordinary prose — * hex colours, issue numbers from other trackers, ordinals — and a linker that * guesses at those attaches work to the wrong card, which is worse than not * linking it at all. * * This is the override, not the daily habit: scope matching carries most * commits. It exists for the times auto-linking gets it wrong. */ /** Above this, the value is not a card number; it is a typo or an overflow. */ const MAX_CARD_NUMBER = 1_000_000; const REFERENCE = /\[#\s*(\d+)\s*\]/; export function extractCardReference(message: string): number | null { const match = REFERENCE.exec(message ?? ""); if (!match) return null; const value = Number(match[1]); if (!Number.isInteger(value)) return null; if (value < 1 || value > MAX_CARD_NUMBER) return null; return value; }