Skip to content

matching

Commit matching functions.

CLASS DESCRIPTION
MetadataMatch

Evaluates an attribute in the metadata against a value using an operator.

SummaryRegexMatch

Matches the commit summary using a regular expression.

Classes

MetadataMatch

MetadataMatch(attribute: str, operator: str, value: Any)

Evaluates an attribute in the metadata against a value using an operator.

Examples:

To group breaking changes:

- action: MetadataMatch
  category: Breaking Changes
  kwargs:
    attribute: has_breaking_change
    operator: is
    value: True

To match a specific value:

- action: MetadataMatch
  category: Feature
  kwargs:
    attribute: commit_type
    operator: ==
    value: feat

To match multiple values:

- action: MetadataMatch
  category: Updates
  kwargs:
    attribute: commit_type
    operator: in
    value: ["fix", "refactor", "update"]

Valid operators: ==, !=, <, >, >=, <=, is, is not, in, not in

ATTRIBUTE DESCRIPTION
operator_map

A map of operator names to operators

TYPE: Dict[str, Callable]

PARAMETER DESCRIPTION
attribute

The name of the metadata key whose value will be evaluated

TYPE: str

operator

One of the valid operators described above

TYPE: str

value

The value to evaluate the against the metadata

TYPE: Any

RAISES DESCRIPTION
ValueError

If the operator value is not recognized

METHOD DESCRIPTION
__call__

Does the commit metadata attribute meet the conditional?

Attributes

operator_map class-attribute
operator_map: Dict[str, Callable] = {
    "==": eq,
    "!=": ne,
    "<": lt,
    ">": gt,
    ">=": ge,
    "<=": le,
    "is": is_,
    "is not": is_not,
    "in": contains,
    "not in": lambda x, y: x not in y,
}

Mapping of operator strings to functions for evaluation.

Functions

__call__
__call__(commit: CommitContext) -> bool

Does the commit metadata attribute meet the conditional?

SummaryRegexMatch

SummaryRegexMatch(pattern: Optional[str] = None)

Matches the commit summary using a regular expression.

If pattern is None all commits will match.

Examples:

In .changelog-config.yaml:

commit_classifiers:
- action: SummaryRegexMatch
  category: New
  kwargs:
    pattern: (?i)^(?:new|add)[^\n]*$
PARAMETER DESCRIPTION
pattern

The pattern to match against the commit summary

TYPE: Optional[str] DEFAULT: None

METHOD DESCRIPTION
__call__

Does the commit summary match the pattern?

Functions

__call__
__call__(commit: CommitContext) -> bool

Does the commit summary match the pattern?

Functions