build: update not-in-stable after semver changes

This commit is contained in:
Nick Craig-Wood 2020-09-12 12:49:16 +01:00
parent 6a56ac1032
commit e0fd560711

View File

@ -10,6 +10,8 @@ import (
"os" "os"
"os/exec" "os/exec"
"regexp" "regexp"
"github.com/coreos/go-semver/semver"
) )
// version=$(sed <VERSION -e 's/\.[0-9]+*$//g') // version=$(sed <VERSION -e 's/\.[0-9]+*$//g')
@ -28,7 +30,7 @@ func readCommits(from, to string) (logMap map[string]string, logs []string) {
cmd := exec.Command("git", "log", "--oneline", from+".."+to) cmd := exec.Command("git", "log", "--oneline", from+".."+to)
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {
log.Fatalf("failed to run git log: %v", err) log.Fatalf("failed to run git log %s: %v", from+".."+to, err)
} }
logMap = map[string]string{} logMap = map[string]string{}
logs = []string{} logs = []string{}
@ -53,15 +55,20 @@ func main() {
if len(args) != 0 { if len(args) != 0 {
log.Fatalf("Syntax: %s", os.Args[0]) log.Fatalf("Syntax: %s", os.Args[0])
} }
// v1.54.0
versionBytes, err := ioutil.ReadFile("VERSION") versionBytes, err := ioutil.ReadFile("VERSION")
if err != nil { if err != nil {
log.Fatalf("Failed to read version: %v", err) log.Fatalf("Failed to read version: %v", err)
} }
i := bytes.LastIndexByte(versionBytes, '.') if versionBytes[0] == 'v' {
version := string(versionBytes[:i]) versionBytes = versionBytes[1:]
log.Printf("Finding commits not in stable %s", version) }
masterMap, masterLogs := readCommits(version+".0", "master") versionBytes = bytes.TrimSpace(versionBytes)
stableMap, _ := readCommits(version+".0", version+"-stable") semver := semver.New(string(versionBytes))
stable := fmt.Sprintf("v%d.%d", semver.Major, semver.Minor-1)
log.Printf("Finding commits in %v not in stable %s", semver, stable)
masterMap, masterLogs := readCommits(stable+".0", "master")
stableMap, _ := readCommits(stable+".0", stable+"-stable")
for _, logMessage := range masterLogs { for _, logMessage := range masterLogs {
// Commit found in stable already // Commit found in stable already
if _, found := stableMap[logMessage]; found { if _, found := stableMap[logMessage]; found {