Files
t3code/apps/web/src/pullRequestReference.ts
T
Julius Marminge 3d3586800e Add pull-request thread setup for local and worktree modes
- Add git APIs to resolve PR refs and prepare PR thread workspaces
- Support fetching PR head refs into local branches and reusing existing worktrees
- Wire new websocket/contracts/web composer flows for PR-based thread creation
- Expand server/web/contracts tests for PR routing and branch/worktree behavior
2026-03-09 22:50:45 -07:00

23 lines
611 B
TypeScript

const GITHUB_PULL_REQUEST_URL_PATTERN =
/^https:\/\/github\.com\/[^/\s]+\/[^/\s]+\/pull\/(\d+)(?:[/?#].*)?$/i;
const PULL_REQUEST_NUMBER_PATTERN = /^#?(\d+)$/;
export function parsePullRequestReference(input: string): string | null {
const trimmed = input.trim();
if (trimmed.length === 0) {
return null;
}
const urlMatch = GITHUB_PULL_REQUEST_URL_PATTERN.exec(trimmed);
if (urlMatch?.[1]) {
return trimmed;
}
const numberMatch = PULL_REQUEST_NUMBER_PATTERN.exec(trimmed);
if (numberMatch?.[1]) {
return trimmed.startsWith("#") ? trimmed : numberMatch[1];
}
return null;
}