mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2025-12-27 13:08:17 +00:00
Fix to provide correct previous version when the current commit is tagged.
This commit is contained in:
parent
92bc0a8ba4
commit
ba6e71e658
5 changed files with 32 additions and 4 deletions
2
dist/index.js
vendored
2
dist/index.js
vendored
|
|
@ -745,7 +745,7 @@ class DefaultLastReleaseResolver {
|
||||||
// so that we will have an accurate increment (assuming the new tag is the expected one)
|
// so that we will have an accurate increment (assuming the new tag is the expected one)
|
||||||
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
||||||
tag = yield (0, CommandRunner_1.cmd)(command);
|
tag = yield (0, CommandRunner_1.cmd)(command);
|
||||||
tag = tag.split('\n').at(-1) || '';
|
tag = tag.split('\n').reverse().find(t => t !== '' && t !== currentTag) || '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
||||||
|
|
|
||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -54,7 +54,7 @@ class DefaultLastReleaseResolver {
|
||||||
// so that we will have an accurate increment (assuming the new tag is the expected one)
|
// so that we will have an accurate increment (assuming the new tag is the expected one)
|
||||||
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
||||||
tag = yield (0, CommandRunner_1.cmd)(command);
|
tag = yield (0, CommandRunner_1.cmd)(command);
|
||||||
tag = tag.split('\n').at(-1) || '';
|
tag = tag.split('\n').reverse().find(t => t !== '' && t !== currentTag) || '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,19 @@ test('Tagging does not break version', async () => {
|
||||||
expect(result.formattedVersion).toBe('0.0.1+2');
|
expect(result.formattedVersion).toBe('0.0.1+2');
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
||||||
|
|
||||||
|
test('Tagging does not break version from previous tag', async () => {
|
||||||
|
const repo = createTestRepo(); // 0.0.0+0
|
||||||
|
|
||||||
|
repo.makeCommit('Initial Commit'); // 0.0.1+0
|
||||||
|
repo.exec('git tag v0.0.1')
|
||||||
|
repo.makeCommit(`Second Commit`); // 0.0.2+0
|
||||||
|
repo.makeCommit(`Third Commit`); // 0.0.2+1
|
||||||
|
repo.exec('git tag v0.0.2')
|
||||||
|
const result = await repo.runAction();
|
||||||
|
expect(result.formattedVersion).toBe('0.0.2+1');
|
||||||
|
}, 15000);
|
||||||
|
|
||||||
test('Minor update bumps minor version and resets increment', async () => {
|
test('Minor update bumps minor version and resets increment', async () => {
|
||||||
const repo = createTestRepo(); // 0.0.0+0
|
const repo = createTestRepo(); // 0.0.0+0
|
||||||
|
|
||||||
|
|
@ -640,3 +653,17 @@ test('Correct previous version is returned when using branches', async () => {
|
||||||
expect(result.previousVersion).toBe('2.0.1');
|
expect(result.previousVersion).toBe('2.0.1');
|
||||||
expect(result.formattedVersion).toBe('2.0.2+0');
|
expect(result.formattedVersion).toBe('2.0.2+0');
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
||||||
|
test('Correct previous version is returned when directly tagged', async () => {
|
||||||
|
const repo = createTestRepo();
|
||||||
|
|
||||||
|
repo.makeCommit('Initial Commit');
|
||||||
|
repo.exec('git tag v2.0.1')
|
||||||
|
repo.makeCommit(`Second Commit`);
|
||||||
|
repo.makeCommit(`Third Commit`);
|
||||||
|
repo.exec('git tag v2.0.2')
|
||||||
|
const result = await repo.runAction();
|
||||||
|
|
||||||
|
expect(result.previousVersion).toBe('2.0.1');
|
||||||
|
expect(result.formattedVersion).toBe('2.0.2+1');
|
||||||
|
}, 15000);
|
||||||
|
|
@ -31,7 +31,8 @@ export class DefaultLastReleaseResolver implements LastReleaseResolver {
|
||||||
// so that we will have an accurate increment (assuming the new tag is the expected one)
|
// so that we will have an accurate increment (assuming the new tag is the expected one)
|
||||||
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
||||||
tag = await cmd(command);
|
tag = await cmd(command);
|
||||||
tag = tag.split('\n').at(-1) || '';
|
tag = tag.split('\n').reverse().find(t => t !== '' && t !== currentTag) || '';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
|
||||||
tag = await cmd(command);
|
tag = await cmd(command);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue