Skip to content

feat(vcs): add getOrganizationUrl to the adapter contract - #345

Merged
HarshMN2345 merged 2 commits into
mainfrom
feat/vcs-organization-url
Sep 24, 2026
Merged

HarshMN2345 merged 2 commits into
mainfrom
feat/vcs-organization-url

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

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:

Adapter Host source
GitLab $gitlabUrl (setEndpoint)
Gitea $giteaUrl (setEndpoint)
Bitbucket $bitbucketUrl
Origin $webEndpoint
GitHub github.com, fixed

Forgejo 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:

public function getOrganizationUrl(string $owner): string
{
    throw new Exception('getOrganizationUrl() is not supported by ' . $this->getName());
}

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 -l clean on all six changed files.
  • The method is a pure string builder off an existing property, with no new branching.

Not covered by a unit test: the sibling URL builders have none either, so this follows the surrounding convention. tests/Unit/Base.php is 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

  • Self-hosted GitLab reports the Appwrite console showing a gitlab.com owner link in project settings. Consuming this in Appwrite needs a release of this package first, then an organizationUrl field on the installation response, then the console change.

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.
@walter-o-brien

walter-o-brien Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

Reviewed 2eadc59..455b559 only; earlier commits in this PR were reviewed in a previous run.

Comment thread packages/vcs/src/VCS/Adapter.php Outdated
/**
* Browser-facing URL for an owner's home page: a user, organization or group.
*/
abstract public function getOrganizationUrl(string $owner): string;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other · high
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.

@walter-o-brien walter-o-brien Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ OpenCodeReview found no issues in 455b559 and has no open findings on this pull request.

This is an automated review and does not replace a review by a maintainer.

@HarshMN2345
HarshMN2345 merged commit 9255c15 into main Sep 24, 2026
5 of 6 checks passed

This branch had an error being deployed

1 failed deployment
vcs — 455b559c Deployed Sep 24, 2026 by HarshMN2345 via test (vcs) #1211
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.

1 participant