2b3c7f61c5
Under our old versioning system, when we started a new point release, we'd tag the HEAD commit of master with a tag like `v0.16.6-dev` and our scripts would use this to generate a new version number. This required a great deal of gymnastics when producing a release and caused us to litter these -dev tags everywhere. To improve this, we change version number generation to the following strategy: 1. If the commit we are building has a tag applied to it, use that tag as the version (appending the dirty bit metadata to the version, if needed). 2. If the commit we are bulding does not have a tag applied to it, take the version from the next reachable tag, increment the patch version and then append the `-dev` pre-release tag. As part of this, we also make a slight tweek to our semver generation such that instead of `-dev<TIMESTAMP>` we use `-dev.<TIMESTAMP>` which is more in line with what semver recommends.
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
// Copyright 2016-2018, Pulumi Corporation.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
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-rc.1": "0.12.0rc1",
|
|
"v0.12.0-rc.1+dirty": "0.12.0rc1+dirty",
|
|
"v0.12.1-dev.1524606809+gf2f1178b": "0.12.1.dev1524606809",
|
|
"v0.12.1-dev.1524606809+gf2f1178b.dirty": "0.12.1.dev1524606809+dirty",
|
|
}
|
|
|
|
for ver, expected := range cases {
|
|
p, err := PyPiVersionFromNpmVersion(ver)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, expected, p, "failed parsing '%s'", ver)
|
|
}
|
|
}
|