Merge remote-tracking branch 'origin/main' into item-532
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
# Conflicts: # todo.md
This commit is contained in:
+10
-6
@@ -95,17 +95,21 @@ such as QZ, and never XK, which is Kosovo's in practice. The table has a row per
|
||||
--tasks shipped-features benches rebuilding features the project shipped, so nobody writes a task. A shipped feature is a chunk
|
||||
on the base's first-parent history that took an item out of `todo.md`. A chunk is a merge commit with what it merged, or the
|
||||
commits a rebase landed together, which share a commit time. A chunk with a commit whose title opens `Drop item <ID>:` took
|
||||
that item out unbuilt, so it didn't ship it. The bench goes through the shipped features newest first, until --shipped of
|
||||
them, 5 by default, count. For each:
|
||||
- it takes the chunk's change out of a copy of each side's tree, as `git apply -R` does. The plan and the project's records stay
|
||||
that item out unbuilt, so it didn't ship it. Commits fast-forwarded onto the branch keep a commit time each, so each is a chunk
|
||||
of its own, and the chunk that took the item out holds only the feature's last commit. The feature then starts after the latest
|
||||
earlier chunk that took an item out or landed by a merge or a rebase. A commit between two features that belongs to neither
|
||||
joins the later one; it counts only where its tests fail after the revert and pass with the reference patch, as for any feature.
|
||||
A fast-forwarded feature is passed over where no such chunk comes before it, and where its branch merged the default branch into
|
||||
itself, since its commits then hold the changes of the features that merge brought in. A merge titled
|
||||
`Merge remote-tracking branch '...' into <branch>` is read as that, whatever the branch. The bench goes through the shipped
|
||||
features newest first, until --shipped of them, 5 by default, count. For each:
|
||||
- it takes the feature's change out of a copy of each side's tree, as `git apply -R` does. The plan and the project's records stay
|
||||
as the side holds them, since later chunks added to them. The records are the changelog, the comprehension history, the
|
||||
decisions, the reading cost and the score anchors. So Haiku can read there what the changelog says of the feature;
|
||||
- Haiku is told the tagline of the item, or of each item the chunk shipped;
|
||||
- the acceptance tests are the test files the change touched, and its files under a `testdata` folder, each as the head holds it;
|
||||
- the reference patch is the change itself.
|
||||
With those, a shipped feature counts, and a build passes, as for a feature. The bench also passes over three kinds:
|
||||
- one whose branch landed by fast-forward. Its commits keep a commit time each, so the history doesn't say which of them
|
||||
built it;
|
||||
With those, a shipped feature counts, and a build passes, as for a feature. The bench also passes over two kinds:
|
||||
- one whose change doesn't come out of both trees cleanly, as where a later chunk rewrote its lines;
|
||||
- one whose change touched no test the head still holds.
|
||||
The report says which and why. The table has a row per shipped feature and side, named by its items, as `item 7`.
|
||||
|
||||
@@ -5,6 +5,7 @@ is checked."""
|
||||
import functools
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
@@ -14,15 +15,18 @@ 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 that landed by fast-forward is passed over: no earlier chunk says where its commits start, or its branch merged
|
||||
# the default branch into itself, so its commits hold what other features built.
|
||||
NO_START = "its branch landed by fast-forward, and nothing earlier marks where its commits start"
|
||||
MERGED_IN = "its branch landed by fast-forward after merging the default branch into itself, so its commits hold other features' changes"
|
||||
# What git titles a merge of the default branch into a feature branch, other than into main or master, which git leaves out of
|
||||
# the title. A person's merge of a branch into another default branch has the same title; its feature is then passed over.
|
||||
SYNC_MERGE = re.compile(r"Merge (?:remote-tracking )?branch '[^']+' into (?!main$|master$)\S+")
|
||||
|
||||
# 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 +35,14 @@ 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, and passed_over then says why."""
|
||||
|
||||
name: str
|
||||
told: str
|
||||
before: str
|
||||
before: str | None
|
||||
tip: str
|
||||
landing: Landing
|
||||
passed_over: str = ""
|
||||
|
||||
|
||||
class ShippedFeatures(typing.NamedTuple):
|
||||
@@ -62,11 +67,24 @@ 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 that ends the chunk before it.
|
||||
marked = None
|
||||
merged_in = False
|
||||
for chunk, items in reversed(list(zip(branch.chunks, shipped))):
|
||||
if items:
|
||||
# A fast-forwarded feature's commits are a chunk each, and this chunk holds only the last. The earlier ones follow the
|
||||
# commit that ends the latest earlier chunk of another feature.
|
||||
starts, why = chunk.before, ""
|
||||
if chunk.landing == "push":
|
||||
starts, why = (None, NO_START) if marked is None else (None, MERGED_IN) if merged_in else (marked, "")
|
||||
told = "\n\n".join(tagline_text(item.tagline) for item in items)
|
||||
found.append(Shipped(named(items), told, starts, chunk.tip, why))
|
||||
if SYNC_MERGE.fullmatch(branch.commits[chunk.tip].title):
|
||||
merged_in = True
|
||||
elif items or chunk.landing != "push":
|
||||
marked, merged_in = chunk.tip, False
|
||||
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 +107,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 = feature.passed_over if feature.before is None else on_disk(f"take {feature.name} out of the trees in {folder}", functools.partial(without, bench, feature, feature.before, 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
|
||||
@@ -117,12 +135,12 @@ class TakenOut(typing.NamedTuple):
|
||||
feature: Feature
|
||||
|
||||
|
||||
def without(bench: Bench, shipped: Shipped, records: list[str], folder: pathlib.Path) -> TakenOut | str | Failure:
|
||||
"""shipped taken out of a copy of each side's tree, under folder, where its patch and its acceptance tests go too; or why it
|
||||
def without(bench: Bench, shipped: Shipped, before: str, records: list[str], folder: pathlib.Path) -> TakenOut | str | Failure:
|
||||
"""shipped, as the commits from before to its tip, taken out of a copy of each side's tree, under folder, where its patch and its acceptance tests go too; or why it
|
||||
cannot be, which ends a sentence that opens with its name. A Failure where git fails.
|
||||
|
||||
Raises OSError where a file cannot be copied."""
|
||||
change = (shipped.before, shipped.tip, "--", ".", *(f":(exclude,literal){path}" for path in records))
|
||||
change = (before, shipped.tip, "--", ".", *(f":(exclude,literal){path}" for path in records))
|
||||
# A name that is not UTF-8 is read with U+FFFD in it. The head's tree holds no file of that name, so the file is left out.
|
||||
names = bench.git("diff", "--name-only", "-z", *change, cwd=bench.checkout, errors="replace")
|
||||
if isinstance(names, Failure):
|
||||
|
||||
@@ -17,8 +17,8 @@ from task_bench.test_task_bench import BASE_CODE, HEAD_CODE
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git
|
||||
from task_bench import main
|
||||
from task_bench.shipped_features import MERGED_IN, read_shipped
|
||||
from branch_chunks.read import READ_AT
|
||||
from task_bench.shipped_features import read_shipped
|
||||
|
||||
HEADER = "| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves |\n|---|---|---|---|---|---|---|---|---|---|---|\n"
|
||||
ROWS = {
|
||||
@@ -92,6 +92,35 @@ class ShippedFeaturesCase(BenchOfTasksCase):
|
||||
self.env.pop(name, None)
|
||||
|
||||
|
||||
def fast_forwarded_item_11(self):
|
||||
"""Item 11 lands as a fast-forward leaves a branch: a plan commit, the feature and the commit that takes the item out, each
|
||||
with the time it was written at, so each is a chunk of its own to branch_chunks. The head branches off after them."""
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(11)
|
||||
self.landed(6, "Plan an item", written_then=True)
|
||||
(self.repo / "third.go").write_text("package calc\n")
|
||||
(self.repo / "third_test.go").write_text("test -e third.go\n")
|
||||
self.landed(7, "Add Third", written_then=True)
|
||||
self.plan()
|
||||
self.landed(8, "Finish item 11 in the plan", written_then=True)
|
||||
self.git("checkout", "--quiet", "-B", "item-1")
|
||||
(self.repo / "calc.go").write_text(HEAD_CODE)
|
||||
self.commit("Head")
|
||||
|
||||
def fast_forwarded_item_11_alone(self):
|
||||
"""Makes the default branch a history of its own, where item 11 is the one item shipped, and it landed by fast-forward."""
|
||||
self.git("checkout", "--quiet", "--orphan", "fresh")
|
||||
self.git("rm", "--quiet", "-r", "-f", ".")
|
||||
self.plan(11)
|
||||
(self.repo / "calc_test.go").write_text("exit 0\n")
|
||||
self.landed(1, "Plan an item", written_then=True)
|
||||
(self.repo / "third.go").write_text("package calc\n")
|
||||
self.landed(2, "Add Third", written_then=True)
|
||||
self.plan()
|
||||
self.landed(3, "Finish item 11 in the plan", written_then=True)
|
||||
self.git("branch", "--quiet", "--force", "main", "fresh")
|
||||
|
||||
|
||||
class ShippedFeatureBenchTest(ShippedFeaturesCase):
|
||||
def test_has_haiku_rebuild_each_shipped_feature_from_its_tagline_and_checks_it_with_the_tests_its_change_added(self):
|
||||
report = self.bench()
|
||||
@@ -175,23 +204,22 @@ class ShippedFeatureBenchTest(ShippedFeaturesCase):
|
||||
self.assertEqual(report.reason, "No shipped feature on the base's history counts; the lines above say why.")
|
||||
self.assertIn("task-bench: passed over the shipped feature item 8: its revert doesn't apply at the head.", self.progress.getvalue().splitlines())
|
||||
|
||||
def test_passes_over_a_feature_whose_branch_landed_by_fast_forward(self):
|
||||
# Each commit keeps the time it was written at, so the commit that takes the item out is a chunk of its own.
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(11)
|
||||
self.landed(6, "Plan an item")
|
||||
(self.repo / "third.go").write_text("package calc\n")
|
||||
(self.repo / "third_test.go").write_text("test -e third.go\n")
|
||||
self.landed(7, "Add Third", written_then=True)
|
||||
self.plan()
|
||||
self.landed(8, "Finish item 11 in the plan", written_then=True)
|
||||
# The bench's base is where the head left the default branch, so the head leaves it after item 11.
|
||||
def test_rebuilds_a_feature_whose_branch_landed_by_fast_forward_from_the_commits_after_the_item_shipped_before_it(self):
|
||||
self.fast_forwarded_item_11()
|
||||
report = self.bench(**{"--shipped": "1"})
|
||||
self.assertNotIsInstance(report, Failure, report)
|
||||
# Nothing is passed over, and the feature has a row at each side.
|
||||
self.assertEqual(report[1], "")
|
||||
self.assertEqual([line[:23] for line in report if line.startswith("| 1: item 11")], ["| 1: item 11 | base | 0", "| 1: item 11 | head | 0"])
|
||||
|
||||
def test_passes_over_a_fast_forwarded_feature_where_no_item_shipped_before_it(self):
|
||||
self.fast_forwarded_item_11_alone()
|
||||
self.git("checkout", "--quiet", "-B", "item-1")
|
||||
(self.repo / "calc.go").write_text(HEAD_CODE)
|
||||
self.commit("Head")
|
||||
report = self.bench(**{"--shipped": "1"})
|
||||
self.assertNotIsInstance(report, Failure, report)
|
||||
self.assertEqual(report[1], "Passed over the shipped feature item 11: its branch landed by fast-forward, so the history doesn't say which commits built it.")
|
||||
self.assertEqual(report.reason, "No shipped feature on the base's history counts; the lines above say why.")
|
||||
self.assertIn("task-bench: passed over the shipped feature item 11: its branch landed by fast-forward, and nothing earlier marks where its commits start.", self.progress.getvalue().splitlines())
|
||||
|
||||
def test_fails_before_docker_runs_where_the_history_shipped_no_item(self):
|
||||
self.git("branch", "--quiet", "--force", "main", "main~8")
|
||||
@@ -221,6 +249,41 @@ class ReadShippedTest(ShippedFeaturesCase):
|
||||
])
|
||||
self.assertEqual(shipped.records, ["todo.md", "decisions.md", "score-anchors.md", "docs/comprehension-history.md", "docs/reading-cost.md", "changelog.md"])
|
||||
|
||||
def test_a_fast_forwarded_feature_starts_after_the_chunk_that_shipped_the_item_before_it(self):
|
||||
self.fast_forwarded_item_11()
|
||||
newest = self.read().found[0]
|
||||
self.assertEqual((newest.name, newest.before, newest.tip), ("item 11", self.git("rev-parse", "main~3"), self.git("rev-parse", "main")))
|
||||
|
||||
def test_a_fast_forwarded_feature_with_no_item_shipped_before_it_has_no_start(self):
|
||||
self.fast_forwarded_item_11_alone()
|
||||
self.assertEqual([(feature.name, feature.before) for feature in self.read().found], [("item 11", None)])
|
||||
|
||||
def fast_forwarded_item_11_around_a_merge(self, title):
|
||||
"""Item 11's commits, fast-forwarded, with a merge of a commit from a side branch between them under title. Returns the merge's hash."""
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.git("branch", "--quiet", "side")
|
||||
self.git("checkout", "--quiet", "side")
|
||||
(self.repo / "other.go").write_text("package calc\n")
|
||||
self.landed(5, "Other work")
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(11)
|
||||
self.landed(6, "Plan an item", written_then=True)
|
||||
(self.repo / "third.go").write_text("package calc\n")
|
||||
self.landed(7, "Add Third", written_then=True)
|
||||
self.git("merge", "--quiet", "--no-ff", "--message", title, "side")
|
||||
self.plan()
|
||||
self.landed(9, "Finish item 11 in the plan", written_then=True)
|
||||
return self.git("rev-parse", "main~1")
|
||||
|
||||
def test_passes_over_a_fast_forwarded_feature_whose_branch_merged_the_default_branch_into_itself(self):
|
||||
self.fast_forwarded_item_11_around_a_merge("Merge remote-tracking branch 'origin/main' into item-11")
|
||||
newest = self.read().found[0]
|
||||
self.assertEqual((newest.name, newest.before, newest.passed_over), ("item 11", None, MERGED_IN))
|
||||
|
||||
def test_a_fast_forwarded_feature_starts_after_a_chunk_that_landed_by_a_merge_and_shipped_no_item(self):
|
||||
merge = self.fast_forwarded_item_11_around_a_merge("Merge pull request 'Release review' (#7) from release-review into main")
|
||||
self.assertEqual(self.read().found[0].before, merge)
|
||||
|
||||
def test_a_chunk_that_shipped_two_items_is_one_feature_told_by_both_taglines(self):
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(7, 8)
|
||||
@@ -231,6 +294,14 @@ class ReadShippedTest(ShippedFeaturesCase):
|
||||
self.assertEqual((newest.name, newest.told), ("items 7, 8", "Add `Halve`, which halves a whole number.\n\nMultiply in `Twice`."))
|
||||
self.assertEqual((newest.before, newest.tip), (self.git("rev-parse", "main~3"), self.git("rev-parse", "main")))
|
||||
|
||||
def test_a_feature_that_landed_by_a_rebase_starts_at_its_own_chunk_whatever_was_fast_forwarded_before_it(self):
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(11)
|
||||
self.landed(6, "Plan an item", written_then=True)
|
||||
self.plan()
|
||||
self.landed(7, "Build it", "Finish item 11 in the plan")
|
||||
self.assertEqual(self.read().found[0].before, self.git("rev-parse", "main~2"))
|
||||
|
||||
def test_an_item_a_commit_title_drops_is_not_shipped(self):
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(8)
|
||||
|
||||
Reference in New Issue
Block a user