generate_changelog.actions.matching.MetadataMatch

MetadataMatch#

class generate_changelog.actions.matching.MetadataMatch[source]#

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

Parameters:
  • attribute (str) – The name of the metadata key whose value will be evaluated

  • operator (str) – One of the valid operators described above

  • value (Any) – The value to evaluate the against the metadata

Raises:

ValueError – If the operator value is not recognized

operator_map: ClassVar[Dict[str, Callable]] = {'!=': <built-in function ne>, '<': <built-in function lt>, '<=': <built-in function le>, '==': <built-in function eq>, '>': <built-in function gt>, '>=': <built-in function ge>, 'in': <built-in function contains>, 'is': <built-in function is_>, 'is not': <built-in function is_not>, 'not in': <function MetadataMatch.<lambda>>}#

Mapping of operator strings to functions for evaluation.

__init__(attribute, operator, value)[source]#
Parameters:
  • attribute (str) –

  • operator (str) –

  • value (Any) –

__call__(commit)[source]#

Does the commit metadata attribute meet the conditional?

Return type:

bool

Parameters:

commit (CommitContext) –