Skip to content

Commit

Permalink
Allow empty tag prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHatch committed Dec 12, 2019
1 parent 118c3fd commit 8af45c2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
default: "master"
tag_prefix:
description: "The prefix to use to identify tags"
required: true
required: false
default: "v"
major_pattern:
description: "a string which, if present in a git commit, indicates that a change represents a major (breaking) change"
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ async function run() {
const remoteExists = remote !== '';
const remotePrefix = remoteExists ? 'origin/' : '';

const tagPrefix = core.getInput('tag_prefix', { required: true });
const tagPrefix = core.getInput('tag_prefix') || '';
const branch = `${remotePrefix}${core.getInput('branch', { required: true })}`;
const majorPattern = core.getInput('major_pattern', { required: true });
const minorPattern = core.getInput('minor_pattern', { required: true });
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function run() {
const remoteExists = remote !== '';
const remotePrefix = remoteExists ? 'origin/' : '';

const tagPrefix = core.getInput('tag_prefix', { required: true });
const tagPrefix = core.getInput('tag_prefix') || '';
const branch = `${remotePrefix}${core.getInput('branch', { required: true })}`;
const majorPattern = core.getInput('major_pattern', { required: true });
const minorPattern = core.getInput('minor_pattern', { required: true });
Expand Down
15 changes: 14 additions & 1 deletion index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,17 @@ test('Format input is respected', () => {
expect(result).toMatch('M1m2p4i0');

repo.clean();
})
});

test('Version prefixes are not required/can be empty', () => {
const repo = createTestRepo({ tag_prefix: '' }); // 0.0.0

repo.makeCommit('Initial Commit'); // 0.0.1
repo.exec('git tag 0.0.1');
repo.makeCommit(`Second Commit`); // 0.0.2
const result = repo.runAction();

expect(result).toMatch('Version is 0.0.2');

repo.clean();
});

0 comments on commit 8af45c2

Please sign in to comment.