From 8a36e52d428805555de59bf29e45ef44e4b17a0f Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Wed, 4 Sep 2024 09:40:56 +0200 Subject: [PATCH] fix: validate workspace instead of project Signed-off-by: Benjamin Janssens --- .../src/actions/bitbucketCloudPullRequest.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloudPullRequest.ts b/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloudPullRequest.ts index 47261021b6..033eb59b6c 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloudPullRequest.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloudPullRequest.ts @@ -323,12 +323,9 @@ export function createPublishBitbucketCloudPullRequestAction(options: { gitAuthorEmail, } = ctx.input; - const { project, repo, host, workspace } = parseRepoUrl( - repoUrl, - integrations, - ); + const { workspace, repo, host } = parseRepoUrl(repoUrl, integrations); - if (!project) { + if (!workspace) { throw new InputError( `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`, ); @@ -350,15 +347,17 @@ export function createPublishBitbucketCloudPullRequestAction(options: { let finalTargetBranch = targetBranch; if (!finalTargetBranch) { finalTargetBranch = await getDefaultBranch({ - workspace: workspace!, + workspace, repo, authorization, apiBaseUrl, }); } + // TODO: check if sourceBranch already exists and just create a pull request for it if so + await createBranch({ - workspace: workspace!, + workspace, repo, branchName: sourceBranch, authorization, @@ -445,7 +444,7 @@ export function createPublishBitbucketCloudPullRequestAction(options: { }); const pullRequestUrl = await createPullRequest({ - workspace: workspace!, + workspace, repo, title, description,