7b27f00602
Our logic for converting npm style versions to PEP-440 style versions was not correct in some cases. This change fixes this. As part of this change we no longer produce a NPM version that would be just X.Y.Z-dev, instead for development versions we always include both the timestamp of the commit and the commit hash. Instead of trying to use a bunch of sed logic to do our conversions, we now have a small go program that uses a newly added library in pkg/util. A side effect of this is that we can more easily write tests to ensure the conversion works as expected. Fixes #1243
27 lines
983 B
Go
27 lines
983 B
Go
package buildutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestVersions(t *testing.T) {
|
|
cases := map[string]string{
|
|
"v0.12.0": "0.12.0",
|
|
"v0.12.0-dirty": "0.12.0+dirty",
|
|
"v0.12.0-1524606809-gf2f1178b": "0.12.0.post1524606809+gf2f1178b",
|
|
"v0.12.0-1524606809-gf2f1178b-dirty": "0.12.0.post1524606809+gf2f1178b.dirty",
|
|
"v0.12.0-rc1": "0.12.0rc1",
|
|
"v0.12.0-rc1-1524606809-gf2f1178b": "0.12.0rc1.post1524606809+gf2f1178b",
|
|
"v0.12.0-rc1-1524606809-gf2f1178b-dirty": "0.12.0rc1.post1524606809+gf2f1178b.dirty",
|
|
"v0.12.1-dev-1524606809-gf2f1178b": "0.12.1.dev1524606809+gf2f1178b",
|
|
"v0.12.1-dev-1524606809-gf2f1178b-dirty": "0.12.1.dev1524606809+gf2f1178b.dirty",
|
|
}
|
|
|
|
for ver, expected := range cases {
|
|
p, err := PyPiVersionFromNpmVersion(ver)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, expected, p, "failed parsing '%s'", ver)
|
|
}
|
|
}
|