Skip to content

release_utils

assert_branch(branch, step)

Assert that a release step is done in the proper branch.

This can only happen in release/x.y.z or hotfix/x.y.z.

Parameters:

Name Type Description Default
branch str

branch name to verify.

required
step str

the release step name.

required

Returns:

Type Description
Res[tuple[str, str]]

An Issue if the current branch is not a release/hotfix else the

Res[tuple[str, str]]

release type and version to release/hotfix.

Source code in m/ci/release_utils.py
def assert_branch(branch: str, step: str) -> Res[tuple[str, str]]:
    """Assert that a release step is done in the proper branch.

    This can only happen in `release/x.y.z` or `hotfix/x.y.z`.

    Args:
        branch: branch name to verify.
        step: the release step name.

    Returns:
        An Issue if the current branch is not a release/hotfix else the
        release type and version to release/hotfix.
    """
    valid_prefix = ('release/', 'hotfix/')
    if branch.startswith(valid_prefix):
        parts = branch.split('/')
        return Good((parts[0], parts[1]))
    return issue(
        f'{step}_release can only be done from a release/hotfix branch',
        context={
            'current_branch': branch,
            'expected': 'release/x.y.z or hotfix/x.y.z',
        },
    )

is_yes(user_response)

Assert the user response is "yes".

Parameters:

Name Type Description Default
user_response str

user's response

required

Returns:

Type Description
bool

True if the string is "yes".

Source code in m/ci/release_utils.py
def is_yes(user_response: str) -> bool:
    """Assert the user response is "yes".

    Args:
        user_response: user's response

    Returns:
        True if the string is "yes".
    """
    return user_response == 'yes'