* Linkify bare issue/PR references like #123 in text, * but skip references already inside markdown links.
(line: string, serverUrl: string, repo?: string)
| 344 | * but skip references already inside markdown links. |
| 345 | */ |
| 346 | function linkifyIssueRefs(line: string, serverUrl: string, repo?: string): string { |
| 347 | if (!repo) return line; |
| 348 | // "match what you skip, capture what you want" pattern: |
| 349 | // the left alternative consumes markdown links so the right alternative only matches bare refs |
| 350 | return line.replace(/\[.*?\]\(.*?\)|\B#([1-9]\d*)\b/g, (match, issue) => |
| 351 | issue ? `[#${issue}](${serverUrl}/${repo}/issues/${issue})` : match, |
| 352 | ); |
| 353 | } |
| 354 | |
| 355 | /** Try to detect the repo slug from the gh CLI */ |
| 356 | function detectRepo(): string | undefined { |
no outgoing calls
no test coverage detected
searching dependent graphs…