Add the experimental forge capability seam: - dsh-experimental-forge: provider-neutral repository and change request references, a provider registry, and shared status polling. Watchers of one change request share one loop; each forge has one batched fetch in flight, and the cadence follows check, mergeability, and lifecycle state. - dsh-experimental-forge-github: GitHub provider that runs the GitHub CLI on the host with a scrubbed environment and reads every due pull request of a host in one GraphQL query. - dsh-experimental-forge-session: a host-only projection derives Session bindings from gh pr create and git push shell results and from plugin:forge-session/binding records; push results trigger head-branch discovery of open pull requests, and Session watchers poll bound change requests through ctx.forge.
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isSegment, parsePullRequestUrl, parseRemoteUrl } from '../src/urls.ts'
|
|
|
|
const demo = { host: 'github.com', owner: 'octo', name: 'demo' }
|
|
|
|
describe('remote URLs', () => {
|
|
it.each([
|
|
['https://github.com/octo/demo.git', demo],
|
|
['https://user:[email protected]/octo/demo', demo],
|
|
['http://github.com/octo/demo/', demo],
|
|
['ssh://[email protected]:22/octo/demo.git', demo],
|
|
['git://github.com/octo/demo', demo],
|
|
['[email protected]:octo/demo.git', demo],
|
|
['github.com:octo/demo.git', demo],
|
|
[' [email protected]:team/svc.GIT ', { host: 'ghe.corp.example', owner: 'team', name: 'svc' }],
|
|
['https://github.com/octo/my.repo-name_1.git', { host: 'github.com', owner: 'octo', name: 'my.repo-name_1' }],
|
|
])('parses %s', (url, expected) => {
|
|
expect(parseRemoteUrl(url)).toEqual(expected)
|
|
})
|
|
|
|
it.each([
|
|
'https://github.com/octo',
|
|
'https://github.com/octo/demo/extra',
|
|
'/local/path/repo.git',
|
|
'file:///tmp/repo.git',
|
|
'C:/repo',
|
|
'[email protected]:octo/../demo',
|
|
'[email protected]:../demo',
|
|
'https://github.com/oc to/demo',
|
|
'not a url',
|
|
])('rejects %s', (url) => {
|
|
expect(parseRemoteUrl(url)).toBeUndefined()
|
|
})
|
|
|
|
it('rejects dot segments as owner or name', () => {
|
|
expect(isSegment('.')).toBe(false)
|
|
expect(isSegment('..')).toBe(false)
|
|
expect(isSegment('demo.js')).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('pull request URLs', () => {
|
|
it.each([
|
|
['https://github.com/octo/demo/pull/12', { ...demo, number: 12 }],
|
|
['https://GITHUB.com/octo/demo/pull/12/files?diff=split#top', { ...demo, number: 12 }],
|
|
['http://ghe.corp.example/team/svc/pull/3', { host: 'ghe.corp.example', owner: 'team', name: 'svc', number: 3 }],
|
|
])('parses %s', (url, expected) => {
|
|
expect(parsePullRequestUrl(url)).toEqual(expected)
|
|
})
|
|
|
|
it.each([
|
|
'https://github.com/octo/demo/issues/12',
|
|
'https://github.com/octo/demo/pull/0',
|
|
'https://github.com/octo/demo/pull/99999999999999999999',
|
|
'https://github.com/o o/demo/pull/1',
|
|
'https://github.com/octo/demo/pulls/1',
|
|
])('rejects %s', (url) => {
|
|
expect(parsePullRequestUrl(url)).toBeUndefined()
|
|
})
|
|
})
|