fix(upgrade): honor --dry-run as preview-only instead of silently upgrading#416
Open
jackjin1997 wants to merge 1 commit into
Open
fix(upgrade): honor --dry-run as preview-only instead of silently upgrading#416jackjin1997 wants to merge 1 commit into
jackjin1997 wants to merge 1 commit into
Conversation
…rading dws upgrade registered no --dry-run flag and never read the global one, so --dry-run fell through to runUpgrade and performed a real, irreversible upgrade (download + replace binary). This contradicts the flag's documented contract (预览操作内容,不实际执行). Resolve the target release and platform asset (so a missing build / 'already latest' is still reported), then render the planned 1-5 steps and return before any side effect: no backup, no download, no replace. Advertise --dry-run in the command examples. Fixes DingTalk-Real-AI#364
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.
Summary
dws upgradenow honors--dry-run: it resolves the target release and platform asset (so "already latest" / a missing build for the platform is still reported), prints the 1–5 steps it would perform, and returns before any side effect — no backup, no download, no replace.--dry-runis also advertised in the command examples.newUpgradeCommandregistered no--dry-runflag and never read the global persistent one, so--dry-runfell through torunUpgradeand performed a real, irreversible upgrade (download + binary replace). This directly contradicts the flag's documented contract (预览操作内容,不实际执行) and is dangerous: users running a "preview" actually got upgraded.Fixes #364
Verification
make buildmake lint—go vetpasses;staticchecknot installed in my local env (CI covers it)go test ./internal/app/(incl. newTestWriteDryRunPlan_*, updated help test)make policy./scripts/policy/check-generated-drift.sh./scripts/policy/check-command-surface.sh --strictNotes
writeDryRunPlan) is writer-injected and side-effect-free for testability.dws upgradepath.--dry-run+--rollbackis the same "mutating op ignores dry-run" class and could be a small follow-up, but is intentionally out of scope here to keep the change atomic.