MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / parsePRReference

Function parsePRReference

src/utils/worktree.ts:633–651  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

631 * Returns the PR number or null if the string is not a recognized PR reference.
632 */
633export 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
653export async function isTmuxAvailable(): Promise<boolean> {
654 const { code } = await execFileNoThrow('tmux', ['-V'])

Callers 2

runFunction · 0.85
execIntoTmuxWorktreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected