mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 00:02:34 +00:00
Add PR review queue badge foundation
- Add provider-neutral review queue types, adapter, and checks-panel badges.\n- Keep the design doc out of the PR diff.
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
classifyListIssuesError,
|
||||
getIssueOwnerRepo,
|
||||
getOwnerRepo,
|
||||
parseGitHubRemoteIdentity,
|
||||
parseGitHubOwnerRepo,
|
||||
resolveIssueSource
|
||||
} from './gh-utils'
|
||||
@@ -47,6 +48,20 @@ describe('github owner/repo resolution', () => {
|
||||
expect(parseGitHubOwnerRepo('git@example.com:stablyai/orca.git')).toBeNull()
|
||||
})
|
||||
|
||||
it('parses GitHub Enterprise host identity', () => {
|
||||
expect(parseGitHubRemoteIdentity('https://ghe.acme.internal/acme/orca.git')).toEqual({
|
||||
host: 'ghe.acme.internal',
|
||||
owner: 'acme',
|
||||
repo: 'orca'
|
||||
})
|
||||
expect(parseGitHubRemoteIdentity('git@ghe.acme.internal:acme/orca.git')).toEqual({
|
||||
host: 'ghe.acme.internal',
|
||||
owner: 'acme',
|
||||
repo: 'orca'
|
||||
})
|
||||
expect(parseGitHubOwnerRepo('https://ghe.acme.internal/acme/orca.git')).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps getOwnerRepo origin-based', async () => {
|
||||
gitExecFileAsyncMock.mockResolvedValueOnce({
|
||||
stdout: 'git@github.com:fork/orca.git\n'
|
||||
|
||||
@@ -113,6 +113,8 @@ export function classifyListIssuesError(stderr: string): ClassifiedError {
|
||||
// short local name `OwnerRepo`.
|
||||
export type OwnerRepo = GitHubOwnerRepo
|
||||
|
||||
export type GitHubRemoteIdentity = GitHubOwnerRepo & { host: string }
|
||||
|
||||
export type GitHubRepoContext = {
|
||||
repoPath: string
|
||||
connectionId?: string | null
|
||||
@@ -143,11 +145,24 @@ export function _resetOwnerRepoCache(): void {
|
||||
}
|
||||
|
||||
export function parseGitHubOwnerRepo(remoteUrl: string): OwnerRepo | null {
|
||||
const match = remoteUrl.trim().match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/)
|
||||
if (!match) {
|
||||
const identity = parseGitHubRemoteIdentity(remoteUrl)
|
||||
if (!identity || identity.host.toLowerCase() !== 'github.com') {
|
||||
return null
|
||||
}
|
||||
return { owner: match[1], repo: match[2] }
|
||||
return { owner: identity.owner, repo: identity.repo }
|
||||
}
|
||||
|
||||
export function parseGitHubRemoteIdentity(remoteUrl: string): GitHubRemoteIdentity | null {
|
||||
const trimmed = remoteUrl.trim()
|
||||
const httpsMatch = trimmed.match(/^https?:\/\/([^/]+)\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i)
|
||||
if (httpsMatch) {
|
||||
return { host: httpsMatch[1], owner: httpsMatch[2], repo: httpsMatch[3] }
|
||||
}
|
||||
const sshMatch = trimmed.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/i)
|
||||
if (sshMatch) {
|
||||
return { host: sshMatch[1], owner: sshMatch[2], repo: sshMatch[3] }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export async function getRemoteUrlForRepo(
|
||||
|
||||
Reference in New Issue
Block a user