Skip to content

refactor: consolidate version packages#28

Merged
rianjs merged 1 commit intomainfrom
refactor/24-consolidate-version-packages
Jan 29, 2026
Merged

refactor: consolidate version packages#28
rianjs merged 1 commit intomainfrom
refactor/24-consolidate-version-packages

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 29, 2026

Summary

  • Create shared/version package with standardized variable names
  • Add Info() and Full() helper functions
  • Update cfl and jtk to use shared version package
  • Standardize on BuildDate (was Date in cfl)
  • Update ldflags in Makefiles, .goreleaser.yml, and snapcraft.yaml
  • Remove tool-specific version packages

Variable Names (Standardized)

var (
    Version   = "dev"
    Commit    = "none"
    BuildDate = "unknown"
)

Test plan

  • Build succeeds
  • All tests pass
  • Lint passes
  • Version output verified for both tools

Closes #24

🤖 Generated with Claude Code

- Create shared/version package with standardized variable names
- Add Info() and Full() helper functions
- Update cfl and jtk to use shared version package
- Standardize on BuildDate (was Date in cfl)
- Update ldflags in Makefiles, .goreleaser.yml, and snapcraft.yaml
- Remove tool-specific version packages

Both tools now use consistent version formatting.

Closes #24
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 29, 2026

Test Coverage Assessment for PR #28

Summary

This PR consolidates version packages from tools/cfl/internal/version and tools/jtk/internal/version into a shared shared/version package. The changes are primarily:

  1. New code: shared/version/version.go (30 lines) - 3 exported variables and 2 helper functions
  2. Deleted code: Two tool-specific version packages (9 + 18 lines)
  3. Updated imports: Both root.go files updated to use the shared package
  4. Build config changes: Makefiles, GoReleaser, and Snapcraft configs updated with new ldflags paths

Test Coverage Analysis

Current State: The new shared/version/version.go has no test file (go test ./shared/version/... reports "no test files").

Is this acceptable? Yes, for the following reasons:

  1. Trivial code: The package contains only:

    • 3 string variables with default values
    • Info() - returns Version (1 line)
    • Full() - string concatenation (1 line)
  2. Build-time validation: The ldflags injection is validated through:

    • Successful builds (CI verifies this)
    • The PR notes "Version output verified for both tools"
  3. No business logic: No conditionals, no error handling, no edge cases to test

  4. Pattern consistency: Looking at the deleted files, neither tools/cfl/internal/version/version.go nor tools/jtk/internal/version/version.go had tests either - the jtk version had the same Info() and Full() functions that are now being consolidated

  5. Integration coverage: The root.go integration points use the version package, and those root commands are exercised by other tests

Potential Improvements (Optional)

If the team wants to enforce test coverage for all shared packages, a simple test would look like:

func TestInfo(t *testing.T) {
    // Default value when not built with ldflags
    if got := Info(); got != "dev" {
        t.Errorf("Info() = %q, want %q", got, "dev")
    }
}

func TestFull(t *testing.T) {
    got := Full()
    if !strings.Contains(got, "dev") {
        t.Error("Full() should contain version")
    }
    if !strings.Contains(got, "built") {
        t.Error("Full() should contain 'built'")
    }
}

However, this provides minimal value since it only tests string concatenation with default values.

Verdict

No test coverage gaps that would warrant blocking this PR. The code is trivial, follows existing patterns (the deleted code also had no tests), and the real validation happens at build time through ldflags injection.

The PR correctly updates all ldflags references, standardizes the variable name (Date -> BuildDate), and adds two convenience functions that existed in jtk but not cfl.


Automated review by Claude Code

@rianjs rianjs merged commit cafc0cb into main Jan 29, 2026
7 checks passed
@rianjs rianjs deleted the refactor/24-consolidate-version-packages branch January 29, 2026 20:05
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.

refactor: consolidate version packages

1 participant