From 72d6b9f4e2a62e29024e6cbf52b83413fe63f54b Mon Sep 17 00:00:00 2001 From: Maurice Mohlek Date: Fri, 13 Jan 2023 13:31:18 +0100 Subject: [PATCH 1/6] default commit msgs for bitbucketServer Signed-off-by: Maurice Mohlek --- .changeset/red-pens-tickle.md | 5 +++ .../builtin/publish/bitbucketServer.ts | 35 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 .changeset/red-pens-tickle.md diff --git a/.changeset/red-pens-tickle.md b/.changeset/red-pens-tickle.md new file mode 100644 index 0000000000..2a09f6c7e6 --- /dev/null +++ b/.changeset/red-pens-tickle.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Override default commit message and author details in BitbucketServer diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts index d0cde4ad31..eec9587365 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts @@ -130,6 +130,9 @@ export function createPublishBitbucketServerAction(options: { sourcePath?: string; enableLFS?: boolean; token?: string; + gitCommitMessage?: string; + gitAuthorName?: string; + gitAuthorEmail?: string; }>({ id: 'publish:bitbucketServer', description: @@ -174,6 +177,21 @@ export function createPublishBitbucketServerAction(options: { description: 'The token to use for authorization to BitBucket Server', }, + gitCommitMessage: { + title: 'Git Commit Message', + type: 'string', + description: `Sets the commit message on the repository. The default value is 'initial commit'`, + }, + gitAuthorName: { + title: 'Default Author Name', + type: 'string', + description: `Sets the default author name for the commit. The default value is 'Scaffolder'`, + }, + gitAuthorEmail: { + title: 'Default Author Email', + type: 'string', + description: `Sets the default author email for the commit.`, + }, }, }, output: { @@ -197,6 +215,9 @@ export function createPublishBitbucketServerAction(options: { defaultBranch = 'master', repoVisibility = 'private', enableLFS = false, + gitCommitMessage = 'initial commit', + gitAuthorName, + gitAuthorEmail, } = ctx.input; const { project, repo, host } = parseRepoUrl(repoUrl, integrations); @@ -241,8 +262,12 @@ export function createPublishBitbucketServerAction(options: { }); const gitAuthorInfo = { - name: config.getOptionalString('scaffolder.defaultAuthor.name'), - email: config.getOptionalString('scaffolder.defaultAuthor.email'), + name: gitAuthorName + ? gitAuthorName + : config.getOptionalString('scaffolder.defaultAuthor.name'), + email: gitAuthorEmail + ? gitAuthorEmail + : config.getOptionalString('scaffolder.defaultAuthor.email'), }; const auth = authConfig.token @@ -260,9 +285,9 @@ export function createPublishBitbucketServerAction(options: { auth, defaultBranch, logger: ctx.logger, - commitMessage: config.getOptionalString( - 'scaffolder.defaultCommitMessage', - ), + commitMessage: gitCommitMessage + ? gitCommitMessage + : config.getOptionalString('scaffolder.defaultCommitMessage'), gitAuthorInfo, }); From da8e11460e0b3c60f077515ea03d2c6a54968790 Mon Sep 17 00:00:00 2001 From: Maurice Mohlek Date: Fri, 13 Jan 2023 15:19:24 +0100 Subject: [PATCH 2/6] Update plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts Co-authored-by: Johan Haals Signed-off-by: Maurice Mohlek --- .../scaffolder/actions/builtin/publish/bitbucketServer.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts index eec9587365..8c96c14463 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts @@ -183,14 +183,14 @@ export function createPublishBitbucketServerAction(options: { description: `Sets the commit message on the repository. The default value is 'initial commit'`, }, gitAuthorName: { - title: 'Default Author Name', + title: 'Author Name', type: 'string', - description: `Sets the default author name for the commit. The default value is 'Scaffolder'`, + description: `Sets the author name for the commit. The default value is 'Scaffolder'`, }, gitAuthorEmail: { - title: 'Default Author Email', + title: 'Author Email', type: 'string', - description: `Sets the default author email for the commit.`, + description: `Sets the author email for the commit.`, }, }, }, From 9506adea4db69ebfcfce74c060070f105c71b757 Mon Sep 17 00:00:00 2001 From: Maurice Mohlek Date: Fri, 13 Jan 2023 15:19:30 +0100 Subject: [PATCH 3/6] Update .changeset/red-pens-tickle.md Co-authored-by: Johan Haals Signed-off-by: Maurice Mohlek --- .changeset/red-pens-tickle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/red-pens-tickle.md b/.changeset/red-pens-tickle.md index 2a09f6c7e6..03f509991e 100644 --- a/.changeset/red-pens-tickle.md +++ b/.changeset/red-pens-tickle.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend': patch --- -Override default commit message and author details in BitbucketServer +Added ability to override the commit message and author details for the `publish:bitbucketServer` action. From ffe1455cae8ba0d0088124e139eb1738cf0fa5f9 Mon Sep 17 00:00:00 2001 From: Maurice Mohlek Date: Fri, 13 Jan 2023 15:52:46 +0100 Subject: [PATCH 4/6] cleaning up failing tests Signed-off-by: Maurice Mohlek --- .../builtin/publish/bitbucketServer.test.ts | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts index 52f445098b..6b4fa3d781 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts @@ -375,7 +375,11 @@ describe('publish:bitbucketServer', () => { defaultBranch: 'master', auth: { token: 'thing' }, logger: mockContext.logger, - gitAuthorInfo: {}, + commitMessage: 'initial commit', + gitAuthorInfo: { + email: undefined, + name: undefined, + }, }); }); @@ -429,7 +433,11 @@ describe('publish:bitbucketServer', () => { defaultBranch: 'master', auth: { username: 'test-user', password: 'test-password' }, logger: mockContext.logger, - gitAuthorInfo: {}, + commitMessage: 'initial commit', + gitAuthorInfo: { + email: undefined, + name: undefined, + }, }); }); @@ -481,7 +489,11 @@ describe('publish:bitbucketServer', () => { defaultBranch: 'main', auth: { token: 'thing' }, logger: mockContext.logger, - gitAuthorInfo: {}, + commitMessage: 'initial commit', + gitAuthorInfo: { + email: undefined, + name: undefined, + }, }); }); @@ -555,6 +567,7 @@ describe('publish:bitbucketServer', () => { auth: { token: 'thing' }, logger: mockContext.logger, defaultBranch: 'master', + commitMessage: 'initial commit', gitAuthorInfo: { name: 'Test', email: 'example@example.com' }, }); }); @@ -574,7 +587,7 @@ describe('publish:bitbucketServer', () => { ], }, scaffolder: { - defaultCommitMessage: 'Test commit message', + defaultCommitMessage: 'initial commit', }, }); @@ -626,7 +639,7 @@ describe('publish:bitbucketServer', () => { auth: { token: 'thing' }, logger: mockContext.logger, defaultBranch: 'master', - commitMessage: 'Test commit message', + commitMessage: 'initial commit', gitAuthorInfo: { email: undefined, name: undefined }, }); }); From fe9eaf93dbb0fd28ff370d8a66c1b4bda4ec9a62 Mon Sep 17 00:00:00 2001 From: Maurice Mohlek Date: Fri, 13 Jan 2023 16:03:44 +0100 Subject: [PATCH 5/6] fix: generate api-report.md Signed-off-by: Maurice Mohlek --- plugins/scaffolder-backend/api-report.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index c89ead6d2b..59d7622772 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -341,6 +341,9 @@ export function createPublishBitbucketServerAction(options: { sourcePath?: string | undefined; enableLFS?: boolean | undefined; token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; }>; // @public From 4cab7905d876756358ad6e4d8ca7cd23547399b2 Mon Sep 17 00:00:00 2001 From: Maurice Mohlek Date: Mon, 16 Jan 2023 10:31:23 +0100 Subject: [PATCH 6/6] Update .changeset/red-pens-tickle.md Co-authored-by: Johan Haals Signed-off-by: Maurice Mohlek --- .changeset/red-pens-tickle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/red-pens-tickle.md b/.changeset/red-pens-tickle.md index 03f509991e..110f186d25 100644 --- a/.changeset/red-pens-tickle.md +++ b/.changeset/red-pens-tickle.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-scaffolder-backend': patch +'@backstage/plugin-scaffolder-backend': minor --- Added ability to override the commit message and author details for the `publish:bitbucketServer` action.