Skip to content

Commit

Permalink
Merge pull request cri-o#7757 from haircommander/release-note-start-ver
Browse files Browse the repository at this point in the history
release-notes: fix startTag calculation
  • Loading branch information
openshift-merge-bot[bot] committed Feb 8, 2024
2 parents e0e17ee + 05f4cbb commit 11a1334
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion scripts/release-notes/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/blang/semver/v4"
"github.com/cri-o/cri-o/internal/version"
"github.com/sirupsen/logrus"
"sigs.k8s.io/release-sdk/git"
Expand Down Expand Up @@ -87,7 +88,11 @@ func run() error {
shortHead := head[:7]
endRev := head

startTag := util.AddTagPrefix(version.Version)
startVersion, err := startVersionFromCurrent(version.Version)
if err != nil {
return fmt.Errorf("parsing start version: %w", err)
}
startTag := util.AddTagPrefix(startVersion)
if output, err := command.New(
"git", "describe", "--tags", "--exact-match",
).RunSilentSuccessOutput(); err == nil {
Expand Down Expand Up @@ -354,3 +359,19 @@ func decVersion(tag string) string {

return sv.String()
}

func startVersionFromCurrent(ver string) (string, error) {
semVer, err := semver.Parse(ver)
if err != nil {
return "", err
}
if semVer.Patch == 0 {
// If we're looking at an unreleased (or recently released) branch,
// we compare against the last version.
semVer.Minor--
} else {
// Otherwise, we're comparing against the last patch version.
semVer.Patch--
}
return semVer.String(), nil
}

0 comments on commit 11a1334

Please sign in to comment.