Skip to content

feat: upgrade command - #5

Merged
BKJN1 merged 1 commit into
mainfrom
feat/upgrade-command
Aug 4, 2026
Merged

feat: upgrade command#5
BKJN1 merged 1 commit into
mainfrom
feat/upgrade-command

Conversation

@BKJN1

@BKJN1 BKJN1 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@augmentcode

augmentcode Bot commented Aug 4, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Adds a new versola upgrade subcommand to self-update the CLI binary from the latest GitHub Release.

Changes:

  • Registers the upgrade Cobra command in the root command.
  • Implements GitHub “latest release” lookup, platform/arch asset selection, and download into the executable’s directory.
  • Verifies the downloaded asset against the release’s checksums.txt when available, mirroring existing install script behavior.
  • Replaces the running executable in-place (Windows uses a rename-aside flow with .old cleanup).

Technical Notes: Refuses to run on dev builds and keeps the implementation dependency-free by using raw HTTP + SHA256.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread internal/cmd/upgrade.go Outdated

func latestReleaseTag(client *http.Client, repo string) (string, error) {
url := fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", repo)
resp, err := client.Get(url)

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

internal/cmd/upgrade.go:170: The GitHub API requires a User-Agent header on requests; using client.Get directly can be rejected (commonly as 403), which would make upgrade fail even when networking is otherwise fine. Consider ensuring these requests include a User-Agent so the endpoint is reliably callable.

Severity: high

Other Locations
  • internal/cmd/upgrade.go:192
  • internal/cmd/upgrade.go:224

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@BKJN1
BKJN1 force-pushed the feat/upgrade-command branch from a8eefb3 to c97716b Compare August 4, 2026 12:23
@BKJN1

BKJN1 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

augment review

@BKJN1
BKJN1 merged commit cc9be1d into main Aug 4, 2026
1 check passed

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 5 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread internal/cmd/upgrade.go
// and always returns the newest non-pre-release tag, so a plain
// inequality is enough here -- no need to pull in a semver library
// just to answer "is there something to install".
if latestTag == version {

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

internal/cmd/upgrade.go:91: Treating any latestTag != version as an available upgrade can be misleading for pre-release builds (e.g. v1.2.0-beta), since /releases/latest returns the latest non-pre-release and may be older than the current version. In that case this would present a downgrade as an upgrade ("is available"), which could surprise users.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread internal/cmd/upgrade.go
// couldn't remove its own running file. It's harmless clutter, but
// this is the one command that would ever create it, so it's also
// the natural place to sweep it up on a later run.
_ = os.Remove(exe + ".old")

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

internal/cmd/upgrade.go:68: _ = os.Remove(exe + ".old") runs on all platforms even though the .old file is only created by the Windows replacement path. This could delete a user-created <binary>.old file without confirmation.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread internal/cmd/upgrade.go
}

fmt.Printf("versola-cli %s is available (you have %s).\n", latestTag, version)
if !upgradeAssumeYes && !confirm("Update now?") {

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

internal/cmd/upgrade.go:102: confirm() reads from stdin even when it’s non-interactive, so versola upgrade can block in scripted/CI contexts unless --yes is provided. That makes automation behavior sensitive to how stdin is wired up.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread internal/cmd/upgrade.go
return release.TagName, nil
}

// downloadToFile streams url into path and also returns the full body, so

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

internal/cmd/upgrade.go:212-214: The downloadToFile doc comment says it "streams" into the file, but the implementation reads the full response into memory via io.ReadAll and only then writes it. This can mislead readers about memory usage/behavior for larger assets.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread README.md
### `upgrade`

Checks the latest versola-cli release on GitHub and, if it's different
from this binary's version, downloads it — verified against that

@augmentcode augmentcode Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

README.md:190-193: The docs state the download is verified against the release’s checksums.txt, but the implementation explicitly proceeds without verification on 404/other fetch errors or when the asset isn’t present in checksums.txt (with warnings). This wording may overstate the verification guarantee.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

BKJN1 added a commit that referenced this pull request Aug 5, 2026
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