Skip to content

v0.x: rollback and pin

update can roll back to an earlier release and pin a tool to one (spec 0104). A tool picks this up with the gtb release that ships it; nothing in a tool's code changes unless it implements update.Updater.

What changes

  • An attended downgrade asks first. update --version <tag> naming a release older than the running one used to install it without a word. At a terminal it now asks "Roll back … ? This installs an older release.", and a decline exits non-zero with setup.ErrDowngradeNotConfirmed. Unattended (CI, or no terminal), it proceeds as before. --force skips the question.
  • update.Updater gains ReleaseBefore(ctx, current string) (string, error). It is how the command finds the release before the running one. *setup.SelfUpdater implements it.
  • update.UpdateResult gains RolledBack and Pinned. --output json carries rolled_back and, when the tool is pinned, pinned.
  • update refuses positional arguments. update --rollback v1.1.0 used to ignore the version. It now fails and says to write --rollback=v1.1.0.

What to do

  • A test double or a custom implementation of update.Updater: add ReleaseBefore. Returning "" and an error is enough where rollback is not exercised.
  • A script that runs update --version <older tag> at a terminal and expects no prompt: pass --force, or run it unattended.