Fix update/revert loop when .luca-version is present#59
Merged
albertodebortoli merged 2 commits intomainfrom Apr 10, 2026
Merged
Fix update/revert loop when .luca-version is present#59albertodebortoli merged 2 commits intomainfrom
albertodebortoli merged 2 commits intomainfrom
Conversation
Before this fix, `updateToLatest` would install the latest GitHub release but leave `.luca-version` unchanged. On the next invocation `updateIfNeeded` (which runs before every command) would see the stale pin, downgrade back to the pinned version, and a subsequent `luca update` would upgrade again — creating an update/revert loop across repeated runs. Write the newly installed version into `.luca-version` when the file already exists so the pin stays in sync. When no `.luca-version` is present, behaviour is unchanged.
The update command fetches the latest release itself, so running updateIfNeeded beforehand is wasteful — it would install the .luca-version pin only for updateToLatest to overwrite it moments later. After the update, write the new version into .luca-version (when the file exists) so the pin stays in sync. Before this fix, running luca update with a .luca-version pin older than the latest release would produce two consecutive downloads: first updateIfNeeded would install the pinned version, then updateToLatest would install the latest, effectively updating and reverting in a loop across repeated runs.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Description
When a project pins a Luca version via
.luca-version, runningluca updatewould trigger two consecutive updates:updateIfNeededpre-flight (runs before every command) sees the pin and installs it (e.g. 0.12.0)updatecommand itself fetches the latest release and installs that (e.g. 0.13.0), overwriting what was just installedOn the next run of any command,
updateIfNeededwould see the stale pin again and downgrade back to 0.12.0. Runningluca updateagain would repeat the cycle — creating an update/revert loop across repeated invocations.This PR fixes the issue in two ways:
updateIfNeededwhen the command isupdate: since the update command fetches the latest release itself, running the pre-flight check is redundant and wasteful..luca-versionafter a successful update: afterupdateToLatestinstalls a new version, write it back into.luca-version(only when the file already exists) so the pin stays in sync andupdateIfNeededwon't attempt to downgrade on the next run.Type of Change
How Has This Been Tested?
Three new tests covering
.luca-versionsync afterupdateToLatest:test_updateToLatest_versionFileExists_updatesVersionFile—.luca-versionis written with the new versiontest_updateToLatest_noVersionFile_doesNotCreateOne— no file created when there's no existing pintest_updateToLatest_alreadyUpToDate_doesNotWriteVersionFile— no write when already at latestChecklist
Breaking Changes?