Skip to content

Only link release URL for published version tags#23

Merged
jclusso merged 1 commit into
masterfrom
version-url-fix
Jun 1, 2026
Merged

Only link release URL for published version tags#23
jclusso merged 1 commit into
masterfrom
version-url-fix

Conversation

@jclusso
Copy link
Copy Markdown
Member

@jclusso jclusso commented Jun 1, 2026

Problem

emailable version / --version appended a GitHub releases/tag/<v> URL for any version that wasn't literally dev. Two real build paths produce a non-dev, non-release version and so printed a link to a tag that doesn't exist:

Build version string URL
make release-snapshot 0.3.0-next (from version_template) .../tag/v0.3.0-next → 404
go install …@<branch> pseudo-version .../tag/v0.3.1-0.2026… → 404

Local make build (dev) and official GoReleaser releases were already correct.

Fix

Gate the URL on a strict semver match (^[0-9]+\.[0-9]+\.[0-9]+$), the same shape make release enforces. Only a published tag gets a link; snapshot, pseudo-version, and dev builds omit it. The old dev/v-prefix special-casing drops out.

Test

TestVersionDisplay_ReleaseURL covers release / snapshot / pseudo-version / dev. Verified the four cases against real binaries built with the matching ldflags.

The --version and version output appended a GitHub releases/tag URL for any non-"dev" version, so snapshot ("X.Y.Z-next") and go-install pseudo-version builds printed a link to a tag that does not exist. Gate the URL on a clean semver match instead, mirroring the release check in the Makefile.
Copilot AI review requested due to automatic review settings June 1, 2026 15:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Tightens the version-output release URL logic so that only clean semver releases produce a GitHub tag link, avoiding 404s for snapshot and pseudo-version builds.

Changes:

  • Replace dev/v-prefix special-casing with a strict ^X.Y.Z$ regex gate.
  • Add TestVersionDisplay_ReleaseURL covering release, snapshot, pseudo-version, and dev cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/root.go Replace conditional URL logic with regex match for clean semver and prepend v unconditionally.
cmd/version_test.go Add table-driven test verifying URL inclusion across version shapes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jclusso jclusso merged commit 35d0425 into master Jun 1, 2026
4 checks passed
@jclusso jclusso deleted the version-url-fix branch June 1, 2026 15:39
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.

2 participants