Files
releaser/internal/version/version.go
T

24 lines
711 B
Go
Raw Permalink Normal View History

2026-07-07 00:07:53 +02:00
package version
import (
"fmt"
"git.k3nny.fr/releaser/internal/commits"
)
// Next computes the next version string (without tag prefix, e.g. "1.2.4").
// currentPatch is -1 when no tag exists yet (first release will be X.Y.0).
// releasable is the set of commit types that trigger a bump; nil defaults to all three.
2026-07-07 00:07:53 +02:00
// Returns ("", false) when there are no releasable commits.
func Next(major, minor, currentPatch int, types []commits.Type, releasable map[commits.Type]bool) (string, bool) {
if releasable == nil {
releasable = commits.ReleasableSet(nil)
}
2026-07-07 00:07:53 +02:00
for _, t := range types {
if releasable[t] {
2026-07-07 00:07:53 +02:00
return fmt.Sprintf("%d.%d.%d", major, minor, currentPatch+1), true
}
}
return "", false
}