feat:add default branch prop for publish:azure action

Signed-off-by: shoukoo <shoukoo.koike@gmail.com>
This commit is contained in:
shoukoo
2021-07-04 08:59:14 +10:00
parent 330f2ac32d
commit 73195b6e65
2 changed files with 33 additions and 3 deletions
@@ -162,6 +162,29 @@ describe('publish:azure', () => {
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: mockContext.workspacePath,
remoteUrl: 'https://dev.azure.com/organization/project/_git/repo',
defaultBranch: 'master',
auth: { username: 'notempty', password: 'tokenlols' },
logger: mockContext.logger,
});
});
it('should call initRepoAndPush with the correct default branch', async () => {
mockGitClient.createRepository.mockImplementation(() => ({
remoteUrl: 'https://dev.azure.com/organization/project/_git/repo',
}));
await action.handler({
...mockContext,
input: {
...mockContext.input,
defaultBranch: 'main',
},
});
expect(initRepoAndPush).toHaveBeenCalledWith({
dir: mockContext.workspacePath,
remoteUrl: 'https://dev.azure.com/organization/project/_git/repo',
defaultBranch: 'master',
auth: { username: 'notempty', password: 'tokenlols' },
logger: mockContext.logger,
});
@@ -30,6 +30,7 @@ export function createPublishAzureAction(options: {
return createTemplateAction<{
repoUrl: string;
description?: string;
defaultBranch?: string;
sourcePath?: string;
}>({
id: 'publish:azure',
@@ -48,6 +49,11 @@ export function createPublishAzureAction(options: {
title: 'Repository Description',
type: 'string',
},
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.',
@@ -70,9 +76,9 @@ export function createPublishAzureAction(options: {
},
},
async handler(ctx) {
const { owner, repo, host, organization } = parseRepoUrl(
ctx.input.repoUrl,
);
const { repoUrl, defaultBranch = 'master' } = ctx.input;
const { owner, repo, host, organization } = parseRepoUrl(repoUrl);
if (!organization) {
throw new InputError(
@@ -120,6 +126,7 @@ export function createPublishAzureAction(options: {
await initRepoAndPush({
dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
remoteUrl,
defaultBranch,
auth: {
username: 'notempty',
password: integrationConfig.config.token,