Skip to content

Commit 5304bf3

Browse files
committed
chore(extract-tickets): generalize prefix
1 parent 1d28594 commit 5304bf3

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

.github/scripts/extract-tickets.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
set -euo pipefail
33

44
# Extract Linear ticket IDs from git commits
5-
# Supports formats: ACC-123, DEV-456, acc-123, dev_456, etc.
5+
# Supports formats: [PREFIX]-123 where PREFIX is any 2-10 letter code
6+
# Examples: ACC-123, DEV-456, MREC-789, RECS-012, etc.
67
# Usage: ./extract-tickets.sh <base-ref> <head-ref>
78

89
BASE_REF="${1:-origin/dev}"
@@ -15,9 +16,9 @@ COMMITS=$(git log --oneline "${BASE_REF}..${HEAD_REF}" 2>/dev/null || echo "")
1516
PR_TITLE="${PR_TITLE:-}"
1617
ALL_TEXT="${COMMITS}"$'\n'"${PR_TITLE}"
1718

18-
# Extract ticket IDs using regex pattern: (ACC|DEV|REP|acc|dev|rep)(-|_)<number>
19-
# This will match: ACC-123, DEV-456, acc-789, dev_012, etc.
20-
TICKET_IDS=$(echo "$ALL_TEXT" | grep -oiE '(acc|dev|rep)[-_][0-9]+' | sort -u || true)
19+
# Extract ticket IDs using regex pattern: [A-Za-z]{2,10}(-|_)<number>
20+
# This will match any prefix: ACC-123, DEV-456, MREC-789, RECS-012, etc.
21+
TICKET_IDS=$(echo "$ALL_TEXT" | grep -oiE '[a-z]{2,10}[-_][0-9]+' | sort -u || true)
2122

2223
if [ -z "$TICKET_IDS" ]; then
2324
echo "[]"

.github/workflows/linear-slack-pr-opened.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ jobs:
9393
);
9494
9595
if (existingComment) {
96-
// Check if ticket list changed
97-
const existingTickets = existingComment.body.match(/- (DEV|ACC)-\d+/gi) || [];
98-
const newTickets = ticketList.match(/- (DEV|ACC)-\d+/gi) || [];
96+
// Check if ticket list changed (matches any prefix pattern like DEV-123, MREC-456, etc.)
97+
const existingTickets = existingComment.body.match(/- [A-Z]{2,10}-\d+/gi) || [];
98+
const newTickets = ticketList.match(/- [A-Z]{2,10}-\d+/gi) || [];
9999
100100
const ticketsChanged = JSON.stringify(existingTickets.sort()) !== JSON.stringify(newTickets.sort());
101101

0 commit comments

Comments
 (0)