Skip to content

fix forge api base url construction#141

Draft
pigam wants to merge 2 commits into
git-pkgs:mainfrom
pigam:api-base-url
Draft

fix forge api base url construction#141
pigam wants to merge 2 commits into
git-pkgs:mainfrom
pigam:api-base-url

Conversation

@pigam

@pigam pigam commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Fix forge api API base URL selection for self-hosted forge instances.

forge api previously selected the API root using domain-name substring checks, for example by looking for gitlab in the hostname. This breaks self-hosted instances whose domain does not include the expected forge-specific substring.

Closes #140

Changes

  • Extract API base URL selection into apiBaseURL.
  • Resolve the API root from:
    1. explicit --forge-type
    2. configured domain type
    3. known-domain defaults
    4. existing hostname heuristics as fallback
  • Add unit tests for:
    • known domains
    • unknown domains with explicit forge type
    • unknown domains with configured forge type
    • unknown domains without type information

pigam added 2 commits July 20, 2026 17:56
Add unit tests covering known domains, explicit forge types, configured forge types, and unknown-domain fallback behavior.
@pigam
pigam marked this pull request as draft July 21, 2026 08:59
@pigam

pigam commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Further analysis : the api base url is a property of a forge.

resolve.Repo returns a Forge, but the result is ignored here.

_, owner, repoName, domain, err := resolve.Repo(flagRepo, flagForgeType)
^
# forge !

Normal, as the Forge interface has not yet a way to return this information.

I think a cleaner solution would be to add APIBaseURL to the Forge interface, but this would force the change on all actual forges backend.

An opinion ?

@andrew

andrew commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Agreed, the API base URL belongs to the resolved forge. I’d use a small companion interface such as APIBaseURLProvider rather than changing Forge, so external implementations do not break. Then forge api can use the resolved backend directly, including types found by probing and GitHub Enterprise’s /api/v3 URL.

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.

🐛 forge api ignores forge type for base URL

2 participants