Skip to content

fix: use the only existing tag as predecessor for a newer release - #1688

Merged
mikepenz merged 4 commits into
mikepenz:developfrom
sarankumar1325:fix/single-tag-predecessor
Oct 30, 2026
Merged

mikepenz merged 4 commits into
mikepenz:developfrom
sarankumar1325:fix/single-tag-predecessor

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes #1683

Problem

When exactly one tag exists, findPredecessorTag always 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 example toTag: ${{ 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 toTag isn't in the list, the loop falls through and tags[0] (the latest tag) is returned.

Change

  • In 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.
  • If the single tag is the current release, or there are no tags, the action still falls back to the initial commit as before.
  • Rebuilt dist/ with npm run package.

Tests

  • Added two cases to __tests__/tags.test.ts: one where the single tag differs from toTag (it is returned as the predecessor), and one where it matches toTag by 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 passed
  • npm run build, eslint src/pr-collector/tags.ts and prettier --check all clean

AI disclosure: I made this change with help from an AI coding assistant, then reviewed and tested it myself.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 09:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 10:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

sarankumar1325 and others added 3 commits October 30, 2026 11:26
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
mikepenz force-pushed the fix/single-tag-predecessor branch from e799cd5 to 6ffac6f Compare October 30, 2026 10:35
Copilot AI balanced review requested due to automatic review settings October 30, 2026 10:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.
Copilot AI balanced review requested due to automatic review settings October 30, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@mikepenz
mikepenz merged commit eb419df into mikepenz:develop Oct 30, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Second release resolves fromTag to root when only one previous tag exists

3 participants