Skip to content

Fix GitLab changelog URLs for custom domain instances with nested groups#300

Open
slhck wants to merge 1 commit into
cookpete:masterfrom
slhck:claude/fix-gitlab-changelog-urls-011CUyvP6yNTM2gzo42hJn3w
Open

Fix GitLab changelog URLs for custom domain instances with nested groups#300
slhck wants to merge 1 commit into
cookpete:masterfrom
slhck:claude/fix-gitlab-changelog-urls-011CUyvP6yNTM2gzo42hJn3w

Conversation

@slhck
Copy link
Copy Markdown

@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

@slhck
Copy link
Copy Markdown
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.

@ljharb
Copy link
Copy Markdown
Collaborator

ljharb commented May 5, 2026

This seems like a pretty major conceptual refactor. It seems simple and cleaner to add a new config option that's basically a template for the root path, which defaults to ${hostname}/, or something?

@slhck
Copy link
Copy Markdown
Author

slhck commented May 6, 2026

It's not just about the hostname, the path of the repository must be properly constructed. A template won't help here, as you can see from the broken path in the example.

@ljharb
Copy link
Copy Markdown
Collaborator

ljharb commented May 6, 2026

surely something would - like a config object where you specify path as /foo/bar/ vs the default /?

@slhck
Copy link
Copy Markdown
Author

slhck commented May 7, 2026

I think you're suggesting some configurable template for the host, but that does not help when the repository oath is wrongly constructed. Please look at the unit test cases and see how they fail today. You wouldn't want users having to specify the exact remote path naming convention per repository, and it's not even necessary, because the suggested change handles that automatically for everyone.

@slhck
Copy link
Copy Markdown
Author

slhck commented May 7, 2026

Just to comment on this a bit more: I think there may be a misunderstanding about where the bug is.

The git remote URL itself already contains the full path. remote.pathname from parse-github-url gives us /foo/bar/baz/project correctly. There is no need for the user to configure anything. The auto-changelog tool currently just throws that information away in the fallback branch by using remote.repo (first two segments only).

So it's not that the tool can't know the path; it's that it's discarding what it already knows.

A config option would work, but every self-hosted GitLab user with nested groups gets broken commit URLs unless they discover the option and set it for every single repository.

The added test cases pin the existing platforms to their correct output so there's no regression risk.

@ljharb
Copy link
Copy Markdown
Collaborator

ljharb commented May 13, 2026

i'm confused, then why do we need to make github (or "not github") special? we should just always use remote.pathname for every case, no?

@slhck slhck force-pushed the claude/fix-gitlab-changelog-urls-011CUyvP6yNTM2gzo42hJn3w branch from 2e1bbb3 to 26ef957 Compare May 13, 2026 08:13
@slhck
Copy link
Copy Markdown
Author

slhck commented May 13, 2026

You're right – I tested it and there's actually no reason for a special case. Rebased and simplified.

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