Skip to content

Commit

Permalink
(mathieudutour#145) formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-hartmond-mw committed Apr 21, 2023
1 parent 32ca813 commit e1d672d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default async function main() {
const defaultPreReleaseBump = core.getInput('default_prerelease_bump') as
| ReleaseType
| 'false';
const defaultDraftBump = core.getInput('default_draft_bump') as ReleaseType | 'false' || defaultPreReleaseBump;
const defaultDraftBump =
(core.getInput('default_draft_bump') as ReleaseType | 'false') ||
defaultPreReleaseBump;
const tagPrefix = core.getInput('tag_prefix');
const customTag = core.getInput('custom_tag');
const releaseBranches = core.getInput('release_branches');
Expand Down Expand Up @@ -162,8 +164,7 @@ export default async function main() {
if (!previousWasPrerelease)
// previous version is a prerelease -> draft a new version with the default bump and make it a prerelease
bump = defaultDraftBump;
else
bump = defaultPreReleaseBump;
else bump = defaultPreReleaseBump;
}

// TODO: these next 10 lines are horrible!! why we have preminor as bump type at all if it is always striped away?
Expand Down
24 changes: 12 additions & 12 deletions tests/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ describe('github-tag-action', () => {
beforeEach(() => {
jest.clearAllMocks();
setBranch('prerelease');
loadDefaultInputs();
loadDefaultInputs();
setInput('pre_release_branches', 'prerelease');
});

Expand Down Expand Up @@ -669,7 +669,7 @@ describe('github-tag-action', () => {
});

/**
* 1.2.3 commit =[minor, -, prerelease]=> 1.2.4-pre.0
* 1.2.3 commit =[minor, -, prerelease]=> 1.2.4-pre.0
* according to semver, a prerelease increment on a non-prerelease version drafts a new minor version
*/
it('default_draft_bump defaults to default_prerelease_bump (prerelease)', async () => {
Expand Down Expand Up @@ -705,21 +705,21 @@ describe('github-tag-action', () => {
* Then
*/
expect(mockCreateTag).toHaveBeenCalledWith(
'v1.2.4-prerelease.0', // prerelease drafts patch upgrades
'v1.2.4-prerelease.0', // prerelease drafts patch upgrades
expect.any(Boolean),
expect.any(String)
);
expect(mockSetFailed).not.toBeCalled();
});

/**
* 1.2.3 commit =[minor, -, prerelease]=> 1.2.4-pre.0
* 1.2.3 commit =[minor, -, prerelease]=> 1.2.4-pre.0
* according to semver, a prerelease increment on a non-prerelease version drafts a new minor version
*/
it('default_draft_bump defaults to default_prerelease_bump (preminor)', async () => {
/*
* Given
*/
* Given
*/
const commits = [{ message: 'this is a commit', hash: null }];
jest
.spyOn(utils, 'getCommits')
Expand All @@ -739,23 +739,23 @@ describe('github-tag-action', () => {
.mockImplementation(async () => validTags);

/*
* When
*/
* When
*/
setInput('default_bump', 'minor');
setInput('default_prerelease_bump', 'preminor');
await action();

/*
* Then
*/
* Then
*/
expect(mockCreateTag).toHaveBeenCalledWith(
'v1.3.0-prerelease.0', // prerelease drafts patch upgrades
'v1.3.0-prerelease.0', // prerelease drafts patch upgrades
expect.any(Boolean),
expect.any(String)
);
expect(mockSetFailed).not.toBeCalled();
});

it('does create prepatch tag', async () => {
/*
* Given
Expand Down
4 changes: 2 additions & 2 deletions tests/helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export function setInputs(map: { [key: string]: string }) {

export function resetInputs(map: { [key: string]: string }) {
Object.keys(process.env)
.filter(k => k.startsWith("INPUT_"))
.forEach(k => delete process.env[k]);
.filter((k) => k.startsWith('INPUT_'))
.forEach((k) => delete process.env[k]);
Object.keys(map).forEach((key) => setInput(key, map[key]));
}

Expand Down

0 comments on commit e1d672d

Please sign in to comment.