Skip to content

fix(ci): check the exact lock tree entry and clean up lockfix test dirs - #230

Merged
mforce merged 1 commit into
mainfrom
fix/lockfix-test-hygiene
Oct 27, 2026
Merged

mforce merged 1 commit into
mainfrom
fix/lockfix-test-hygiene

Conversation

@mforce

@mforce mforce commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Follow-up to #224. These fixes come from a code-quality review of mforce/cluckwork#1374, which ports part of this lockfix to cluckwork. I checked each finding against collectify's main, and these three apply here too.

Changes

  • The mode check looks at the exact entry. lockfix-apply.sh checked a lock's mode with git ls-files -s -- "$rel", which matches a path prefix. A directory committed at the lock path, holding one regular file, passed as 100644. The classifier refused that case later, so it was not a hole. The check now reads git ls-tree HEAD -- "$rel" and requires exactly 100644 blob.
  • The tests clean up after themselves. lockfix.test.mjs created scratch directories with mkdtempSync and never removed them. They now share one scratch root, which an after() hook deletes.
  • Small test fixes. The symlink test uses fileURLToPath instead of new URL(...).pathname, which breaks on a path with a space. The mode test now says it tests 100755, and it sets the mode with chmodSync and the existing commit helper.

Verification

  • node --test .github/scripts/lockfix.test.mjs .github/scripts/lockfix-stage.test.mjs passes 24 of 24. A new test commits a directory at the lock path and expects the abort.
  • Mutations: putting the old ls-files check back fails only the new directory test. Deleting the mode check fails both the 100755 test and the directory test.
  • A local review tried the new check on a scratch repo. It accepted a normal lock and refused 100755, a symlink, a directory, a gitlink and a missing path. It treated glob characters in a path literally, and refused a path named -h. It also ran the suite with a private TMPDIR, once with a test forced to fail: no scratch directories were left either time. The review found no defects.
  • shellcheck is clean on lockfix-apply.sh.

lockfix-apply.sh used `ls-files -s`, a pathspec match, so a directory
committed at a lock path passed the 100644 check through its child.
`ls-tree HEAD` reads the entry itself.

The tests now keep their scratch repos under one temp root removed in
after(), use fileURLToPath for the symlink target, and build the 100755
case with chmodSync plus the commit helper. A new test covers a directory
at the lock path.

Refs #224
@mforce
mforce merged commit 4c69642 into main Oct 27, 2026
10 checks passed
@mforce
mforce deleted the fix/lockfix-test-hygiene branch October 27, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant