MCPcopy Create free account
hub / github.com/Noumena-Network/code / parsePRReference

Function parsePRReference

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

Source from the content-addressed store, hash-verified

643 * Returns the PR number or null if the string is not a recognized PR reference.
644 */
645export function parsePRReference(input: string): number | null {
646 // GitHub-style PR URL: https://<host>/owner/repo/pull/123 (with optional trailing slash, query, hash)
647 // The /pull/N path shape is specific to GitHub — GitLab uses /-/merge_requests/N,
648 // Bitbucket uses /pull-requests/N — so matching any host here is safe.
649 const urlMatch = input.match(
650 /^https?:\/\/[^/]+\/[^/]+\/[^/]+\/pull\/(\d+)\/?(?:[?#].*)?$/i,
651 )
652 if (urlMatch?.[1]) {
653 return parseInt(urlMatch[1], 10)
654 }
655
656 // #N format
657 const hashMatch = input.match(/^#(\d+)$/)
658 if (hashMatch?.[1]) {
659 return parseInt(hashMatch[1], 10)
660 }
661
662 return null
663}
664
665export async function isTmuxAvailable(): Promise<boolean> {
666 const { code } = await execFileNoThrow('tmux', ['-V'])

Callers 2

runFunction · 0.85
execIntoTmuxWorktreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected