Skip to content

release_hint

Methods for generating a release hint.

CLASS DESCRIPTION
InvalidRuleError

The evaluated rule is invalid.

ReleaseRule

A commit evaluation rule for hinting at the level of change.

ReleaseRuleResult

The result of evaluating a release rule.

RuleProcessor

Process a commit through all the rules and return the suggestion.

FUNCTION DESCRIPTION
format_bool

Format a boolean value as a string.

get_commit_results

Return the contents of the commit results table.

output_report

Output the release hint report.

print_table

Print the test results as a table.

suggest_release_type

Suggest the type of release based on the unreleased commits.

Attributes

Classes

InvalidRuleError

Bases: Exception

The evaluated rule is invalid.

ReleaseRule

ReleaseRule(
    id_: int,
    match_result: Optional[str],
    no_match_result: Optional[str] = "no-release",
    grouping: Union[str, tuple, list, None] = None,
    path: Optional[Union[str, Sequence[str]]] = None,
    branch: Optional[str] = None,
)

A commit evaluation rule for hinting at the level of change.

PARAMETER DESCRIPTION
id_

The id of this rule. Used for debugging.

TYPE: int

match_result

Release type if a commit context matches the rule.

TYPE: Optional[str]

no_match_result

Release type if a commit context doesn’t match the rule.

TYPE: Optional[str] DEFAULT: 'no-release'

grouping

The partial or exact grouping of the commit context

TYPE: Union[str, tuple, list, None] DEFAULT: None

path

A globbing pattern that matches against files included in the commit

TYPE: Optional[Union[str, Sequence[str]]] DEFAULT: None

branch

A regular expression pattern to match against the branch

TYPE: Optional[str] DEFAULT: None

METHOD DESCRIPTION
__call__

Evaluate the commit using this rule.

matches_branch

Does the current branch match the rule?

matches_grouping

Does the commit grouping match the rule?

matches_path

Do any of the paths in the commit match the rule?

Functions

__call__
__call__(commit: CommitContext, current_branch: str) -> ReleaseRuleResult

Evaluate the commit using this rule.

matches_branch
matches_branch(current_branch: str) -> bool

Does the current branch match the rule?

PARAMETER DESCRIPTION
current_branch

The name of the current branch

TYPE: str

RETURNS DESCRIPTION
bool

True if the current branch matches or if self.branch is None

matches_grouping
matches_grouping(commit: CommitContext) -> bool

Does the commit grouping match the rule?

  • If self.grouping is a string, it checks if the string is in the commit’s grouping.
  • If self.grouping is a list or tuple of strings, it must match the commit’s grouping.
  • If self.grouping is a list or tuple of strings and the last item in the list is a “*”, it must match the beginning of the commit’s grouping.
  • If self.grouping is None, it will return a match
PARAMETER DESCRIPTION
commit

The commit context whose grouping should match

TYPE: CommitContext

RETURNS DESCRIPTION
bool

True if the grouping matches

matches_path
matches_path(commit: CommitContext) -> bool

Do any of the paths in the commit match the rule?

PARAMETER DESCRIPTION
commit

The commit context whose files should match

TYPE: CommitContext

RETURNS DESCRIPTION
bool

True if any file in the commit context matches the pattern or if self.path is None

ReleaseRuleResult dataclass

ReleaseRuleResult(
    rule_id: int,
    commit: str,
    matches_grouping: bool,
    matches_path: bool,
    matches_branch: bool,
    result: str,
)

The result of evaluating a release rule.

ATTRIBUTE DESCRIPTION
matches_all

All the commit criteria were met.

TYPE: bool

Attributes

matches_all property
matches_all: bool

All the commit criteria were met.

RuleProcessor

RuleProcessor(rule_list: List[dict])

Process a commit through all the rules and return the suggestion.

PARAMETER DESCRIPTION
rule_list

The list of dictionaries representing release rules

TYPE: List[dict]

METHOD DESCRIPTION
__call__

Return the result of applying all the rules to a commit.

rule_string

Return a string representation of the rules.

Functions

__call__
__call__(commit: CommitContext, current_branch: str) -> Optional[str]

Return the result of applying all the rules to a commit.

PARAMETER DESCRIPTION
commit

The commit context to apply rules to

TYPE: CommitContext

current_branch

The name of the current branch

TYPE: str

RETURNS DESCRIPTION
Optional[str]

The release hint

rule_string
rule_string() -> str

Return a string representation of the rules.

Functions

format_bool

format_bool(bool_var: bool) -> Text

Format a boolean value as a string.

get_commit_results

get_commit_results(
    results: List[ReleaseRuleResult],
) -> Iterable[RenderableType]

Return the contents of the commit results table.

output_report

output_report(
    renderables: List[RenderableType], path: Optional[Path] = None
) -> None

Output the release hint report.

print_table

print_table(results: dict, commit_results: dict) -> RenderableType

Print the test results as a table.

suggest_release_type

suggest_release_type(
    current_branch: str,
    version_contexts: List[VersionContext],
    config: Configuration,
) -> str

Suggest the type of release based on the unreleased commits.

PARAMETER DESCRIPTION
current_branch

The name of the current branch

TYPE: str

version_contexts

The processed commits to process

TYPE: List[VersionContext]

config

The current configuration

TYPE: Configuration

RETURNS DESCRIPTION
str

The type of release based on the rules, or no-release