Skip to content

Commit

Permalink
fix: rpm doesnt allow dashes in prerelease
Browse files Browse the repository at this point in the history
closes #835
  • Loading branch information
caarlos0 committed Jul 4, 2024
1 parent 41b3349 commit 888e851
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func formatVersion(info *nfpm.Info) string {
version := info.Version

if info.Prerelease != "" {
version += "~" + info.Prerelease
version += "~" + strings.ReplaceAll(info.Prerelease, "-", "_")
}

if info.VersionMetadata != "" {
Expand Down
10 changes: 10 additions & 0 deletions rpm/rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@ func TestRPMVersionWithPrerelease(t *testing.T) {
require.Equal(t, "1", meta.Release)
}

func TestRPMVersionWithPrereleaseWithDashes(t *testing.T) {
info := exampleInfo()
info.Version = "1.0.0"
info.Prerelease = "rc1-alpha-omega" // nolint:goconst
meta, err := buildRPMMeta(info)
require.NoError(t, err)
require.Equal(t, "1.0.0~rc1_alpha_omega", meta.Version)
require.Equal(t, "1", meta.Release)
}

func TestRPMVersionWithReleaseAndPrerelease(t *testing.T) {
// https://fedoraproject.org/wiki/Package_Versioning_Examples#Complex_versioning_examples
info := exampleInfo()
Expand Down

0 comments on commit 888e851

Please sign in to comment.