feat(web,ui): per-project git provider API base URL overrides

Per provider (github|gitlab|gitea) a project override stored in
~/.config/openchamber/projects/<projectId>.json under gitProviders wins
over the global settings.json value (precedence: project override > global
> built-in default). Server forge routes resolve the override per request
directory (worktree-aware via git-common-dir + containment + path fallback,
60s TTL cache); the override host is also accepted for remote parsing and
client detection. New GET/PUT /api/projects/:projectId/git-providers route;
client openchamberConfig preserves the server-owned gitProviders key;
Projects page gains a Git provider API base URLs section; detection store
hydrates per-project overrides (memory-only, server-authoritative).
This commit is contained in:
2026-08-17 09:57:54 +00:00
parent 697925ee0d
commit 66edc74fac
42 changed files with 1765 additions and 87 deletions
+17 -1
View File
@@ -1,5 +1,6 @@
import { getRemoteUrl } from '../git/index.js';
import { getGiteaAuthAccounts, normalizeBaseUrl } from './auth.js';
import { getEffectiveProviderApiBaseUrl } from '../git-providers/project-config.js';
// When no explicit host allowlist is provided, accept any host that matches the
// base URL of a stored Gitea account. Gitea/Forgejo is self-hosted, so there is
@@ -117,8 +118,23 @@ export async function resolveGiteaRepoFromDirectory(directory, remoteName = 'ori
if (!remoteUrl) {
return { repo: null, remoteUrl: null };
}
// A per-project API base override makes its host acceptable for directory
// resolution even when no connected account covers it.
const overrideBaseUrl = getEffectiveProviderApiBaseUrl('gitea', directory);
let knownHosts;
if (overrideBaseUrl) {
knownHosts = acceptedHosts();
try {
const host = new URL(overrideBaseUrl).hostname.toLowerCase();
if (host) {
knownHosts.add(host);
}
} catch {
// ignore a malformed override base URL
}
}
return {
repo: parseGiteaRemoteUrl(remoteUrl),
repo: parseGiteaRemoteUrl(remoteUrl, knownHosts),
remoteUrl,
};
}