fix(rees): consolidate diff-header detection onto shared isDiffFileHeaderLine#2705
Conversation
…aderLine
dependency-scan and lockfile-drift still used the anchored `startsWith("+++ ")`
/ `startsWith("---")` guard that the shared isDiffFileHeaderLine helper replaced
in the other patch-scanning analyzers. That guard misclassifies added/removed
CONTENT whose text begins with `++`/`--` (git renders content `++ x` as the diff
line `+++ x`) as a unified-diff file header.
In lockfile-drift's line-number generator this is a real off-by-one: a wrongly
skipped `+++`-content added line does not advance the new-file counter, so every
drift finding after it is reported one line too low. In dependency-scan the
anchored guard is behavior-equivalent for the structured manifests it parses but
is consolidated here for a single source of truth. Both now delegate to
isDiffFileHeaderLine, which matches only real `+++ a/`/`b/`/`/dev/null` headers.
Adds a lockfile-drift regression pinning the corrected line number across a
++-content added line, and a dependency-scan guard that real file headers are
skipped while the version bump is still extracted.
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-03 07:35:31 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
What
Two rees analyzers —
dependency-scanandlockfile-drift— still used the anchored inline guardto skip unified-diff file headers, instead of the shared
isDiffFileHeaderLinehelper that the other patch-scanning analyzers (diff-lines,heavy-dependency,history) already delegate to.Why it matters
That anchored guard misclassifies added/removed content whose text begins with
++/--as a file header: git renders an added line whose content is++ xas the diff line+++ x, and---likewise. The shared helper deliberately keys on the header's path form (+++ a/,+++ b/,+++ /dev/null) precisely to avoid this — it's documented indiff-lines.tsand covered bydiff-lines.test.ts.In
lockfile-driftthis is an observable off-by-one. Its line-number generator advances the new-file counter per emitted line; a+++-content line wrongly hit by the old guard iscontinued without advancing the counter, so every drift finding after it is reported one line too low:In
dependency-scanthe anchored guard is behavior-equivalent for the structured manifests it parses (npm/PyPI/Go lines never begin++/--), but it's the same drifted copy, so it's consolidated here for a single source of truth — completing the migration toisDiffFileHeaderLine.Tests
lockfile-drift.test.ts: new regression asserting the corrected line number (12) across an intervening++-content added line — fails on the old guard, passes now.dependency-scan.test.ts(new file): guards that real--- a/…/+++ b/…headers are skipped while the real version bump is still extracted.Full
node --testsuite green except the two pre-existingupload-sourcemapstests that require Sentry-CLI locally (unrelated; pass in CI).