From 9cf827cadac90b4151890aebe06e6436ae81b626 Mon Sep 17 00:00:00 2001 From: RedlineTriad <39059512+RedlineTriad@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:14:27 +0200 Subject: [PATCH] fix: double branch creation in `public:bitbucket{Cloud,Server}:pull-request` Signed-off-by: RedlineTriad <39059512+RedlineTriad@users.noreply.github.com> --- .changeset/tricky-crabs-lick.md | 13 +++++++++++++ .../src/actions/bitbucketCloudPullRequest.ts | 8 -------- .../src/actions/bitbucketServerPullRequest.ts | 8 -------- 3 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 .changeset/tricky-crabs-lick.md diff --git a/.changeset/tricky-crabs-lick.md b/.changeset/tricky-crabs-lick.md new file mode 100644 index 0000000000..4f858538a3 --- /dev/null +++ b/.changeset/tricky-crabs-lick.md @@ -0,0 +1,13 @@ +--- +'@backstage/plugin-scaffolder-backend-module-bitbucket-server': patch +'@backstage/plugin-scaffolder-backend-module-bitbucket-cloud': patch +--- + +Fix double branch creation in `public:bitbucket{Cloud,Server}:pull-request` +This resulted in the following error when using the actions: + +``` +AlreadyExistsError: Failed to create branch at create-test because it already exists. +``` + +The issue was original introduced in d103a48fa306d745599dc0c793668c9e6a479d32 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 4d1f0e3a40..99a78c7c26 100644 --- a/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloudPullRequest.ts +++ b/plugins/scaffolder-backend-module-bitbucket-cloud/src/actions/bitbucketCloudPullRequest.ts @@ -21,7 +21,6 @@ import { getRepoSourceDirectory, commitAndPushBranch, addFiles, - createBranch as createGitBranch, cloneRepo, parseRepoUrl, } from '@backstage/plugin-scaffolder-node'; @@ -412,13 +411,6 @@ export function createPublishBitbucketCloudPullRequestAction(options: { ref: sourceBranch, }); - await createGitBranch({ - dir: tempDir, - auth, - logger: ctx.logger, - ref: sourceBranch, - }); - // copy files fs.cpSync(sourceDir, tempDir, { recursive: true, diff --git a/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts b/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts index 1533393a52..69e9dfe7bf 100644 --- a/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts +++ b/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts @@ -24,7 +24,6 @@ import { getRepoSourceDirectory, commitAndPushBranch, addFiles, - createBranch as createGitBranch, cloneRepo, parseRepoUrl, } from '@backstage/plugin-scaffolder-node'; @@ -452,13 +451,6 @@ export function createPublishBitbucketServerPullRequestAction(options: { ref: sourceBranch, }); - await createGitBranch({ - dir: tempDir, - auth, - logger: ctx.logger, - ref: sourceBranch, - }); - // copy files fs.cpSync(sourceDir, tempDir, { recursive: true,