Class CommitAnalyzer
feat -> MINOR fix, perf -> PATCH docs, style, refactor, test, chore, build, ci -> NONE (known, deliberately-no-release types) anything that doesn't conform to the "type: description" shape at all, or uses a type outside the lists above -> PATCH, and a warning is printed to stderr
...except that a '!' after the type/scope (e.g. "feat!:" or "feat(api)!:"), OR a "BREAKING CHANGE:" (or "BREAKING-CHANGE:") footer anywhere in the message, always forces MAJOR regardless of the type - a breaking fix is still a breaking change.
The non-conforming rule (-> PATCH + warning, rather than silently NONE) is a deliberate departure from the semantic-release original, which just ignores anything it doesn't recognize: here, a commit that isn't in Conventional Commits form at all - a typo'd type, a merge commit's default message, a commit predating this convention's adoption, someone not bothering to follow the convention - is treated as a small, defensive PATCH bump instead. The rationale is that silently ignoring an unrecognized commit risks silently ignoring a real, released change; a PATCH bump (the smallest possible) plus a visible warning errs towards "the version moved, and you were told why" rather than "nothing happened and nobody noticed".
Configuring which types map to which bump
Which type-word maps to which CommitAnalyzer.Bump is data, not hardcoded logic: it's a
Map<Bump, Set<String>> (see DEFAULT_TYPE_RULES), optionally passed to
analyze(List, Map) / analyzeOne(String, Map) to override or extend it.
Consumers of the Gradle plugin do this via the commitAnalyzer { } extension registered by
VersionPlugin (see CommitAnalyzerExtension), which exposes one
SetProperty<String> per bump level (majorTypes, minorTypes,
patchTypes, noBumpTypes) - each can be appended to
(.add(...)/.addAll(...)) or replaced outright (.set(...)) independently
of the others.
majorTypes defaults to empty, since MAJOR is normally driven by the
structural '!'/BREAKING CHANGE detection above rather than by type at all - it exists so a
project can ALSO force specific types (e.g. security) to always be MAJOR on their own,
without needing every such commit to remember the '!' marker.
When classifying a single type, the four levels are checked from most to least
severe (MAJOR, MINOR, PATCH, NONE - see analyzeOne(String, Map)), so if a type
is (mis)configured into more than one set, the highest-severity match wins: a type present in
both majorTypes and patchTypes resolves to MAJOR.
See VersionResolver for how the result of analyzing a batch of commits gets turned
into an actual version number, and ChangelogGenerator (release-flow plugin) for how
parse(String) - the syntactic parse, independent of typeRules - gets turned into release
notes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe four possible outcomes of analyzing a commit (or a batch of commits), in ascending severity.static final classThe syntactic parse of a commit message, independent of any type -> bump configuration - seeparse(String). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map<CommitAnalyzer.Bump,Set<String>> The built-in type -> bump mapping, used whenever a caller doesn't supply its own. -
Method Summary
Modifier and TypeMethodDescriptionstatic CommitAnalyzer.BumpEquivalent toanalyze(List, Map)withDEFAULT_TYPE_RULES.static CommitAnalyzer.BumpThe overall bump for a range of commits (e.g.static CommitAnalyzer.BumpanalyzeOne(String message) Equivalent toanalyzeOne(String, Map)withDEFAULT_TYPE_RULES.static CommitAnalyzer.BumpanalyzeOne(String message, Map<CommitAnalyzer.Bump, Set<String>> typeRules) Classifies a single full commit message (subject + blank line + body/footer, if any).static CommitAnalyzer.ParsedCommitThe syntactic parse of a commit message - type/scope/description/breaking-ness - independent of any type -> bump configuration.
-
Field Details
-
DEFAULT_TYPE_RULES
The built-in type -> bump mapping, used whenever a caller doesn't supply its own. See the class doc for why MAJOR's default set is empty.
-
-
Method Details
-
analyze
Equivalent toanalyze(List, Map)withDEFAULT_TYPE_RULES. -
analyze
public static CommitAnalyzer.Bump analyze(List<String> messages, Map<CommitAnalyzer.Bump, Set<String>> typeRules) The overall bump for a range of commits (e.g. every commit since the last release): the highest individualanalyzeOne(String, Map)result across the whole batch wins, so a singlefeat!:commit among tenchore:commits still means MAJOR. An empty batch isBump.NONE, meaning "nothing here warrants a new version" - the caller then decides what to do with that (VersionResolverleaves the base version unchanged).- Parameters:
typeRules- seeDEFAULT_TYPE_RULES
-
analyzeOne
Equivalent toanalyzeOne(String, Map)withDEFAULT_TYPE_RULES. -
analyzeOne
public static CommitAnalyzer.Bump analyzeOne(String message, Map<CommitAnalyzer.Bump, Set<String>> typeRules) Classifies a single full commit message (subject + blank line + body/footer, if any).- Parameters:
typeRules- seeDEFAULT_TYPE_RULES
-
parse
The syntactic parse of a commit message - type/scope/description/breaking-ness - independent of any type -> bump configuration. SeeCommitAnalyzer.ParsedCommit.
-