Skip to content

Conversation

@lerenn
Copy link
Owner

@lerenn lerenn commented Dec 24, 2025

Summary

This PR adds support for ssh:// URL format in repository cloning, allowing users to clone repositories using the explicit ssh:// protocol prefix.

Problem

The normalizeRepositoryURL function only supported:

  • git@host:path format (SSH without protocol)
  • https://host/path format (HTTPS)

It did not support ssh://git@host/path format, causing errors when trying to clone repositories like:

ssh://git@forge.lab.home.lerenn.net/homelab/lgtm.git

Solution

  • Updated normalizeRepositoryURL to parse ssh:// URLs using url.Parse
  • Handle port numbers in ssh:// URLs (e.g., ssh://git@host:22/path)
  • Normalize ssh:// URLs to host/path format consistent with other formats

Testing

  • Added unit tests for ssh:// URL formats:
    • Basic format with .git suffix
    • Without .git suffix
    • With port numbers
  • Added E2E test for ssh:// URL format

Changes

  • pkg/code-manager/clone.go - Updated normalizeRepositoryURL function
  • pkg/code-manager/clone_test.go - Added unit tests
  • test/repo_clone_test.go - Added E2E test

Add support for ssh://git@host/path URL format in the normalizeRepositoryURL
function. This allows users to clone repositories using the explicit ssh://
protocol prefix, which is useful for custom Git servers and specific SSH
configurations.

Changes:
- Updated normalizeRepositoryURL to parse ssh:// URLs using url.Parse
- Handle port numbers in ssh:// URLs (e.g., ssh://git@host:22/path)
- Normalize ssh:// URLs to host/path format consistent with other formats
- Added unit tests for ssh:// URL formats (with/without .git, with port)
- Added E2E test for ssh:// URL format

This fixes the issue where cloning with ssh://git@forge.lab.home.lerenn.net/homelab/lgtm.git
would fail with 'unsupported repository URL format' error.
Extract URL normalization logic into separate helper functions to reduce
cyclomatic complexity from 12 to below the limit of 10.

- Extract normalizeSSHProtocolURL for ssh:// URLs
- Extract normalizeSSHURL for git@host:path URLs
- Extract normalizeHTTPSURL for https:// URLs
- Add isSSHURL helper function for URL type detection
@lerenn lerenn merged commit 92de807 into main Dec 24, 2025
9 checks passed
@lerenn lerenn deleted the feat-support-repo-clone-ssh branch December 24, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants