Skip to content

Add hammer update self-update command#8

Merged
chenchaoyi merged 1 commit into
masterfrom
claude/hammer-update
Jun 23, 2026
Merged

Add hammer update self-update command#8
chenchaoyi merged 1 commit into
masterfrom
claude/hammer-update

Conversation

@chenchaoyi

Copy link
Copy Markdown
Owner

Summary

Adds a hammer update subcommand so the CLI can update itself to the latest GitHub release.

  • Resolves the target release via the GitHub API (latest, or a pinned -version <tag>)
  • Downloads the platform archive (.tar.gz, or .zip on Windows), verifies it against SHA256SUMS, and atomically swaps the running binary (cross-filesystem copy fallback + Windows rename-aside)
  • Reuses the install.sh mirror ladder — -mirror auto|github|ghproxy|<proxy> / HAMMER_INSTALL_MIRROR, and HAMMER_REPO for forks
  • Semver-aware: won't downgrade or reinstall the same version; a dev build always upgrades to a real release
  • Flags: -check (report only), -version, -y/-yes (skip prompt)

Testing

  • Unit tests in update_test.go: semver parse/compare, asset naming, mirror candidate ordering, checksum verify (valid/missing/tampered), tar.gz + zip extraction, atomic replace
  • Verified end-to-end: a v1.1.0 binary downloaded, checksum-verified, and replaced itself with the live v1.2.0 release
  • go build, go vet, gofmt -l, and go test -race ./... all clean

🤖 Generated with Claude Code

Add an `update` subcommand that replaces the running binary with the
latest GitHub release. It resolves the target release via the GitHub
API, downloads the platform archive (tar.gz, or zip on Windows),
verifies it against SHA256SUMS, and atomically swaps the binary in place
(with a cross-filesystem copy fallback and the Windows rename-aside path).

Reuses the install.sh mirror ladder (auto/github/ghproxy/custom proxy via
-mirror or HAMMER_INSTALL_MIRROR) and HAMMER_REPO for forks. Flags: -check,
-version, -y/-yes. Semver-aware so it won't downgrade or reinstall the same
version; a dev build always upgrades to a real release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chenchaoyi chenchaoyi merged commit 653fcf9 into master Jun 23, 2026
1 check passed
@chenchaoyi chenchaoyi deleted the claude/hammer-update branch June 23, 2026 06:11
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.

1 participant