fix(bitbucket): name a project when the workspace won't pick one - #131
fix(bitbucket): name a project when the workspace won't pick one#131HarshMN2345 wants to merge 10 commits into
Conversation
A Bitbucket repository belongs to a project. Bitbucket names one itself where the workspace has a default, which is why creating a repository has worked, and refuses the repository where it doesn't -- leaving the console reporting that the repository could not be created and nothing a user can do about it. The workspace is asked for a project and the create repeated with it, only where Bitbucket said the project was what it objected to. A name already taken, or a credential lacking the scope to create anything, is reported as it was.
Greptile SummaryThe PR adds optional Bitbucket project selection when creating a repository while preserving the shared three-argument adapter contract.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (9): Last reviewed commit: "test(bitbucket): read the project key wh..." | Re-trigger Greptile |
Bitbucket groups repositories under a project and asks for one when a repository is created, which GitHub and GitLab have no equivalent of. The caller can now name it, and the adapters that don't group repositories ignore what they're given.
Choosing a project for the caller put the repository somewhere nobody asked for, guessed from whichever the workspace listed first, and read the provider's wording to decide when to guess. A workspace that wants a project says so, and the caller now has a way to answer.
One test names the project the workspace already chose and reads it back off the repository. The other names one the workspace doesn't hold and expects the refusal, so a name that never left the adapter would fail it.
| * @return array<mixed> Details of new repository | ||
| */ | ||
| public function createRepository(string $owner, string $repositoryName, bool $private): array | ||
| public function createRepository(string $owner, string $repositoryName, bool $private, string $project = ''): array |
There was a problem hiding this comment.
Lets not add project to all adapters, unless we know it is a feature. If project is bitbucket specific concept, we need to keep it bitbucket only
| // Projects are Bitbucket's alone, so they are reached off the adapter | ||
| // itself rather than through the shared contract | ||
| private Bitbucket $bitbucket; |
There was a problem hiding this comment.
Lets try to make Appwrite PR. Curious what this casting will look like there, for bitbuket specific behaviour
There was a problem hiding this comment.
Worried this will be trouble, but not sure. Maybe PHP has some magic to make it nice
|
Not needed for now |
Creating a repository fails on some Bitbucket workspaces with:
and the console reports only that the repository was not created.
Why
A Bitbucket repository belongs to a project — its own create form makes this explicit: "You must either select a project or create a new one." The adapter sends
scm,nameandis_privateand no project, so Bitbucket picks the workspace default. That works where a workspace has one, which is why creation succeeds in CI and on most workspaces, and fails where it doesn't or where that default is restricted.Change
Where Bitbucket's own error names the project as the objection, the workspace is asked for one and the create repeated with
project.key. Any other failure — a name already taken, a credential without the scope to create anything — is reported unchanged, so this doesn't retry things that will not succeed.GET /2.0/workspaces/{workspace}/projectsreturnsvalues[].key; the first is used.Not covered
The caller still can't choose which project. Doing that means carrying a project through
createRepository()and offering a picker in the console, the way Bitbucket's form does — worth doing, but a larger change than unblocking creation.