Remove incorrect "reverse" on previous tags

This commit is contained in:
Paul Hatcherian 2023-04-07 17:59:35 -10:00
parent f9d3daa396
commit 9a5d07b45d
5 changed files with 55 additions and 5 deletions

1
dist/index.js vendored
View file

@ -764,7 +764,6 @@ class DefaultLastReleaseResolver {
tag = yield (0, CommandRunner_1.cmd)(command); tag = yield (0, CommandRunner_1.cmd)(command);
tag = tag tag = tag
.split('\n') .split('\n')
.reverse()
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || ''; .find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
} }
else { else {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -58,7 +58,6 @@ class DefaultLastReleaseResolver {
tag = yield (0, CommandRunner_1.cmd)(command); tag = yield (0, CommandRunner_1.cmd)(command);
tag = tag tag = tag
.split('\n') .split('\n')
.reverse()
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || ''; .find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
} }
else { else {

View file

@ -635,7 +635,7 @@ test('Correct previous version is returned', async () => {
const repo = createTestRepo(); const repo = createTestRepo();
repo.makeCommit('Initial Commit'); repo.makeCommit('Initial Commit');
repo.exec('git tag v2.0.1') repo.exec('git tag v2.0.1');
repo.makeCommit(`Second Commit`); repo.makeCommit(`Second Commit`);
repo.makeCommit(`Third Commit`); repo.makeCommit(`Third Commit`);
const result = await repo.runAction(); const result = await repo.runAction();
@ -644,6 +644,22 @@ test('Correct previous version is returned', async () => {
expect(result.previousVersion).toBe('2.0.1'); expect(result.previousVersion).toBe('2.0.1');
}, timeout); }, 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 () => { test('Correct previous version is returned when using branches', async () => {
const repo = createTestRepo({ tagPrefix: 'release/', useBranches: true }); 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'); expect(result.formattedVersion).toBe('2.0.2+1');
}, timeout); }, 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 () => { test('Prerelease suffixes are ignored', async () => {
const repo = createTestRepo(); const repo = createTestRepo();
@ -898,3 +929,25 @@ test('Tagged commit is flagged as release', async () => {
expect(result.formattedVersion).toBe('1.1.0-prerelease.1'); expect(result.formattedVersion).toBe('1.1.0-prerelease.1');
expect(result.isTagged).toBe(true); expect(result.isTagged).toBe(true);
}, timeout); }, 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);

View file

@ -37,7 +37,6 @@ export class DefaultLastReleaseResolver implements LastReleaseResolver {
tag = await cmd(command); tag = await cmd(command);
tag = tag tag = tag
.split('\n') .split('\n')
.reverse()
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || ''; .find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
} else { } else {