0e6521e433
- Add mappings array support to git_mount entries - Clone repository once per git_mount entry, mount multiple subdirectories - Normalize legacy source_path+target_path to mappings on read - Update _merge_git_mounts to dedup by (remote_url, branch) and concatenate mappings - Add _normalize_git_mount, _clone_git_repo, _resolve_git_mount_mappings helpers - Update GitMountItem Pydantic model with GitMountMapping and model_validator - Update frontend GitMountEditor component with mappings UI - Auto-convert legacy git mount entries to mappings format on load - Add 15 backend unit tests for normalization, resolution, and glob expansion - Update existing config profile resolver tests for new merge behavior Quality gates: pytest 167 passed, frontend typecheck clean Addresses: config-profile-multi-repo-mounts
3.7 KiB
3.7 KiB
Spec: Config Profile Multi-Repo Mounts
Requirements
Functional
- FR-1: A
git_mountentry MAY include amappingsarray. - FR-2: Each item in
mappingsMUST havesource_pathandtarget_path. - FR-3: If
mappingsis absent,source_pathandtarget_pathat the entry level MUST be treated as a single mapping (backward compatibility). - FR-4: The repository MUST be cloned exactly once per
git_mountentry. - FR-5: Each mapping MUST create a separate Docker bind mount.
- FR-6: Glob patterns in
source_pathMUST be expanded per mapping. - FR-7: Relative
target_pathvalues MUST be resolved againstworking_directory. - FR-8: The merge logic for included profiles MUST deduplicate by
(remote_url, branch)within a single resolved profile'sgit_mountslist.
Non-Functional
- NFR-1: No database schema migration required.
- NFR-2: Existing API responses must remain backward-compatible.
- NFR-3: Frontend type-check must pass without errors.
API Contracts
ConfigProfile model (git_mounts field)
{
"git_mounts": [
{
"remote_url": "https://github.com/user/monorepo.git",
"branch": "main",
"mappings": [
{"source_path": "packages/api", "target_path": "/app/api"},
{"source_path": "packages/web", "target_path": "/app/web"}
]
},
{
"remote_url": "https://github.com/user/docs.git",
"source_path": ".",
"target_path": "/docs",
"branch": "main"
}
]
}
Validation rules
mappingsmust be a non-empty array if present.- Each mapping must have
source_path(string) andtarget_path(string). - Either
mappingsOR (source_pathANDtarget_path) must be present. remote_urlmust be a valid HTTPS or SSH Git URL.
Database Schema
No changes. git_mounts is stored as JSONB in config_profiles.git_mounts.
Scenarios
Scenario 1: Monorepo with multiple packages
Given a Config Profile with:
{"git_mounts": [{
"remote_url": "https://github.com/corp/monorepo.git",
"branch": "main",
"mappings": [
{"source_path": "packages/api", "target_path": "/app/api"},
{"source_path": "packages/web", "target_path": "/app/web"},
{"source_path": "packages/shared", "target_path": "/app/shared"}
]
}]}
When the profile is applied to an instance
Then:
corp/monorepois cloned once togit-mounts/monorepo-{hash}/repo-clone- Three bind mounts are created:
{clone}/packages/api→/app/api{clone}/packages/web→/app/web{clone}/packages/shared→/app/shared
Scenario 2: Legacy single mapping (backward compatibility)
Given a Config Profile with:
{"git_mounts": [{
"remote_url": "https://github.com/user/repo.git",
"source_path": "src",
"target_path": "/workspace/src",
"branch": "main"
}]}
When the profile is applied
Then the behavior is identical to before (single clone, single mount).
Scenario 3: Glob expansion within mapping
Given a mapping with:
{"source_path": "packages/*", "target_path": "/app/packages"}
When the repo is cloned and the glob is expanded
Then each matched directory is mounted as a separate bind mount with the relative path appended to the target:
{clone}/packages/api→/app/packages/api{clone}/packages/web→/app/packages/web
Test Strategy
- Unit test
_resolve_single_git_mountwithmappingsarray - Unit test
_merge_git_mountswith mappings deduplication - Integration test: profile with 3 mappings from same repo → verify single clone
- Integration test: legacy profile without
mappings→ verify backward compatibility - Frontend unit test: GitMountEditor renders mappings form correctly