splitUnifiedDiff used bytes.Buffer to accumulate each file's diff, then stored buf.Bytes() into the result map and called buf.Reset() to start the next file. bytes.Buffer.Bytes() returns the buffer's internal backing slice; Reset() resets length to 0 but reuses the same backing array. As a result, every map entry aliased the same storage, so all files ended up showing the LAST file's diff content. Fix: copy the bytes into a fresh slice before storing in the map. Adds TestPRFilesDiffPerFileIsolation as a regression test that asserts each file entry contains its OWN diff --git header and none of the other files' headers. Verified failing on the prior code, passing after the fix. Closes #25
7.9 KiB
7.9 KiB