From f7cc86f9dd4878d751f580877a8a9e4ef4f4f696 Mon Sep 17 00:00:00 2001 From: Jason Froehlich Date: Tue, 16 Jan 2024 15:00:05 -0500 Subject: [PATCH] clean-up code, fixed issue number and added import Signed-off-by: Jason Froehlich --- .changeset/unlucky-wasps-tan.md | 2 +- .../package.json | 1 + .../scaffolder-node/src/actions/gitHelpers.ts | 49 +++++++------------ 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/.changeset/unlucky-wasps-tan.md b/.changeset/unlucky-wasps-tan.md index df6eca4820..97813cb416 100644 --- a/.changeset/unlucky-wasps-tan.md +++ b/.changeset/unlucky-wasps-tan.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend-module-bitbucket': patch --- -Enhanced the pull request action to allow for adding new content to the PR as described in this issue #2172 +Enhanced the pull request action to allow for adding new content to the PR as described in this issue #21762 diff --git a/plugins/scaffolder-backend-module-bitbucket/package.json b/plugins/scaffolder-backend-module-bitbucket/package.json index 03ebab43fc..e045bb9dc8 100644 --- a/plugins/scaffolder-backend-module-bitbucket/package.json +++ b/plugins/scaffolder-backend-module-bitbucket/package.json @@ -28,6 +28,7 @@ "@backstage/errors": "workspace:^", "@backstage/integration": "workspace:^", "@backstage/plugin-scaffolder-node": "workspace:^", + "fs-extra": "10.1.0", "node-fetch": "^2.6.7", "yaml": "^2.0.0" }, diff --git a/plugins/scaffolder-node/src/actions/gitHelpers.ts b/plugins/scaffolder-node/src/actions/gitHelpers.ts index 7f36ae0137..2026e75247 100644 --- a/plugins/scaffolder-node/src/actions/gitHelpers.ts +++ b/plugins/scaffolder-node/src/actions/gitHelpers.ts @@ -138,15 +138,7 @@ export async function commitAndPushRepo(input: { /** * @public */ -export async function cloneRepo({ - url, - dir, - auth, - logger, - ref, - depth, - noCheckout, -}: { +export async function cloneRepo(options: { url: string; dir: string; // For use cases where token has to be used with Basic Auth @@ -158,6 +150,8 @@ export async function cloneRepo({ depth?: number | undefined; noCheckout?: boolean | undefined; }): Promise { + const { url, dir, auth, logger, ref, depth, noCheckout } = options; + const git = Git.fromAuth({ ...auth, logger, @@ -169,12 +163,7 @@ export async function cloneRepo({ /** * @public */ -export async function createBranch({ - dir, - auth, - logger, - ref, -}: { +export async function createBranch(options: { dir: string; ref: string; // For use cases where token has to be used with Basic Auth @@ -183,6 +172,7 @@ export async function createBranch({ auth: { username: string; password: string } | { token: string }; logger?: Logger | undefined; }): Promise { + const { dir, ref, auth, logger } = options; const git = Git.fromAuth({ ...auth, logger, @@ -194,12 +184,7 @@ export async function createBranch({ /** * @public */ -export async function addFiles({ - dir, - filepath, - auth, - logger, -}: { +export async function addFiles(options: { dir: string; filepath: string; // For use cases where token has to be used with Basic Auth @@ -208,6 +193,7 @@ export async function addFiles({ auth: { username: string; password: string } | { token: string }; logger?: Logger | undefined; }): Promise { + const { dir, filepath, auth, logger } = options; const git = Git.fromAuth({ ...auth, logger, @@ -219,16 +205,7 @@ export async function addFiles({ /** * @public */ -export async function commitAndPushBranch({ - dir, - auth, - logger, - commitMessage, - gitAuthorInfo, - branch = 'master', - remoteRef, - remote = 'origin', -}: { +export async function commitAndPushBranch(options: { dir: string; // For use cases where token has to be used with Basic Auth // it has to be provided as password together with a username @@ -241,6 +218,16 @@ export async function commitAndPushBranch({ remoteRef?: string; remote?: string; }): Promise<{ commitHash: string }> { + const { + dir, + auth, + logger, + commitMessage, + gitAuthorInfo, + branch = 'master', + remoteRef, + remote = 'origin', + } = options; const git = Git.fromAuth({ ...auth, logger,