8b70daed53
- 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 ✓
1.9 KiB
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:
- Detects non-repo URLs: Recognizes when a URL contains paths like
/tree/,/blob/,/pull/, or query parameters - Extracts base repo URL: Strips away branch names, file paths, query parameters to get
https://host/owner/repo.git - Suggests correction: Shows the user the extracted base URL and asks for confirmation
- 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