fix(bootstrap): prepend v prefix to version for correct git ref resolution
- commit
- 2b3076bdcc326f928014e3f9609a231a10d8e077
- author
- brice · · 2026-04-03 15:15 UTC
- parent
- 53b3337
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +16 -0
M internal/config/config.go +3 -0
| @@ -222,6 +222,9 @@ func bootstrapRef(version string) string { | |||
| 222 | 222 | case strings.Contains(version, "-next"): | |
| 223 | 223 | return "dev" | |
| 224 | 224 | default: | |
| 225 | + | if !strings.HasPrefix(version, "v") { | |
| 226 | + | return "v" + version | |
| 227 | + | } | |
| 225 | 228 | return version | |
| 226 | 229 | } | |
| 227 | 230 | } | |
| @@ -222,6 +222,9 @@ func bootstrapRef(version string) string { | |||||
| 222 | case strings.Contains(version, "-next"): | 222 | case strings.Contains(version, "-next"): | ||
| 223 | return "dev" | 223 | return "dev" | ||
| 224 | default: | 224 | default: | ||
| 225 | + | if !strings.HasPrefix(version, "v") { | |||
| 226 | + | return "v" + version | |||
| 227 | + | } | |||
| 225 | return version | 228 | return version | ||
| 226 | } | 229 | } | ||
| 227 | } | 230 | } | ||
M internal/config/config_test.go +13 -0
| @@ -26,6 +26,19 @@ func TestNewConfig_UsesDevRefForDevelopmentBuilds(t *testing.T) { | |||
| 26 | 26 | } | |
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | + | func TestNewConfig_GoReleaserVersionWithoutVPrefix(t *testing.T) { | |
| 30 | + | // GoReleaser strips the 'v' prefix: version={{.Version}} yields "0.5.1" not "v0.5.1". | |
| 31 | + | cfg := NewConfig("0.5.1") | |
| 32 | + | ||
| 33 | + | if cfg.RawURL != "https://raw.githubusercontent.com/bnema/archup/v0.5.1" { | |
| 34 | + | t.Fatalf("expected v-prefixed raw URL, got %q", cfg.RawURL) | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | if cfg.Branch() != "v0.5.1" { | |
| 38 | + | t.Fatalf("expected v-prefixed branch, got %q", cfg.Branch()) | |
| 39 | + | } | |
| 40 | + | } | |
| 41 | + | ||
| 29 | 42 | func TestNewConfig_ENVDevOverridesReleaseVersion(t *testing.T) { | |
| 30 | 43 | t.Setenv("ENV", "dev") | |
| 31 | 44 | ||
| @@ -26,6 +26,19 @@ func TestNewConfig_UsesDevRefForDevelopmentBuilds(t *testing.T) { | |||||
| 26 | } | 26 | } | ||
| 27 | } | 27 | } | ||
| 28 | 28 | ||||
| 29 | + | func TestNewConfig_GoReleaserVersionWithoutVPrefix(t *testing.T) { | |||
| 30 | + | // GoReleaser strips the 'v' prefix: version={{.Version}} yields "0.5.1" not "v0.5.1". | |||
| 31 | + | cfg := NewConfig("0.5.1") | |||
| 32 | + | ||||
| 33 | + | if cfg.RawURL != "https://raw.githubusercontent.com/bnema/archup/v0.5.1" { | |||
| 34 | + | t.Fatalf("expected v-prefixed raw URL, got %q", cfg.RawURL) | |||
| 35 | + | } | |||
| 36 | + | ||||
| 37 | + | if cfg.Branch() != "v0.5.1" { | |||
| 38 | + | t.Fatalf("expected v-prefixed branch, got %q", cfg.Branch()) | |||
| 39 | + | } | |||
| 40 | + | } | |||
| 41 | + | ||||
| 29 | func TestNewConfig_ENVDevOverridesReleaseVersion(t *testing.T) { | 42 | func TestNewConfig_ENVDevOverridesReleaseVersion(t *testing.T) { | ||
| 30 | t.Setenv("ENV", "dev") | 43 | t.Setenv("ENV", "dev") | ||
| 31 | 44 | ||||