Merge pull request #9859 from shvmbisht/add-default-commit-msg
Added default commit message
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Override default commit message and author details in GitLab action
|
||||
@@ -266,6 +266,9 @@ export function createPublishGitlabAction(options: {
|
||||
repoVisibility?: 'internal' | 'private' | 'public' | undefined;
|
||||
sourcePath?: string | undefined;
|
||||
token?: string | undefined;
|
||||
gitCommitMessage?: string | undefined;
|
||||
gitAuthorName?: string | undefined;
|
||||
gitAuthorEmail?: string | undefined;
|
||||
}>;
|
||||
|
||||
// @public
|
||||
|
||||
@@ -181,6 +181,7 @@ describe('publish:gitlab', () => {
|
||||
remoteUrl: 'http://mockurl.git',
|
||||
auth: { username: 'oauth2', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
gitAuthorInfo: {},
|
||||
});
|
||||
});
|
||||
@@ -205,6 +206,7 @@ describe('publish:gitlab', () => {
|
||||
remoteUrl: 'http://mockurl.git',
|
||||
auth: { username: 'oauth2', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
gitAuthorInfo: {},
|
||||
});
|
||||
});
|
||||
@@ -252,6 +254,7 @@ describe('publish:gitlab', () => {
|
||||
auth: { username: 'oauth2', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
commitMessage: 'initial commit',
|
||||
gitAuthorInfo: { name: 'Test', email: 'example@example.com' },
|
||||
});
|
||||
});
|
||||
@@ -294,10 +297,10 @@ describe('publish:gitlab', () => {
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'http://mockurl.git',
|
||||
auth: { username: 'oauth2', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
commitMessage: 'Test commit message',
|
||||
commitMessage: 'initial commit',
|
||||
gitAuthorInfo: { email: undefined, name: undefined },
|
||||
logger: mockContext.logger,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ export function createPublishGitlabAction(options: {
|
||||
repoVisibility?: 'private' | 'internal' | 'public';
|
||||
sourcePath?: string;
|
||||
token?: string;
|
||||
gitCommitMessage?: string;
|
||||
gitAuthorName?: string;
|
||||
gitAuthorEmail?: string;
|
||||
}>({
|
||||
id: 'publish:gitlab',
|
||||
description:
|
||||
@@ -63,6 +66,21 @@ export function createPublishGitlabAction(options: {
|
||||
type: 'string',
|
||||
description: `Sets the default branch on the repository. The default value is 'master'`,
|
||||
},
|
||||
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.`,
|
||||
},
|
||||
sourcePath: {
|
||||
title: 'Source Path',
|
||||
description:
|
||||
@@ -95,8 +113,10 @@ export function createPublishGitlabAction(options: {
|
||||
repoUrl,
|
||||
repoVisibility = 'private',
|
||||
defaultBranch = 'master',
|
||||
gitCommitMessage = 'initial commit',
|
||||
gitAuthorName,
|
||||
gitAuthorEmail,
|
||||
} = ctx.input;
|
||||
|
||||
const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
@@ -146,10 +166,13 @@ export function createPublishGitlabAction(options: {
|
||||
const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;
|
||||
|
||||
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'),
|
||||
};
|
||||
|
||||
await initRepoAndPush({
|
||||
dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
|
||||
remoteUrl: http_url_to_repo as string,
|
||||
@@ -159,9 +182,9 @@ export function createPublishGitlabAction(options: {
|
||||
password: token,
|
||||
},
|
||||
logger: ctx.logger,
|
||||
commitMessage: config.getOptionalString(
|
||||
'scaffolder.defaultCommitMessage',
|
||||
),
|
||||
commitMessage: gitCommitMessage
|
||||
? gitCommitMessage
|
||||
: config.getOptionalString('scaffolder.defaultCommitMessage'),
|
||||
gitAuthorInfo,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user