Skip to content

livery.workshop._update

livery.workshop._update

The update family's file movers.

The pieces workflow.update drives: raise [[depends]] floors to the latest released tags, and read the newest release per package from the tags. The driver that branches, commits, and submits lives beside this module.

Functions:

Name Description
latest_released

The newest released version per package path, from tags.

bump_floors

Raise floors to the latest released tags; what changed.

latest_released

latest_released(tags: tuple[str, ...]) -> dict[str, str]

The newest released version per package path, from tags.

Source code in packages/workshop/src/livery/workshop/_update.py
def latest_released(tags: tuple[str, ...]) -> dict[str, str]:
    """The newest released version per package path, from *tags*."""
    latest: dict[str, tuple[int, int, int]] = {}
    for tag in tags:
        found = release_tag(tag)
        if found is None:
            continue
        path, text = found
        major, minor, patch = (int(part) for part in text.split("."))
        version = (major, minor, patch)
        if version > latest.get(path, (-1, -1, -1)):
            latest[path] = version
    return {path: ".".join(map(str, v)) for path, v in latest.items()}

bump_floors

bump_floors(root: Path, *, only: tuple[str, ...] = ()) -> list[str]

Raise floors to the latest released tags; what changed.

A floor names the oldest version a dependant accepts; this raises it to the newest release so instances move together. Both homes move in step: the [[depends]] edge in workshop.toml and the >= constraint in pyproject.toml. only scopes the move to floors on the named distributions (livery-forge); empty moves every floor.

Source code in packages/workshop/src/livery/workshop/_update.py
def bump_floors(root: Path, *, only: tuple[str, ...] = ()) -> list[str]:
    """Raise floors to the latest released tags; what changed.

    A floor names the oldest version a dependant accepts; this raises
    it to the newest release so instances move together. Both homes
    move in step: the ``[[depends]]`` edge in ``workshop.toml`` and the
    ``>=`` constraint in ``pyproject.toml``. *only* scopes the move
    to floors on the named distributions (``livery-forge``); empty
    moves every floor.
    """
    packages = discover_packages(root)
    dist_names = {p.path: p.name for p in packages}
    released = latest_released(git.tags(root))
    changed = []
    for package in packages:
        for edge in package.depends:
            if only and dist_names.get(edge.path, "") not in only:
                continue
            newest = released.get(edge.path, "")
            if not edge.floor or not newest or newest == edge.floor:
                continue
            contract = package.directory / "workshop.toml"
            text = contract.read_text("utf-8")
            scoped = _bump_edge_floor(text, edge.path, edge.floor, newest)
            contract.write_text(scoped, encoding="utf-8")
            pyproject = package.directory / "pyproject.toml"
            text = pyproject.read_text("utf-8")
            pyproject.write_text(
                text.replace(f">={edge.floor}", f">={newest}"), encoding="utf-8"
            )
            changed.append(
                f"{package.path}: floor on {edge.path} {edge.floor} -> {newest}"
            )
    return changed