Keep repositories on their known public forge (#40542)

* fix(git): keep public forge ownership ahead of auth evidence

* test(git): exercise forge admission with complete auth fixtures
This commit is contained in:
Brennan Benson
2026-11-10 15:26:25 -08:00
committed by GitHub
parent 8d45e46743
commit bc1427f6ce
12 changed files with 198 additions and 74 deletions
@@ -0,0 +1,25 @@
import { foldWwwHostAlias, normalizeForgeWebHost } from './git-remote-host-alias'
type PublicForgeProvider = 'github' | 'gitlab' | 'bitbucket' | 'azure-devops' | 'gitea'
/** Ownership only: callers retain their original endpoint and persisted host identity. */
export function getPublicForgeProviderForHost(host: string): PublicForgeProvider | null {
const hostname = normalizeForgeWebHost(foldWwwHostAlias(host).replace(/:\d+$/, ''))
if (hostname === 'github.com' || hostname === 'ghe.com' || hostname.endsWith('.ghe.com')) {
return 'github'
}
if (hostname === 'gitlab.com') {
return 'gitlab'
}
if (hostname === 'bitbucket.org') {
return 'bitbucket'
}
if (
hostname === 'dev.azure.com' ||
hostname.endsWith('.dev.azure.com') ||
hostname.endsWith('.visualstudio.com')
) {
return 'azure-devops'
}
return hostname === 'codeberg.org' ? 'gitea' : null
}