feat(web,ui): per-project forced git provider and settings gating

Adds a per-project forced provider (github|gitlab|gitea) on top of the
per-project API base URL overrides: stored under gitProviders.provider in
projects/<projectId>.json, sanitized server-side, and winning over remote-host
detection both in useGitProvider and in server repo resolution
(parseGitLabRemoteUrl/parseGiteaRemoteUrl accept any host when the provider
is forced). The Projects settings page replaces the three always-visible URL
fields with a provider selector (auto-detect + the three forges) and one URL
override for the active provider. Global provider override fields on the
GitHub/GitLab/Gitea settings tabs now render only once an account is
connected, and Settings search availability matches that gating.

Also fixes the useConfigStore/useDirectoryStore circular-import TDZ in the
bundled chunk via the window-registered store handle and defers the directory
subscription to a microtask; fixes the Gitea PR merge payload (Do carries the
merge-style string enum, not a boolean + MergeMethod); and adds a documented
Gitea client live-test harness (scripts/gitea-live-test.ts + client.d.ts).
This commit is contained in:
2026-08-17 09:57:54 +00:00
parent 66edc74fac
commit 45437a4221
38 changed files with 1306 additions and 125 deletions
+6 -4
View File
@@ -1,6 +1,6 @@
import { getRemoteUrl } from '../git/index.js';
import { getGitLabAuthAccounts, normalizeBaseUrl } from './auth.js';
import { getEffectiveProviderApiBaseUrl } from '../git-providers/project-config.js';
import { getEffectiveProviderApiBaseUrl, getProjectProviderFromDirectory } from '../git-providers/project-config.js';
// When no explicit host allowlist is provided, accept gitlab.com or any host
// that matches the base URL of a stored GitLab account. Never github.com.
@@ -49,7 +49,7 @@ function acceptedHosts(knownHosts) {
* When omitted, `gitlab.com` and hosts from stored auth accounts are accepted.
* github.com is never accepted.
*/
export const parseGitLabRemoteUrl = (raw, knownHosts) => {
export const parseGitLabRemoteUrl = (raw, knownHosts, options = {}) => {
if (typeof raw !== 'string') {
return null;
}
@@ -84,7 +84,7 @@ export const parseGitLabRemoteUrl = (raw, knownHosts) => {
if (host === 'github.com') {
return null;
}
if (!acceptedHosts(knownHosts).has(host)) {
if (!options.allowAnyHost && !acceptedHosts(knownHosts).has(host)) {
return null;
}
@@ -131,8 +131,10 @@ export async function resolveGitLabRepoFromDirectory(directory, remoteName = 'or
// ignore a malformed override base URL
}
}
// A forced gitlab provider (per-project override) accepts any remote host.
const forcedProvider = getProjectProviderFromDirectory(directory);
return {
repo: parseGitLabRemoteUrl(remoteUrl, knownHosts),
repo: parseGitLabRemoteUrl(remoteUrl, knownHosts, { allowAnyHost: forcedProvider === 'gitlab' }),
remoteUrl,
};
}