Skip to content

Improve version handling and asset naming consistency #7

@tobiase

Description

@tobiase

Overview

Currently the update system has some fragile version handling patterns that could be improved.

Priority: Low - System works correctly, but could be more maintainable and robust.

Current Issues

  1. Asset Name Brittleness: We manually construct expected asset names but GoReleaser generates versioned names like wt_0.4.0_Darwin_all.tar.gz. Our matching logic uses string manipulation workarounds.

  2. Binary Name Inconsistency: We support both wt-bin (development name) and worktree-utils (release name) which creates confusion and maintenance overhead.

  3. Platform Detection: Manual OS/arch mapping that could leverage existing Go tooling.

  4. Version Comparison: Basic string comparison instead of semantic versioning.

Suggested Improvements

1. Standardize Asset Naming

  • Use GoReleaser naming patterns consistently
  • Or configure GoReleaser to match our expected patterns
  • Consider using GitHub API dynamic asset discovery

2. Unify Binary Names

  • Choose one canonical name (probably wt-bin for consistency)
  • Update GoReleaser config to use consistent binary name
  • Remove dual binary name support after transition

3. Use Semantic Versioning Library

  • Replace manual version comparison with proper semver
  • Handle pre-release versions, build metadata correctly
  • Examples: github.com/Masterminds/semver/v3 or golang.org/x/mod/semver

4. Learn from Established Tools

  • Study how gh, docker, kubectl handle updates
  • Consider using update frameworks like go-github for releases

Current Workarounds

The update system currently works with these workarounds:

  • strings.HasSuffix(a.Name, "_"+assetName[3:]+".tar.gz") for versioned assets
  • base == "wt-bin" || base == "worktree-utils" for binary names

Benefits of Fixing

  • More maintainable update code
  • Reduced fragility when changing release processes
  • Better error messages for users
  • Preparation for more complex update scenarios (checksums, signatures, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions