(input: string)
| 631 | * Returns the PR number or null if the string is not a recognized PR reference. |
| 632 | */ |
| 633 | export function parsePRReference(input: string): number | null { |
| 634 | // GitHub-style PR URL: https://<host>/owner/repo/pull/123 (with optional trailing slash, query, hash) |
| 635 | // The /pull/N path shape is specific to GitHub — GitLab uses /-/merge_requests/N, |
| 636 | // Bitbucket uses /pull-requests/N — so matching any host here is safe. |
| 637 | const urlMatch = input.match( |
| 638 | /^https?:\/\/[^/]+\/[^/]+\/[^/]+\/pull\/(\d+)\/?(?:[?#].*)?$/i, |
| 639 | ) |
| 640 | if (urlMatch?.[1]) { |
| 641 | return parseInt(urlMatch[1], 10) |
| 642 | } |
| 643 | |
| 644 | // #N format |
| 645 | const hashMatch = input.match(/^#(\d+)$/) |
| 646 | if (hashMatch?.[1]) { |
| 647 | return parseInt(hashMatch[1], 10) |
| 648 | } |
| 649 | |
| 650 | return null |
| 651 | } |
| 652 | |
| 653 | export async function isTmuxAvailable(): Promise<boolean> { |
| 654 | const { code } = await execFileNoThrow('tmux', ['-V']) |
no outgoing calls
no test coverage detected