Files
headquarter/openspec/changes/smart-git-url-parsing/proposal.md
T
Fusion 8b70daed53 feat: smart git URL parsing for browser URLs
- Add git URL parsing utilities (extract_base_repo_url, parse_git_url)
- Support GitHub, GitLab, Bitbucket browser URL detection
- Add /projects/repositories/parse-url endpoint
- Enhance repository creation to detect browser URLs and suggest corrections
- Add real-time URL validation in frontend with debouncing
- Show visual indicators (green/yellow/red) for URL validity
- Display inline suggestions with 'Use Suggested' button
- Add comprehensive unit tests for URL parsing
- Quality gates: ruff ✓, mypy ✓, typecheck ✓, lint ✓, build ✓
2026-05-19 12:25:44 +02:00

1.9 KiB

Smart Git URL Parsing for Repository Creation

Problem

When users add a new repository, they often paste a full browser URL that includes branch names, file paths, or query parameters instead of a clean repository URL. This causes the clone operation to fail with unclear error messages.

Examples of problematic URLs:

  • https://github.com/user/repo/tree/main (includes branch path)
  • https://github.com/user/repo/blob/main/README.md (includes file path)
  • https://github.com/user/repo?tab=readme-ov-file (includes query params)
  • https://github.com/user/repo/pull/123 (includes PR path)

Current behavior: The backend attempts to clone the exact URL, which fails with "fatal: repository not found" or similar errors.

User confusion: Users don't understand why the clone failed since the URL works in their browser.

Solution

Implement smart URL parsing that:

  1. Detects non-repo URLs: Recognizes when a URL contains paths like /tree/, /blob/, /pull/, or query parameters
  2. Extracts base repo URL: Strips away branch names, file paths, query parameters to get https://host/owner/repo.git
  3. Suggests correction: Shows the user the extracted base URL and asks for confirmation
  4. Improves clone handling: Handles edge cases and provides clear error messages

Benefits

  • Better UX: Users get helpful suggestions instead of cryptic errors
  • Fewer support issues: Self-service correction reduces confusion
  • More robust: Handles common copy-paste mistakes automatically
  • Educational: Teaches users what a proper git URL looks like

Scope

Backend

  • URL parsing utilities to detect and extract base repo URLs
  • Enhanced validation in repository creation endpoint
  • Clear error messages for unsupported URLs

Frontend

  • UI dialog to show URL correction suggestions
  • Option to accept or edit the suggested URL
  • Visual indicator for URL validation status