Merge branch 'main' of ssh://git.commumedia.org:2222/alex/headquarter

This commit is contained in:
Fusion
2026-05-22 20:34:20 +02:00
20 changed files with 867 additions and 252 deletions
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-05-22
@@ -0,0 +1,45 @@
## Context
The current repository creation flow already supports cloning remote repositories via `remote_url` and can normalize pasted browser URLs. However, the UI asks for a full URL, which is awkward for the fixed provider `git.commumedia.org`. The requested behavior is to enter `owner` and `repo`, check whether the repository exists, and clone only if it does.
## Goals / Non-Goals
**Goals:**
- Accept SSH-only `owner` and `repo` inputs for cloning from `git.commumedia.org`
- Verify repository existence before clone
- Preserve full URL paste as a fallback path
- Preserve blank repository creation
- Reuse the existing repository create endpoint and shared dialog
**Non-Goals:**
- Supporting multiple git providers
- Adding a remote repository discovery API
- Supporting HTTPS clone flow for the new structured path
- Changing repository storage or clone behavior beyond preflight validation
## Decisions
**1. Provider assumption**
- Hardcode `git.commumedia.org` for the structured clone path
- Build SSH URLs as `git@git.commumedia.org:{owner}/{repo}.git`
**2. Existence check**
- Use `git ls-remote` on the constructed SSH URL before cloning
- If the command fails, surface a repository-not-found/inaccessible error and do not clone
**3. UI structure**
- Keep the shared repository creation dialog as the single entry point
- In clone mode, collect `owner` and `repo` instead of asking for a full URL
- Keep an advanced paste-URL fallback for existing behavior and browser URL parsing
- Keep blank repository creation available in the same dialog
**4. Backend behavior**
- Reuse `POST /projects/{project_id}/repositories`
- Add preflight logic before the existing `git clone --mirror`
- Leave the database schema unchanged
## Risks / Trade-offs
**[Risk] SSH auth may still fail even if the repo exists** → Mitigation: preflight error should be explicit and user-facing.
**[Risk] Command availability** → Mitigation: reuse the same `git` dependency already required for cloning.
**[Risk] UI complexity** → Mitigation: keep the dialog shared and minimal, with fallback URL paste.
@@ -0,0 +1,25 @@
## Why
Repository creation already supports cloning from a remote URL, but the current UI only accepts a full URL. For the common fixed-provider case (`git.commumedia.org`), users should be able to enter `owner` and `repo` and have the app verify the repository exists before cloning. If the repository does not exist, the app should surface a clear error. Existing blank repository creation must remain available.
## What Changes
- Change the shared repository create dialog to support an SSH-only clone form with `owner` and `repo`
- Build the clone target as `git@git.commumedia.org:{owner}/{repo}.git`
- Preflight clone targets with `git ls-remote` before cloning
- Return a clear error when the repository is missing or inaccessible
- Keep the current full URL paste flow as an advanced fallback
- Keep blank repository creation as a fallback option
## Capabilities
### Modified Capabilities
- `git-repo`: Repository creation UX and clone validation reuse the existing create endpoint and clone path
## Impact
- Frontend: `repository-create-dialog.tsx`, `git-repositories.tsx`, `repositories-settings-tab.tsx`
- Backend: `git_repositories.py` create endpoint clone preflight
- Docs: repository creation guidance must reflect SSH-only owner/repo input
- Tests: add coverage for SSH repo existence checks and fallback URL behavior
@@ -0,0 +1,22 @@
## 1. Backend - SSH Existence Check
- [ ] 1.1 Add `git ls-remote` preflight to repository creation in `git_repositories.py`
- [ ] 1.2 Build SSH clone URL from `owner` and `repo` for `git.commumedia.org`
- [ ] 1.3 Return a clear error when the repository is missing or inaccessible
## 2. Frontend - Structured Clone Form
- [ ] 2.1 Update `RepositoryCreateDialog` clone mode to accept `owner` and `repo`
- [ ] 2.2 Keep advanced full-URL paste flow and blank repository fallback
- [ ] 2.3 Reuse the shared dialog from repository settings and repositories page
## 3. Validation and Docs
- [ ] 3.1 Update repository docs to explain SSH-only owner/repo input
- [ ] 3.2 Add tests for success, missing repo, and URL fallback behavior
## 4. Quality Gates
- [ ] 4.1 Run backend and frontend targeted tests
- [ ] 4.2 Run frontend typecheck and lint where applicable
- [ ] 4.3 Commit and push changes
@@ -0,0 +1,33 @@
## Context
Repository creation currently produces mirrored bare repos for any remote clone and bare repos for blank creations. The workspace, file browser, commit editor, and git toolbar are built around a working-tree repository model, so users can hit 400s when they try to sync or when the repo has no usable branch state.
## Goals
- Create working clones for remote repositories
- Create working repos with an initial branch for blank repositories
- Preserve the existing repository create endpoint and shared UI flow
- Keep fetch/pull/push aligned with a normal local clone
## Decisions
1. Clone mode
- Use `git clone` without `--mirror`
- Keep the existing remote URL preflight and URL parsing behavior
2. Blank repositories
- Initialize with `git init -b main` when supported
- Fall back to `git init` plus `git symbolic-ref HEAD refs/heads/main` if needed
3. Branch state
- Treat `main` as the initial branch name for blank repos
- Make branch listing and current-branch helpers tolerate unborn `HEAD`
4. Pull behavior
- Prefer the current branch when no explicit branch is supplied
- Do not force `origin <branch>` if the branch is unborn or already tracked by the current checkout
## Risks
- Some older git versions may not support `git init -b`; the backend should fall back cleanly
- Existing blank repos created under the old bare model may still require migration or cleanup outside this change
@@ -0,0 +1,17 @@
## Why
The current repository creation flow creates mirrored bare repositories for clone-based repos. That breaks the workspace model because the UI and file editing features expect a normal working clone with an initial branch, remote tracking, and pull/fetch behavior that works from a checked-out branch.
## What Changes
- Create clone-based repositories as normal working clones instead of mirrors
- Initialize blank repositories as working clones with an initial branch when needed
- Ensure newly created repos have a usable current branch for workspace browsing and commits
- Update pull semantics to use the current tracked branch when available
- Keep fetch behavior available for remote-synced repositories
## Impact
- Backend: repository creation and git control helpers
- Backend tests: clone, pull, and empty-repo branch behavior
- Frontend: no intentional UX change beyond sync behavior becoming reliable
@@ -0,0 +1,19 @@
## 1. Backend - Repository Creation
- [x] 1.1 Switch clone-based repository creation from mirror clones to normal working clones
- [x] 1.2 Initialize blank repositories with a default branch name
- [x] 1.3 Preserve remote preflight and clear error handling
## 2. Backend - Git Sync Helpers
- [x] 2.1 Update pull behavior to use the current tracked branch when available
- [x] 2.2 Make branch helpers tolerate unborn HEAD in blank repos
## 3. Tests
- [x] 3.1 Add unit coverage for clone creation and blank repo initialization
- [x] 3.2 Add coverage for pull behavior on working clones and blank repos
## 4. Quality Gates
- [ ] 4.1 Run targeted API tests