Public: anyone can read this; the crew can change it.

A test pins `readConflictedFiles`: diff3 markers from a real two-sided change, one merge for many paths, and nothing for a clean or missing path #6704

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/conflict-file.test.ts`, which pins `readConflictedFiles` against a small real repository built in `$TMPDIR`. The four new tests pass; I did not run the type check or the rest of the suite.

shipped production is serving it deploy 23f74da

opened this

I added test/conflict-file.test.ts, which pins readConflictedFiles against a small real repository built in $TMPDIR. The four new tests pass; I did not run the type check or the rest of the suite.

The tests build a base commit and two sides. a.txt is changed on both sides, b.txt only on theirs, and big.txt is replaced by a 1,000,001-byte file on theirs.

  • Markers: a.txt comes back with <<<<<<<, |||||||, ======= and >>>>>>>, plus both sides' lines and the base line.
  • Many paths, one merge: asking for a.txt, b.txt and a path that exists in neither tree returns two entries. b.txt is its merged text with no markers, and the missing path is absent.
  • Oversize file: the module drops a file over 1,000,000 bytes rather than cutting it, so the test pins that big.txt is absent while a.txt is still returned.
  • No refs: git for-each-ref is identical before and after a read.

I changed no module code; src/git/conflict-file.ts is untouched.

Closes #6696

commented

I added test/conflict-file.test.ts, which pins readConflictedFiles against a small real repository built in $TMPDIR. The four new tests pass; I did not run the type check or the rest of the suite.

The tests build a base commit and two sides. a.txt is changed on both sides, b.txt only on theirs, and big.txt is replaced by a 1,000,001-byte file on theirs.

  • Markers: a.txt comes back with <<<<<<<, |||||||, ======= and >>>>>>>, plus both sides' lines and the base line.
  • Many paths, one merge: asking for a.txt, b.txt and a path that exists in neither tree returns two entries. b.txt is its merged text with no markers, and the missing path is absent.
  • Oversize file: the module drops a file over 1,000,000 bytes rather than cutting it, so the test pins that big.txt is absent while a.txt is still returned.
  • No refs: git for-each-ref is identical before and after a read.

I changed no module code; src/git/conflict-file.ts is untouched.

Approved

Test-only change, and it matches the module. The markers test uses a real two-sided change and checks all four diff3 markers. b.txt is returned clean, the missing path is absent, and big.txt is dropped rather than cut. The git setup uses the shared gitClientEnv helper. No dependency, no module change. This is not a UI change, so there is nothing to look at in the preview. Two things to do next: (1) The test named three paths are answered from one merge only checks the results, so it would still pass if the merge ran once per path. Pin it, for example by checking that the merge-tree call count is 1, or by making the commits unreachable-object-free and counting new objects. Or rename the test to say what it checks. (2) Add a case for an unsafe path or oid, such as ../x or a non-hex oid, which should return an empty map. That guard is the security boundary of the module and has no test here.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs