Skip to content

refactor: remove 'version.Get()' and only use 'version.Raw()'#445

Open
mwbrooks wants to merge 1 commit intomainfrom
mwbrooks-remove-version-get
Open

refactor: remove 'version.Get()' and only use 'version.Raw()'#445
mwbrooks wants to merge 1 commit intomainfrom
mwbrooks-remove-version-get

Conversation

@mwbrooks
Copy link
Copy Markdown
Member

@mwbrooks mwbrooks commented Mar 27, 2026

Changelog

  • N/A

Summary

This pull request removes version.Get() and only uses version.Raw(). The motivation is the simplify version handling to be 1 method instead of 2 methods.

Context:

PR #429 consolidated version handling to prefer version.Raw() and slackcontext.Version(ctx). A follow-up task was to remove version.Get() entirely since it creates confusion about which function to use. The only difference is that .Get() prepends a v prefix if missing - but we can guarantee the v prefix is always present without requiring .Get().

Why it's Safe to Remove:

The v prefix is already guaranteed in all code paths that set Version:

  1. Build-Time (Makefile): git describe --tags --match 'v*.*.*' - the --match pattern requires a v-prefixed tag, and git describe outputs the matching tag name, so the result always starts with v.
  2. Default Value (version.go): "v0.0.0-dev" - already has the prefix.
  3. Env Var Override (version.go): SLACK_TEST_VERSION - this is the one gap. QA testers could set it without a v. This PR adds validation by moving the v-prefix enforcement from .Get() into init(), ensuring Version is normalized at startup.

Open Question 🧠

  • Do we want to rename version.Raw() to version.Version()?
    • Technically, it's no longer the "raw" version because it may have a v-prefix added.
    • In the future, we may want a version.Major(), version.Minor(), etc to get specific elements of the version.

Requirements

Move the v-prefix enforcement from Get() into init(), ensuring Version
is normalized at startup. This eliminates the confusing Get() vs Raw()
distinction — Raw() is now the single way to access the version.
@mwbrooks mwbrooks added this to the Next Release milestone Mar 27, 2026
@mwbrooks mwbrooks self-assigned this Mar 27, 2026
@mwbrooks mwbrooks added code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment labels Mar 27, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.35%. Comparing base (0c37128) to head (e114959).

Files with missing lines Patch % Lines
internal/pkg/auth/login.go 0.00% 3 Missing ⚠️
cmd/root.go 33.33% 2 Missing ⚠️
cmd/upgrade/upgrade.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #445      +/-   ##
==========================================
+ Coverage   70.32%   70.35%   +0.02%     
==========================================
  Files         220      220              
  Lines       18506    18506              
==========================================
+ Hits        13015    13020       +5     
+ Misses       4313     4311       -2     
+ Partials     1178     1175       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member Author

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

A few notes for the semantic minded versioners 🔢

if envVersion := getVersionFromEnv(); envVersion != "" {
Version = envVersion
}
Version = ensurePrefix(Version)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

note: We now enforce the v prefix on init() so that all version-pathways will now have a v prefix.

@mwbrooks mwbrooks marked this pull request as ready for review March 27, 2026 21:05
@mwbrooks mwbrooks requested a review from a team as a code owner March 27, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant