default commit msgs of rest providers

Signed-off-by: Shivam bisht <shvmbisht@gmail.com>
This commit is contained in:
Shivam bisht
2022-04-19 14:27:21 +05:30
parent b9f7ffb162
commit b031b2ca09
6 changed files with 106 additions and 19 deletions
@@ -192,6 +192,7 @@ describe('publish:azure', () => {
defaultBranch: 'master',
auth: { username: 'notempty', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: {},
});
});
@@ -215,6 +216,7 @@ describe('publish:azure', () => {
defaultBranch: 'master',
auth: { username: 'notempty', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: {},
});
});
@@ -254,6 +256,7 @@ describe('publish:azure', () => {
auth: { username: 'notempty', password: 'tokenlols' },
logger: mockContext.logger,
defaultBranch: 'master',
commitMessage: 'initial commit',
gitAuthorInfo: { name: 'Test', email: 'example@example.com' },
});
});
@@ -290,7 +293,7 @@ describe('publish:azure', () => {
auth: { username: 'notempty', password: 'tokenlols' },
logger: mockContext.logger,
defaultBranch: 'master',
commitMessage: 'Test commit message',
commitMessage: 'initial commit',
gitAuthorInfo: { email: undefined, name: undefined },
});
});
@@ -40,6 +40,9 @@ export function createPublishAzureAction(options: {
defaultBranch?: string;
sourcePath?: string;
token?: string;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
}>({
id: 'publish:azure',
description:
@@ -62,6 +65,21 @@ export function createPublishAzureAction(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:
@@ -90,7 +108,13 @@ export function createPublishAzureAction(options: {
},
},
async handler(ctx) {
const { repoUrl, defaultBranch = 'master' } = ctx.input;
const {
repoUrl,
defaultBranch = 'master',
gitCommitMessage = 'initial commit',
gitAuthorName,
gitAuthorEmail,
} = ctx.input;
const { owner, repo, host, organization } = parseRepoUrl(
repoUrl,
@@ -142,8 +166,12 @@ export function createPublishAzureAction(options: {
const repoContentsUrl = remoteUrl;
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({
@@ -155,9 +183,9 @@ export function createPublishAzureAction(options: {
password: token,
},
logger: ctx.logger,
commitMessage: config.getOptionalString(
'scaffolder.defaultCommitMessage',
),
commitMessage: gitCommitMessage
? gitCommitMessage
: config.getOptionalString('scaffolder.defaultCommitMessage'),
gitAuthorInfo,
});
@@ -348,6 +348,7 @@ describe('publish:bitbucket', () => {
defaultBranch: 'master',
auth: { username: 'x-token-auth', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: {},
});
});
@@ -391,6 +392,7 @@ describe('publish:bitbucket', () => {
defaultBranch: 'main',
auth: { username: 'x-token-auth', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: {},
});
});
@@ -460,6 +462,7 @@ describe('publish:bitbucket', () => {
auth: { username: 'x-token-auth', password: 'tokenlols' },
logger: mockContext.logger,
defaultBranch: 'master',
commitMessage: 'initial commit',
gitAuthorInfo: { name: 'Test', email: 'example@example.com' },
});
});
@@ -526,7 +529,7 @@ describe('publish:bitbucket', () => {
auth: { username: 'x-token-auth', password: 'tokenlols' },
logger: mockContext.logger,
defaultBranch: 'master',
commitMessage: 'Test commit message',
commitMessage: 'initial commit',
gitAuthorInfo: { email: undefined, name: undefined },
});
});
@@ -213,6 +213,9 @@ export function createPublishBitbucketAction(options: {
sourcePath?: string;
enableLFS?: boolean;
token?: string;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
}>({
id: 'publish:bitbucket',
description:
@@ -257,6 +260,21 @@ export function createPublishBitbucketAction(options: {
type: 'string',
description: 'The token to use for authorization to BitBucket',
},
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: {
@@ -280,6 +298,9 @@ export function createPublishBitbucketAction(options: {
defaultBranch = 'master',
repoVisibility = 'private',
enableLFS = false,
gitCommitMessage = 'initial commit',
gitAuthorName,
gitAuthorEmail,
} = ctx.input;
const { workspace, project, repo, host } = parseRepoUrl(
@@ -340,8 +361,12 @@ export function createPublishBitbucketAction(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'),
};
let auth;
@@ -368,9 +393,9 @@ export function createPublishBitbucketAction(options: {
auth,
defaultBranch,
logger: ctx.logger,
commitMessage: config.getOptionalString(
'scaffolder.defaultCommitMessage',
),
commitMessage: gitCommitMessage
? gitCommitMessage
: config.getOptionalString('scaffolder.defaultCommitMessage'),
gitAuthorInfo,
});
@@ -198,6 +198,7 @@ describe('publish:github', () => {
defaultBranch: 'master',
auth: { username: 'x-access-token', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: {},
});
});
@@ -228,6 +229,7 @@ describe('publish:github', () => {
defaultBranch: 'main',
auth: { username: 'x-access-token', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: {},
});
});
@@ -275,6 +277,7 @@ describe('publish:github', () => {
defaultBranch: 'master',
auth: { username: 'x-access-token', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'initial commit',
gitAuthorInfo: { name: 'Test', email: 'example@example.com' },
});
});
@@ -319,7 +322,7 @@ describe('publish:github', () => {
defaultBranch: 'master',
auth: { username: 'x-access-token', password: 'tokenlols' },
logger: mockContext.logger,
commitMessage: 'Test commit message',
commitMessage: 'initial commit',
gitAuthorInfo: { email: undefined, name: undefined },
});
});
@@ -47,6 +47,9 @@ export function createPublishGithubAction(options: {
access?: string;
defaultBranch?: string;
deleteBranchOnMerge?: boolean;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
allowRebaseMerge?: boolean;
allowSquashMerge?: boolean;
allowMergeCommit?: boolean;
@@ -103,6 +106,21 @@ export function createPublishGithubAction(options: {
type: 'boolean',
description: `Delete the branch after merging the PR. The default value is 'false'`,
},
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.`,
},
allowMergeCommit: {
title: 'Allow Merge Commits',
type: 'boolean',
@@ -181,6 +199,9 @@ export function createPublishGithubAction(options: {
repoVisibility = 'private',
defaultBranch = 'master',
deleteBranchOnMerge = false,
gitCommitMessage = 'initial commit',
gitAuthorName,
gitAuthorEmail,
allowMergeCommit = true,
allowSquashMerge = true,
allowRebaseMerge = true,
@@ -290,8 +311,12 @@ export function createPublishGithubAction(options: {
const repoContentsUrl = `${newRepo.html_url}/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({
@@ -303,9 +328,9 @@ export function createPublishGithubAction(options: {
password: octokitOptions.auth,
},
logger: ctx.logger,
commitMessage: config.getOptionalString(
'scaffolder.defaultCommitMessage',
),
commitMessage: gitCommitMessage
? gitCommitMessage
: config.getOptionalString('scaffolder.defaultCommitMessage'),
gitAuthorInfo,
});