Repository navigation
feat(vcs): add getOrganizationUrl to the adapter contract - #345
Merged
Merged
Conversation
Every adapter already builds browser-facing repository, branch, commit and file URLs from its own configured host, but nothing could link to the owner itself, so callers wanting an owner link had no option but to hardcode a provider domain. Add getOrganizationUrl alongside getRepositoryUrl, resolved from the same host property in each adapter: gitlabUrl, giteaUrl, bitbucketUrl, Origin's webEndpoint, and github.com for GitHub, which is fixed. Forgejo and Gogs extend Gitea and override only giteaUrl's default, so they inherit a correct implementation.
HarshMN2345
requested review from
Meldiron,
abnegate,
eldadfux and
loks0n
as code owners
September 24, 2026 08:17
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). Reviewed |
| /** | ||
| * Browser-facing URL for an owner's home page: a user, organization or group. | ||
| */ | ||
| abstract public function getOrganizationUrl(string $owner): string; |
There was a problem hiding this comment.
Adding this abstract method is a breaking change for consumers that subclass Adapter: their adapters will fail to load until they implement it. Since this is a public library API, either provide a compatible concrete default or release this change as a breaking major version and document the migration.
Declaring it abstract forces every adapter defined outside this package to implement it before the class will load, which makes an otherwise additive change breaking. Ship a default that reports the method as unsupported, matching how listNamespaces() handles providers that do not model it. All five adapters here still override it, so nothing in this package reaches the default.
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Every adapter already builds browser-facing URLs from its own configured host —
getRepositoryUrl,getBranchUrl,getCommitUrl,getFileUrl— but there is no way to link to the owner itself. A caller that wants an owner link has no option but to hardcode a provider domain, which is wrong for every self-hosted instance.This adds
getOrganizationUrl(string $owner): string, resolved from the same host property each adapter already holds:$gitlabUrl(setEndpoint)$giteaUrl(setEndpoint)$bitbucketUrl$webEndpointgithub.com, fixedForgejo and Gogs extend Gitea and override only
giteaUrl's default (http://forgejo:3000,http://gogs:3000), so they inherit a correct implementation rather than needing their own.Additive, not breaking
The method is declared concrete on
Adapter, with a default that reports it as unsupported, rather than abstract. An abstract declaration would stop any adapter defined outside this package from loading until it implemented the method, which turns an otherwise additive change into a breaking one for a published public API.The default follows how
listNamespaces()already handles providers that do not model a concept:All five adapters in this package override it, so nothing here reaches the default. This can go out as a patch or a minor; it does not need a major.
Test Plan
php -lclean on all six changed files.Not covered by a unit test: the sibling URL builders have none either, so this follows the surrounding convention.
tests/Unit/Base.phpis a shared base every adapter subclass runs, which would make one method cover all providers at once — happy to add it there if you would rather have it.Related PRs and Issues
gitlab.comowner link in project settings. Consuming this in Appwrite needs a release of this package first, then anorganizationUrlfield on the installation response, then the console change.