fix(changed-since): resolve paths relative to cwd, not the repo root - #33
Merged
Merged
Conversation
TWD Contract Validation
23 passed · 41 failed · 3 warnings · 1 skipped Failed validations./contracts/users-3.0.json
./contracts/posts-3.1.json
./contracts/products-3.0.json
./contracts/events-3.1.json
|
`git diff --name-only` reports from the repository root while `git ls-files` reports from cwd, and the paths are then reused relative to cwd twice: as the pathspec of the `diff -U0`, and by `path.resolve(cwd, file)`. Below the root — `working-directory: packages/web`, which is what both composite actions do — that built the pathspec `packages/web/packages/web/…`. It matched nothing, so `files` was populated but no titles came out, and `--changed-since` reported "No tests changed" on a branch that had just added tests. Through the record action it read as "nothing to record" on the PR that added them. `--relative` makes diff agree with ls-files. It is a no-op from the root, so single-package callers are unaffected. The test helper now models git only returning cwd-relative paths when asked, so the two new cases fail without the fix.
kevinccbsg
force-pushed
the
fix/changed-since-from-subdirectory
branch
from
September 18, 2026 18:26
1725bd4 to
79d4260
Compare
TWD Contract Validation
23 passed · 41 failed · 3 warnings · 1 skipped Failed validations./contracts/users-3.0.json
./contracts/posts-3.1.json
./contracts/products-3.0.json
./contracts/events-3.1.json
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
--changed-sincefinds no titles whenever the CLI runs below the repository root, so a branch that added tests reports none. In therecordaction that surfaces as a PR comment saying there is nothing to record, on the very pull request that added the tests.Reproduced in a real npm-workspaces monorepo, with the tests in
packages/web:The cause
The two git commands in
resolveChangedTitlesdisagree about what their paths are relative to:Those paths are then used relative to cwd twice: as the pathspec of the
diff -U0that reads the added lines, and bypath.resolve(cwd, file)in the whole-file fallback. So the pathspec becamepackages/web/packages/web/…, matched nothing, and no titles were extracted —fileswas populated,titleswas empty:Both composite actions run the CLI with
working-directory, so any consumer pointing them at a package of a monorepo hits this.The fix
One flag: ask git for
--relativesodiffagrees withls-files.From the repository root
--relativeis a no-op, so existing single-package callers are unaffected. Below the root it additionally scopes the diff to the package under test, which is what naming that directory meant.Tests
The mock previously returned the same paths whether or not
--relativewas asked for, so a test could not tell the two apart. It now models git — root-prefixed unless--relativeis passed — via arootPrefixoption that defaults to'', leaving every existing case unchanged.Two new cases cover the monorepo path, and both fail without the source change (verified by reverting it):
finds the titles when cwd is one package of a monoreporeads the whole file from cwd when the diff added no it()Three existing assertions were updated for the new command shape.
Full suite: 576 passed, 25 files. Verified end to end against the real monorepo — from
packages/webthe patched resolver now returns all three titles the branch added.