Skip to content

Conversation

@slhck
Copy link

@slhck slhck commented Nov 10, 2025

The previous implementation assumed any unknown hostname was GitHub-like, which caused incorrect URLs for GitLab instances on custom domains.

Problem:
For a remote URL like https://git.example.com/foo/bar/baz/project.git, the old code generated: https://git.example.com/foo/bar/commit/... The correct URL should be: https://git.example.com/foo/bar/baz/project/commit/...

Root cause:
The code used remote.repo (only first 2 path segments) in the fallback handler, which broke nested groups in GitLab and any platform supporting deep path hierarchies.

Solution:

  1. Explicitly detect github.com and use GitHub-specific logic (remote.repo)
  2. Detect other known platforms (GitLab, Bitbucket, Azure, etc.)
  3. Generic fallback uses remote.pathname for platform-agnostic support

This fix:

  • ✅ Fixes GitLab instances on custom domains with nested groups
  • ✅ Maintains backward compatibility with all GitHub URLs
  • ✅ Supports GitHub Enterprise on custom domains
  • ✅ Works with any git hosting platform using deep path structures
  • ✅ Preserves HTTP/HTTPS protocol correctly

Added comprehensive test coverage for:

  • GitLab custom domains with nested groups (HTTPS and HTTP)
  • GitHub Enterprise on custom domains
  • GitLab instances with "gitlab" in hostname and nested paths

The previous implementation assumed any unknown hostname was GitHub-like,
which caused incorrect URLs for GitLab instances on custom domains.

Problem:
For a remote URL like https://git.example.com/foo/bar/baz/project.git,
the old code generated: https://git.example.com/foo/bar/commit/...
The correct URL should be: https://git.example.com/foo/bar/baz/project/commit/...

Root cause:
The code used `remote.repo` (only first 2 path segments) in the fallback
handler, which broke nested groups in GitLab and any platform supporting
deep path hierarchies.

Solution:
1. Explicitly detect github.com and use GitHub-specific logic (remote.repo)
2. Detect other known platforms (GitLab, Bitbucket, Azure, etc.)
3. Generic fallback uses remote.pathname for platform-agnostic support

This fix:
- ✅ Fixes GitLab instances on custom domains with nested groups
- ✅ Maintains backward compatibility with all GitHub URLs
- ✅ Supports GitHub Enterprise on custom domains
- ✅ Works with any git hosting platform using deep path structures
- ✅ Preserves HTTP/HTTPS protocol correctly

Added comprehensive test coverage for:
- GitLab custom domains with nested groups (HTTPS and HTTP)
- GitHub Enterprise on custom domains
- GitLab instances with "gitlab" in hostname and nested paths
@slhck
Copy link
Author

slhck commented Nov 10, 2025

Full disclosure: This is entirely LLM-generated and an attempt to fix #299 based on what I think the best solution is.

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