Skip to content

Add build info resolution and version display in help overlay - #11

Merged
someson merged 1 commit into
mainfrom
claude/pensive-albattani-8epkyd
Sep 26, 2026
Merged

someson merged 1 commit into
mainfrom
claude/pensive-albattani-8epkyd

Conversation

@someson

@someson someson commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Summary

This PR enhances version information handling by automatically resolving build metadata from Go's build info when release ldflags are not set, and displays the version in the help overlay for better visibility during bug reports.

Key Changes

  • New buildinfo.go module: Implements fillBuildInfo() and resolveBuildInfo() functions that intelligently extract version, commit hash, and build date from Go's runtime build info

    • Handles multiple build scenarios: Goreleaser releases, go install @vX.Y.Z, and local go build in git checkouts
    • Distinguishes between tagged versions and pseudo-versions/development builds
    • Detects dirty working trees and appends -dirty suffix to commit hashes
    • Truncates commit hashes to 7 characters for readability
  • Version string formatting: Extracted version display logic into versionString() function with consistent format: "azform X.Y.Z (commit, date)"

  • Help overlay enhancement: Displays version information right-aligned on the help title line, making it immediately visible when users open the help overlay (the natural place to look for version info when filing bug reports)

  • Integration:

    • fillBuildInfo() called early in main() to populate global version variables
    • Version string now shown in usage/help output
    • Updated tests to verify version display in help overlay

Implementation Details

  • Uses regex pattern matching to distinguish pseudo-versions from tagged versions
  • Respects ldflags precedence: if version/commit/date are already set by build tools, they are not overwritten
  • Keeps "dev" version for local builds to avoid cache invalidation on every commit while still providing commit hash for identification
  • Gracefully handles missing or incomplete build metadata

https://claude.ai/code/session_012a4ih1YQN5a7BsPynuErjY

The version was only reachable via --version and --doctor, never from
inside the form. The F1/? overlay now shows it right-aligned on the
title line, and -h prints it above the usage.

Builds without the goreleaser ldflags reported a bare "dev". The
version, commit and date are now backfilled from the Go build info: a
tagged go install gets its module version, a local build gets its VCS
commit (with -dirty). Pseudo-versions keep "dev" so the update check
does not nag local builds and the metadata cache is not invalidated on
every commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012a4ih1YQN5a7BsPynuErjY
@someson
someson merged commit 25c5fa9 into main Sep 26, 2026
6 checks passed
@someson
someson deleted the claude/pensive-albattani-8epkyd branch September 26, 2026 23:26
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