Skip to content

fix: only call getRecentCommits when needed#105

Open
Zamiell wants to merge 1 commit into
antfu-collective:mainfrom
Zamiell:fix-tag
Open

fix: only call getRecentCommits when needed#105
Zamiell wants to merge 1 commit into
antfu-collective:mainfrom
Zamiell:fix-tag

Conversation

@Zamiell

@Zamiell Zamiell commented Jan 18, 2026

Copy link
Copy Markdown

Previously, getRecentCommits() was called unconditionally in both
versionBump() and versionBumpInfo(). This caused issues in repositories
with no git tags because the underlying git describe command would fail
with "fatal: No names found, cannot describe anything."

This change makes getRecentCommits() only be called when commits are
actually needed:

  • When printCommits is enabled
  • When release type is 'prompt' (user needs to see version options)
  • When release type is 'conventional' (need to determine semver change)

For explicit release types like 'major', 'minor', 'patch', 'prerelease',
etc., commits are not needed and the git describe call is now skipped.

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Previously, getRecentCommits() was called unconditionally in both
versionBump() and versionBumpInfo(). This caused issues in repositories
with no git tags because the underlying git describe command would fail
with "fatal: No names found, cannot describe anything."

This change makes getRecentCommits() only be called when commits are
actually needed:
- When printCommits is enabled
- When release type is 'prompt' (user needs to see version options)
- When release type is 'conventional' (need to determine semver change)

For explicit release types like 'major', 'minor', 'patch', 'prerelease',
etc., commits are not needed and the git describe call is now skipped.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread src/version-bump.ts
Comment on lines +181 to +183
const needsCommits = operation.options.printCommits
|| operation.options.release.type === 'prompt'
|| operation.options.release.type === 'conventional'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am afraid this would be coupled with the implementation located at the other places and might be hard to maintain or cause bugs. How about passing a cache getter so we only get the commits on-demand?

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.

2 participants