mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2025-12-27 04:58:17 +00:00
Merge pull request #104 from PaulHatch/101-previous_version-output-results-in-first-versiontag-and-not-previous-versiontag-when-commit-is-already-tagged
Fix for previous tag logic
This commit is contained in:
commit
d3ce4be042
5 changed files with 55 additions and 5 deletions
1
dist/index.js
vendored
1
dist/index.js
vendored
|
|
@ -764,7 +764,6 @@ class DefaultLastReleaseResolver {
|
|||
tag = yield (0, CommandRunner_1.cmd)(command);
|
||||
tag = tag
|
||||
.split('\n')
|
||||
.reverse()
|
||||
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -58,7 +58,6 @@ class DefaultLastReleaseResolver {
|
|||
tag = yield (0, CommandRunner_1.cmd)(command);
|
||||
tag = tag
|
||||
.split('\n')
|
||||
.reverse()
|
||||
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -635,7 +635,7 @@ test('Correct previous version is returned', async () => {
|
|||
const repo = createTestRepo();
|
||||
|
||||
repo.makeCommit('Initial Commit');
|
||||
repo.exec('git tag v2.0.1')
|
||||
repo.exec('git tag v2.0.1');
|
||||
repo.makeCommit(`Second Commit`);
|
||||
repo.makeCommit(`Third Commit`);
|
||||
const result = await repo.runAction();
|
||||
|
|
@ -644,6 +644,22 @@ test('Correct previous version is returned', async () => {
|
|||
expect(result.previousVersion).toBe('2.0.1');
|
||||
}, timeout);
|
||||
|
||||
test('Correct previous version is returned when multiple tags are present', async () => {
|
||||
const repo = createTestRepo();
|
||||
|
||||
repo.makeCommit('Initial Commit');
|
||||
repo.exec('git tag v1.0.1');
|
||||
repo.makeCommit(`Second Commit`);
|
||||
repo.exec('git tag v2.0.1');
|
||||
repo.makeCommit(`Third Commit`);
|
||||
repo.exec('git tag v3.0.1');
|
||||
repo.makeCommit(`Fourth Commit`);
|
||||
const result = await repo.runAction();
|
||||
|
||||
expect(result.formattedVersion).toBe('3.0.2+0');
|
||||
expect(result.previousVersion).toBe('3.0.1');
|
||||
}, timeout);
|
||||
|
||||
test('Correct previous version is returned when using branches', async () => {
|
||||
const repo = createTestRepo({ tagPrefix: 'release/', useBranches: true });
|
||||
|
||||
|
|
@ -673,6 +689,21 @@ test('Correct previous version is returned when directly tagged', async () => {
|
|||
expect(result.formattedVersion).toBe('2.0.2+1');
|
||||
}, timeout);
|
||||
|
||||
test('Correct previous version is returned when directly tagged with multiple previous tags', async () => {
|
||||
const repo = createTestRepo();
|
||||
|
||||
repo.makeCommit('Initial Commit');
|
||||
repo.exec('git tag v2.0.1')
|
||||
repo.makeCommit(`Second Commit`);
|
||||
repo.exec('git tag v2.0.2')
|
||||
repo.makeCommit(`Third Commit`);
|
||||
repo.exec('git tag v2.0.3')
|
||||
const result = await repo.runAction();
|
||||
|
||||
expect(result.previousVersion).toBe('2.0.2');
|
||||
expect(result.formattedVersion).toBe('2.0.3+0');
|
||||
}, timeout);
|
||||
|
||||
test('Prerelease suffixes are ignored', async () => {
|
||||
const repo = createTestRepo();
|
||||
|
||||
|
|
@ -897,4 +928,26 @@ test('Tagged commit is flagged as release', async () => {
|
|||
result = await repo.runAction();
|
||||
expect(result.formattedVersion).toBe('1.1.0-prerelease.1');
|
||||
expect(result.isTagged).toBe(true);
|
||||
}, timeout);
|
||||
|
||||
|
||||
test('Highest tag is chosen when multiple tags are present', async () => {
|
||||
const repo = createTestRepo();
|
||||
|
||||
repo.makeCommit('Initial Commit');
|
||||
repo.exec('git tag v2.0.0');
|
||||
repo.exec('git tag v1.0.0');
|
||||
repo.exec('git tag v1.5.0');
|
||||
var result = await repo.runAction();
|
||||
expect(result.formattedVersion).toBe('2.0.0+0');
|
||||
|
||||
repo.exec('git tag v3.0.0');
|
||||
repo.exec('git tag v2.1.0');
|
||||
result = await repo.runAction();
|
||||
expect(result.formattedVersion).toBe('3.0.0+0');
|
||||
|
||||
repo.makeCommit('Additional Commit');
|
||||
result = await repo.runAction();
|
||||
expect(result.formattedVersion).toBe('3.0.1+0');
|
||||
|
||||
}, timeout);
|
||||
|
|
@ -37,7 +37,6 @@ export class DefaultLastReleaseResolver implements LastReleaseResolver {
|
|||
tag = await cmd(command);
|
||||
tag = tag
|
||||
.split('\n')
|
||||
.reverse()
|
||||
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
|
||||
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue