Bench a shipped feature whose branch landed by fast-forward from the commits after the item shipped before it
CI / tests (pull_request) Failing after 4m50s
CI / tests (pull_request) Failing after 4m50s
This commit is contained in:
@@ -14,15 +14,15 @@ from branch_chunks.read import cut_with_shipped, unsupported
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import Git
|
||||
from plan.todo_table import Item, tagline_text
|
||||
from branch_chunks.cut import Landing
|
||||
from project_config.main import located
|
||||
from task_bench.runs import of_tests
|
||||
from project_config.settings import RECORDS
|
||||
from task_bench.figures import Side, SIDES
|
||||
|
||||
# Why a feature whose chunk landed by fast-forward is passed over. Each of its commits is a chunk of its own to branch_chunks,
|
||||
# so the chunk that took the item out holds the branch's last commit alone.
|
||||
FAST_FORWARDED = "its branch landed by fast-forward, so the history doesn't say which commits built it"
|
||||
# Why a feature whose chunk landed by fast-forward and has no earlier feature before it is passed over. Each of its commits is a
|
||||
# chunk of its own to branch_chunks, so the chunk that took the item out holds the branch's last commit alone, and only the commit
|
||||
# of the feature shipped before it says where the branch starts.
|
||||
FAST_FORWARDED = "its branch landed by fast-forward, and no feature shipped before it to say which commits built it"
|
||||
|
||||
# The options that keep the checkout's diff config out of a patch. --no-renames writes a renamed file as one file removed and
|
||||
# one added, so `git apply` doesn't have to detect the rename again.
|
||||
@@ -31,13 +31,13 @@ PLAIN_DIFF = ("--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", "-
|
||||
|
||||
class Shipped(typing.NamedTuple):
|
||||
"""A feature the project shipped: the name the report gives it, such as `item 7`, the tagline of each item its chunk took out
|
||||
of the plan, a paragraph each, the commits its chunk's change runs between, and how the chunk landed."""
|
||||
of the plan, a paragraph each, and the commits its change runs between. before is None where the history doesn't say where
|
||||
the change starts."""
|
||||
|
||||
name: str
|
||||
told: str
|
||||
before: str
|
||||
before: str | None
|
||||
tip: str
|
||||
landing: Landing
|
||||
|
||||
|
||||
class ShippedFeatures(typing.NamedTuple):
|
||||
@@ -62,11 +62,20 @@ def read_shipped(home: pathlib.Path, checkout: str, base: str, git: Git) -> Ship
|
||||
if isinstance(cut, Failure):
|
||||
return cut
|
||||
branch, shipped = cut
|
||||
found = [
|
||||
Shipped(named(items), "\n\n".join(tagline_text(item.tagline) for item in items), chunk.before, chunk.tip, chunk.landing)
|
||||
for chunk, items in zip(branch.chunks, shipped)
|
||||
if items and chunk.before
|
||||
]
|
||||
found: list[Shipped] = []
|
||||
# The oldest chunk first, so each feature knows the commit the one before it shipped at.
|
||||
shipped_at = None
|
||||
for chunk, items in reversed(list(zip(branch.chunks, shipped))):
|
||||
if not items:
|
||||
continue
|
||||
if chunk.before:
|
||||
# A fast-forwarded branch keeps a commit time per commit, so branch_chunks cuts each commit into a chunk of its own, and
|
||||
# this chunk holds only the commit that took the item out. The feature is every commit since the last item shipped.
|
||||
starts = shipped_at if chunk.landing == "push" else chunk.before
|
||||
told = "\n\n".join(tagline_text(item.tagline) for item in items)
|
||||
found.append(Shipped(named(items), told, starts, chunk.tip))
|
||||
shipped_at = chunk.tip
|
||||
found.reverse()
|
||||
if not found:
|
||||
return Failure("No chunk on the base's history took an item out of todo.md, so that history holds no shipped feature to rebuild.")
|
||||
return ShippedFeatures(found, [path for path in map(config.tracked, ("plan", *RECORDS)) if path])
|
||||
@@ -89,7 +98,7 @@ def shipped_tasks(bench: Bench, shipped: ShippedFeatures, count: int) -> Planned
|
||||
break
|
||||
# A feature passed over leaves no folder, so the next one tried takes the same number.
|
||||
folder = bench.folder / "shipped-features" / str(len(tasks) + 1)
|
||||
taken_out = FAST_FORWARDED if feature.landing == "push" else on_disk(f"take {feature.name} out of the trees in {folder}", lambda: without(bench, feature, shipped.records, folder))
|
||||
taken_out = FAST_FORWARDED if feature.before is None else on_disk(f"take {feature.name} out of the trees in {folder}", lambda: without(bench, feature, shipped.records, folder))
|
||||
why = taken_out if not isinstance(taken_out, TakenOut) else why_passed_over(bench, taken_out.trees, taken_out.feature)
|
||||
if isinstance(why, Failure):
|
||||
return why
|
||||
|
||||
Reference in New Issue
Block a user