1.5 KiB
1.5 KiB
Context
The platform has projects and SSH keys but no git repository management. Users need to create bare repos for their projects and optionally clone external ones.
Goals / Non-Goals
Goals:
- Create bare git repositories on disk within project structure
- List repositories per project
- Clone external repositories as bare mirrors
- Delete repositories (cascade with project deletion)
- Prevent duplicate repo names per project
Non-Goals:
- Git hosting (push/pull via SSH/HTTP)
- Webhook handling
- CI/CD integration
- Repository browsing/file viewing
Decisions
-
Bare repositories only
- Simplifies storage, no working tree needed
- Standard pattern for git servers
-
Storage path:
/data/repos/{user_id}/{project_id}/{name}.git- Isolates repos by user and project
- Predictable structure
-
Use subprocess to run
git init --bareandgit clone --mirror- Standard git commands, no additional dependencies
- More reliable than git libraries for basic operations
-
Store only metadata in database
- Name, path, remote_url, project_id
- Actual git data stays on disk
Risks / Trade-offs
- [Disk space] -> Monitor usage, implement cleanup
- [Git not in container] -> Ensure git is installed in API Dockerfile
- [Concurrent access] -> File locking not implemented (future)
Migration Plan
- Create API endpoints
- Add git to Dockerfile
- Create frontend
- Test with sample repos
Open Questions
- Should we validate git URLs before cloning?