From fd05690bdd4f5644e2d89f4243e8966bc07d9924 Mon Sep 17 00:00:00 2001 From: Rome Thorstenson <36779795+Rome-1@users.noreply.github.com> Date: Sat, 26 Sep 2026 18:56:29 -0700 Subject: [PATCH] Newsletter dropped every commit made before the hour it ran (#6491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * The newsletter dropped every commit made before the hour it ran `--since` takes an APPROXIDATE, so the bare date this built did not mean the start of that day -- it meant that day at the CURRENT TIME OF DAY. Measured on a live tree at 17:02 local: git log --since=2026-09-10 -> 0 commits git log --since=2026-09-10T00:00:00 -> 60 commits Sixty commits dropped, silently, in a script whose output is published. The same invocation answered differently depending on the hour it ran. The half-fix is a trap, and it is the one the town-wide description leads to. The finding has been circulated as "--since is a traversal cutoff"; that is true and it is not this bug. Swapping in --since-as-filter while keeping the bare date keeps the whole defect, because approxidate applies to the VALUE regardless of which flag reads it: git log --since-as-filter=2026-09-10 -> 0 commits git log --since-as-filter=2026-09-10T00:00:00 -> 60 commits So both are fixed here: a full timestamp for the approxidate, and --since-as-filter (git 2.37+) for the cutoff, with a comment saying not to simplify either back. FOUR copies, not the three named, in two versions drifted 184 lines apart -- beads/{mayor,refinery} and gastown/{mayor,refinery}. The defective block was byte-identical in both (md5 6fdd32e6 over lines 156-160). All four working trees are patched; the 184-line drift is left alone, because converging them is a decision nobody has made. Verified through the patched code rather than by exit code: exec'ing the new get_commits_since for 2026-09-10 returns 60 where the old form returns 0. igr-9qdx Executed-By: mayor * fix(newsletter): fail loudly when git is too old for --since-as-filter --since-as-filter needs git 2.37 (2022-06). On anything older `git log` exits 129 with `error: unknown option 'since-as-filter=...'` on stderr, stdout is empty, and get_commits_since returned [] — reproducing the silent-and-shorter newsletter this change exists to fix, with a new cause. Check the return code and raise with the version floor named. An empty stdout on a zero exit is still a legitimate "no commits in range". Verified against a shim that rejects the flag the way git < 2.37 does: with the guard, RuntimeError naming the floor; with it reverted, 0 commits and no error; on real git 2.43, 40 commits, unchanged. * docs(newsletter): record the new git >= 2.37 floor --since-as-filter puts the script's first hard git-version floor on the release path (beads-release.formula.toml:866/:870 -> release-complete), but nothing outside get_commits_since()'s docstring said so. On an older runner the release step aborts and the operator has to trace the cause into a function body. Add it to the module docstring alongside its existing requirement sections, and to the README Setup section. No silent fallback to plain --since -- that reinstates the truncation this PR exists to remove. Placement is deliberate: the prose does NOT go in the `# /// script` PEP 723 block. That fence is parsed as TOML, so a comment line there is a hard launcher failure, measured on uv 0.9.5: # /// script # requires-python = ">=3.10" # Requires git >= 2.37 for --since-as-filter # /// $ uv run probe.py error: TOML parse error at line 3, column 10 ... key with no value exit 2 The docstring already carries the Usage / Environment Variables / Configuration File sections, so Requirements belongs beside them. After the edit `uv run scripts/generate-newsletter.py --help` exits 0, and the error string quoted in the README is byte-identical to the f-string it documents. Co-Authored-By: Claude Opus 5 --------- Co-authored-by: Julian Knutsen Co-authored-by: Claude Opus 5 --- scripts/generate-newsletter.py | 39 ++++++++++++++++++++++++--- scripts/generate-newsletter_README.md | 7 +++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/scripts/generate-newsletter.py b/scripts/generate-newsletter.py index b52785c91..3378ed8fe 100755 --- a/scripts/generate-newsletter.py +++ b/scripts/generate-newsletter.py @@ -12,6 +12,11 @@ """ Generate a weekly Beads newsletter based on changelog, commits, and changes. +Requirements: + git >= 2.37 - get_commits_since() passes --since-as-filter to git log + (added in git 2.37, 2022-06). On older git the script + raises rather than silently reporting an empty range. + Usage: python generate-newsletter.py python generate-newsletter.py --model gpt-4o @@ -154,13 +159,41 @@ def get_previous_version() -> tuple[str, datetime]: def get_commits_since(since_date: datetime) -> list[dict]: - """Get git commits since the given date.""" + """Get git commits since the given date. + + Two things below are deliberate, and both of them were bugs whose failure + direction is silent-and-shorter: the newsletter comes out missing commits + and nothing about it looks wrong. + + THE TIMESTAMP IS WRITTEN OUT IN FULL because `--since` takes an + APPROXIDATE, and a bare `2026-09-10` does not mean the start of that day -- + it means that day at the CURRENT TIME OF DAY. Measured on this tree at + 17:02 local, `git log --since=2026-09-10` returned 0 commits where + `--since=2026-09-10T00:00:00` returned 60. Every commit made before the + hour the script happens to run is dropped, so the same command answers + differently depending on when it is invoked. + + `--since-as-filter` IS NOT A TYPO. Plain `--since` is a traversal CUTOFF: + git stops walking the moment it meets a commit older than the bound, so any + commit whose date is out of order with its topology -- rebase, cherry-pick, + imported history, clock skew between machines -- is dropped even though it + is inside the range. `--since-as-filter` (git 2.37+) walks the whole + history and filters, which is what a date range is supposed to mean. + + Do not "simplify" either one back. (igr/fable, 2026-09-10.) + """ + since_arg = since_date.strftime('%Y-%m-%dT%H:%M:%S') result = subprocess.run( - ["git", "log", f"--since={since_date.strftime('%Y-%m-%d')}", "--oneline", "--format=%h|%s|%an|%ai"], + ["git", "log", f"--since-as-filter={since_arg}", "--oneline", "--format=%h|%s|%an|%ai"], capture_output=True, text=True ) - + if result.returncode != 0: + raise RuntimeError( + "git log failed (--since-as-filter needs git >= 2.37): " + f"{result.stderr.strip()}" + ) + commits = [] for line in result.stdout.strip().split('\n'): if line: diff --git a/scripts/generate-newsletter_README.md b/scripts/generate-newsletter_README.md index 3b8161b7f..50a663482 100644 --- a/scripts/generate-newsletter_README.md +++ b/scripts/generate-newsletter_README.md @@ -4,6 +4,13 @@ This script generates a weekly Beads newsletter based on the changelog, git comm ## Setup +### Requirements + +- **git >= 2.37** (2022-06). The commit range is collected with `git log + --since-as-filter`, which older git does not support. On older git the script + fails with `git log failed (--since-as-filter needs git >= 2.37): ...` instead + of generating a newsletter that silently omits commits. + ### Environment Variables Set the appropriate API key for your chosen model: