ADR 0025 T5: per-dir and per-URL config resolution entry points #31

Closed
opened 2026-07-13 15:56:42 +00:00 by hexajon · 0 comments
hexajon commented 2026-07-13 15:56:42 +00:00 (Migrated from codeberg.org)

Add internal/config/resolve_dir.go:

  • GetConfigForDir(ctx, dir) (*Config, error) — chain against the repo at dir: env → dir-local --local madtea.url → OriginForgeURL(dir) → global fallback; per-dir cache, never touches the process cache; ClearCache() clears it too.
  • GetConfigForURL(ctx, forgeURL) (*Config, error) — credentials for a known forge URL via the host-keyed backend.
  • Errors name host + fix: no credentials for <host> — run madtea auth login…; cannot determine the forge for <dir>….
  • ADR 0022: testingConfigGuard() before any git/origin read; env short-circuit first.

Also (follow-up from T4 review): make IsConfigured (internal/config/config.go:98) origin-aware — an origin-only repo with resolvable credentials must count as configured (it currently reads merged madtea.url only; consumers: setup.go, mcp/context.go).

Tests: dir with codeberg origin resolves codeberg while process cache stays on the cwd forge; dir-local override wins; cache isolation. Table-driven, temp repos, GIT_CONFIG_GLOBAL under temp.

Acceptance: go test ./internal/config/ green; chain-order tests from T4 untouched.

Part of #30.

Add `internal/config/resolve_dir.go`: - `GetConfigForDir(ctx, dir) (*Config, error)` — chain against the repo at dir: env → dir-local `--local` madtea.url → `OriginForgeURL(dir)` → global fallback; per-dir cache, never touches the process cache; `ClearCache()` clears it too. - `GetConfigForURL(ctx, forgeURL) (*Config, error)` — credentials for a known forge URL via the host-keyed backend. - Errors name host + fix: `no credentials for <host> — run madtea auth login…`; `cannot determine the forge for <dir>…`. - ADR 0022: `testingConfigGuard()` before any git/origin read; env short-circuit first. Also (follow-up from T4 review): make `IsConfigured` (internal/config/config.go:98) origin-aware — an origin-only repo with resolvable credentials must count as configured (it currently reads merged madtea.url only; consumers: setup.go, mcp/context.go). Tests: dir with codeberg origin resolves codeberg while process cache stays on the cwd forge; dir-local override wins; cache isolation. Table-driven, temp repos, `GIT_CONFIG_GLOBAL` under temp. Acceptance: `go test ./internal/config/` green; chain-order tests from T4 untouched. Part of #30.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sixfold-space/madtea#31
No description provided.