feat:add default branch prop for publish:bitbucket action

Signed-off-by: shoukoo <shoukoo.koike@gmail.com>
This commit is contained in:
shoukoo
2021-07-04 08:52:48 +10:00
parent 76fc5e29c9
commit 330f2ac32d
2 changed files with 51 additions and 0 deletions
@@ -286,6 +286,49 @@ describe('publish:bitbucket', () => {
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: mockContext.workspacePath,
remoteUrl: 'https://bitbucket.org/owner/cloneurl',
defaultBranch: 'master',
auth: { username: 'x-token-auth', password: 'tokenlols' },
logger: mockContext.logger,
});
});
it('should call initAndPush with the correct default branch', async () => {
server.use(
rest.post(
'https://api.bitbucket.org/2.0/repositories/owner/repo',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.set('Content-Type', 'application/json'),
ctx.json({
links: {
html: {
href: 'https://bitbucket.org/owner/repo',
},
clone: [
{
name: 'https',
href: 'https://bitbucket.org/owner/cloneurl',
},
],
},
}),
),
),
);
await action.handler({
...mockContext,
input: {
...mockContext.input,
defaultBranch: 'main',
},
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: mockContext.workspacePath,
remoteUrl: 'https://bitbucket.org/owner/cloneurl',
defaultBranch: 'main',
auth: { username: 'x-token-auth', password: 'tokenlols' },
logger: mockContext.logger,
});
@@ -190,6 +190,7 @@ export function createPublishBitbucketAction(options: {
return createTemplateAction<{
repoUrl: string;
description: string;
defaultBranch?: string;
repoVisibility: 'private' | 'public';
sourcePath?: string;
enableLFS: boolean;
@@ -215,6 +216,11 @@ export function createPublishBitbucketAction(options: {
type: 'string',
enum: ['private', 'public'],
},
defaultBranch: {
title: 'Default Branch',
type: 'string',
description: `Sets the default branch on the repository. The default value is 'master'`,
},
sourcePath: {
title:
'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',
@@ -245,6 +251,7 @@ export function createPublishBitbucketAction(options: {
const {
repoUrl,
description,
defaultBranch = 'master',
repoVisibility = 'private',
enableLFS = false,
} = ctx.input;
@@ -288,6 +295,7 @@ export function createPublishBitbucketAction(options: {
? integrationConfig.config.appPassword
: integrationConfig.config.token ?? '',
},
defaultBranch,
logger: ctx.logger,
});