Skip to content

List the workspaces a Bitbucket account can reach - #177

Open
HarshMN2345 wants to merge 5 commits into
mainfrom
feat/bitbucket-namespaces
Open

List the workspaces a Bitbucket account can reach#177
HarshMN2345 wants to merge 5 commits into
mainfrom
feat/bitbucket-namespaces

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What

listNamespaces() was never implemented for Bitbucket, so the abstract Git default threw and Bitbucket reported no namespaces at all. Consumers fall back to a single owner, which is whatever getOwnerName() returns -- and that reads /user/workspaces and keeps values[0]. An account in several workspaces could only ever see the first one, with no way to pick between them.

The same response already describes every workspace, so this maps it to the shared namespace shape instead of discarding all but the first entry.

Kind

The shared contract expects a user and a group kind, which is why supportsNamespaceListing was previously off for Bitbucket -- a workspace carries no personal-vs-team flag. It does carry the identity of its owner though, so the account's own workspace is found by matching the uuid from /user, falling back to the slug. That distinction is real; it just isn't a field.

Test plan

  • bin/monorepo check vcs -- pint, PHPStan and Rector all pass
  • bin/monorepo test vcs -- 559 tests pass (Bitbucket skips locally without a token)
  • supportsNamespaceListing is no longer overridden in BitbucketTest, so testListNamespaces and testListNamespacesWithSearch now run against Bitbucket in CI

Worth a reviewer's eye: testListNamespaces asserts both a user and a group kind are present, so it needs the test account to belong to its own workspace and at least one team workspace. That is the case for the account CI uses today, but it is a property of the account rather than of the code.

Only the first workspace was ever reported, because getOwnerName() reads
/user/workspaces and keeps values[0]. The same response describes every
workspace, so listing them costs nothing extra and lets a caller pick the
one a repository belongs in.
Listing namespaces reads it to tell a personal workspace from a team one,
and every call was fetching /user again.
@HarshMN2345

Copy link
Copy Markdown
Member Author

@greptile review

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