Skip to content

Commit 929c205

Browse files
committed
fix(ci): build the record separator instead of writing the byte
`pnpm check:nul-bytes` refuses a raw ASCII control byte in any tracked file, and two places here carried one: the `git log -z` record separator and the self-test fixture that exercises it. The escape was materialised into the byte by the editor that wrote it, which is exactly the failure the gate names. `String.fromCharCode(0)` cannot be materialised into anything. Claude-Session: https://claude.ai/code/session_01MCLBsUgfykL74aU716rzVK Co-authored-by: Claude <noreply@anthropic.com>
1 parent f5e13cb commit 929c205

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎scripts/check-commit-card-trailers.mjs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ function objectExists(sha, cwd) {
364364
}
365365
}
366366

367+
/**
368+
* The record separator `git log -z` writes between commits.
369+
*
370+
* Built rather than typed: this repository refuses a raw control byte in any
371+
* tracked file (`pnpm check:nul-bytes`), and an editor asked to write the
372+
* escape can materialise it as the byte itself — which is how this line got
373+
* the gate's attention once already. `String.fromCharCode` cannot be
374+
* materialised into anything.
375+
*/
376+
const NUL = String.fromCharCode(0);
377+
367378
/**
368379
* The commits a rev-list range names, as `{ sha, message }` rows.
369380
*
@@ -377,7 +388,7 @@ export function readCommits(args, { cwd = ROOT, run = execFileSync } = {}) {
377388
maxBuffer: 64 * 1024 * 1024,
378389
});
379390
const rows = [];
380-
for (const record of String(out).split('
391+
for (const record of String(out).split(NUL)) {
381392
if (record.trim() === '') continue;
382393
const nl = record.indexOf('\n');
383394
if (nl < 0) {
@@ -714,7 +725,7 @@ function selfTest() {
714725
);
715726
t(
716727
'the walk reads NUL-terminated records, so a multi-line message stays one commit',
717-
readCommits([], { run: () => 'abc\nfix(x): s\n\nbody\n def\nfix(y): t\n' }).map((c) => c.sha).join(','),
728+
readCommits([], { run: () => ['abc\nfix(x): s\n\nbody\n', 'def\nfix(y): t\n'].join(NUL) }).map((c) => c.sha).join(','),
718729
'abc,def',
719730
);
720731

0 commit comments

Comments
 (0)