Skip to content

Refactor plugin version lookup to use afero and fix shadowing bug in Run#1555

Merged
vzhang-stripe merged 1 commit intomasterfrom
vzhang-local-version-prefered
Apr 20, 2026
Merged

Refactor plugin version lookup to use afero and fix shadowing bug in Run#1555
vzhang-stripe merged 1 commit intomasterfrom
vzhang-local-version-prefered

Conversation

@vzhang-stripe
Copy link
Copy Markdown
Contributor

@vzhang-stripe vzhang-stripe commented Apr 20, 2026

It's annoying to run the local.build.dev version when developing a plugin, update the CLI version preference to always run the local version

What

  • Extracts "local.build.dev" into a localDevelopmentVersion constant
  • Introduces lookUpInstalledVersion() method that checks for a local dev build first, then falls back to a semver glob — using afero.Fs instead of filepath.Glob so it's testable
  • Adds isLocalDevelopmentVersion() predicate and uses it to skip checksum verification for local dev builds in both verifyChecksum and Run
  • Fixes a variable shadowing bug in Run where := inside the else block created a new inner version, leaving the outer variable empty and causing getPluginInstallPath / getChecksum to
    receive "" for all non-dev plugin invocations

No regression for production users

Regular users never have a local.build.dev directory, so lookUpInstalledVersion always falls through to the semver glob. afero.OsFs wraps the real filesystem, so behavior is identical to the
previous filepath.Glob call. The checksum skip only fires for the local.build.dev version string.

Tests

  • TestVerifyChecksumSkipsLocalDevelopmentVersion — checksum is skipped for local dev builds
  • TestLookUpInstalledVersionPrefersLocalDevelopmentVersion — local dev dir takes priority over an installed release
  • TestLookUpInstalledVersionFallsBackToInstalledRelease — falls back to semver glob when no local dev build exists

Extracts lookUpInstalledVersion() using afero.Fs for testability, adds
isLocalDevelopmentVersion() helper, skips checksum verification for local
dev builds, and fixes a variable shadowing bug where :=  inside the else
branch left the outer version empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@vzhang-stripe vzhang-stripe requested a review from a team as a code owner April 20, 2026 21:54
Copy link
Copy Markdown
Collaborator

@vcheung-stripe vcheung-stripe left a comment

Choose a reason for hiding this comment

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

Nice!

@vzhang-stripe vzhang-stripe merged commit 11b7276 into master Apr 20, 2026
37 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.

2 participants