Files
releaser/internal/version/version.go
T
k3nny f07220b0c6
ci / vet, staticcheck, test, build (push) Failing after 4m11s
release / Build and publish release (push) Successful in 5m7s
feat(releaser): release v1.5.0 — Node.js, multi-module Maven, configurable bump rules
- Add internal/node package: reads/writes package.json version (single or
  multi-path via node.package_json / node.package_jsons)
- Add maven.pom_paths support: update multiple pom.xml files in one release
  commit; pom_paths overrides pom_path; --pom flag clears pom_paths
- Add git.bump_rules config: per-type control of which version component bumps
  (breaking/feat/fix accept "patch" or "minor"); wired through version.Next()
  as a new sixth parameter
- Extract injectable function vars (absPath, gitAllCommits, gitCommitsSince,
  gitCommitFiles) to enable error-path testing without interfaces
- Achieve 100% per-package statement coverage across all 12 packages

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-11 16:59:28 +02:00

44 lines
1.1 KiB
Go

package version
import (
"fmt"
"git.k3nny.fr/releaser/internal/commits"
)
// BumpLevel controls which version component is incremented.
type BumpLevel int
const (
BumpPatch BumpLevel = iota
BumpMinor
)
// 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.
// bumpRules maps each type to its bump level; nil defaults to BumpPatch for all.
// Returns ("", false) when there are no releasable commits.
func Next(major, minor, currentPatch int, types []commits.Type, releasable map[commits.Type]bool, bumpRules map[commits.Type]BumpLevel) (string, bool) {
if releasable == nil {
releasable = commits.ReleasableSet(nil)
}
found := false
useMinor := false
for _, t := range types {
if releasable[t] {
found = true
if bumpRules[t] == BumpMinor {
useMinor = true
}
}
}
if !found {
return "", false
}
if useMinor {
return fmt.Sprintf("%d.%d.0", major, minor+1), true
}
return fmt.Sprintf("%d.%d.%d", major, minor, currentPatch+1), true
}