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
+13 -3
View File
@@ -124,11 +124,21 @@ describe('Gitea auth routes', () => {
expect(response.body).toEqual({ error: 'accessToken is required' });
});
test('auth/connect requires a base URL (no default instance)', async () => {
test('auth/connect uses the built-in default base URL when none is provided', async () => {
const fetchMock = scriptedFetch([(url) => (matches(/\/api\/v1\/user$/)(url) ? jsonResponse(aliceUser) : null)]);
const app = createApp();
const response = await request(app).post('/api/gitea/auth/connect').send({ accessToken: 'gitea-valid' });
expect(response.status).toBe(400);
expect(response.body).toEqual({ error: 'baseUrl is required and must be a valid URL' });
expect(fetchMock.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/user');
expect(response.status).toBe(200);
expect(response.body).toMatchObject({
connected: true,
user: { username: 'alice', id: 42, name: 'Alice Example', avatarUrl: 'https://gitea.example.com/avatars/alice.png', webUrl: 'https://gitea.example.com/alice', email: 'alice@example.com' },
});
expect(response.body.accounts).toEqual([
{ id: 'codeberg.org:alice', user: { username: 'alice', name: 'Alice Example', avatarUrl: 'https://gitea.example.com/avatars/alice.png', webUrl: 'https://gitea.example.com/alice' }, baseUrl: 'https://codeberg.org', current: true },
]);
});
test('auth/connect normalizes a scheme-less base URL', async () => {