Repository navigation
fix: use the only existing tag as predecessor for a newer release - #1688
Merged
mikepenz merged 4 commits intoOct 30, 2026
Merged
Conversation
When only one tag exists and the release being built is not that tag (for example `toTag` is the commit sha of the upcoming release), the single tag is the previous release. Previously the action always fell back to the repository's initial commit, repeating the full history. Fixes mikepenz#1683
…e cases - match tags by name, commit or abbreviated sha in every branch - skip pre-releases for single/unmatched tags when ignorePreReleases is set - fall back to the initial commit when no earlier tag exists - mock git in tests, add retrieveRange coverage
mikepenz
force-pushed
the
fix/single-tag-predecessor
branch
from
October 30, 2026 10:35
e799cd5 to
6ffac6f
Compare
The matched tag being the oldest of several is ambiguous (first release or a list truncated by max_tags_to_fetch). Return null as before, so the build reports 'Unable to retrieve previous tag', and log a warning pointing at fromTag and max_tags_to_fetch. A matched tag with only older pre-releases keeps using the next tag as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1683
Problem
When exactly one tag exists,
findPredecessorTagalways fell back to the repository's initial commit. That is right for the first release, where the single tag is the release being built. But for the second release built before it's tagged (for exampletoTag: ${{ github.sha }}), the single existing tag is the previous release. Falling back to the root commit made the changelog repeat the whole history.With two or more tags this case already worked: when
toTagisn't in the list, the loop falls through andtags[0](the latest tag) is returned.Change
src/pr-collector/tags.ts, if there is one tag and it is not the current tag (compared by name or by commit sha, case-insensitive), return that tag as the predecessor.dist/withnpm run package.Tests
__tests__/tags.test.ts: one where the single tag differs fromtoTag(it is returned as the predecessor), and one where it matchestoTagby name or by commit (falls back to the initial commit). The first case fails without the fix.npx vitest --run __tests__/tags.test.ts __tests__/offline/ __tests__/gitHelper.test.ts: 13 passednpm run build,eslint src/pr-collector/tags.tsandprettier --checkall cleanAI disclosure: I made this change with help from an AI coding assistant, then reviewed and tested it myself.