| ... | ... | @@ -1449,6 +1449,44 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => { |
| 1449 | 1449 | }), |
| 1450 | 1450 | ); |
| 1451 | 1451 | |
| 1452 | for (const splitIndex of [false, true]) { |
| 1453 | it.effect(`keeps the preceding second cached in review previews (split: ${splitIndex})`, () => |
| 1454 | Effect.gen(function* () { |
| 1455 | const cwd = yield* makeTmpDir(); |
| 1456 | yield* initRepoWithCommit(cwd); |
| 1457 | const driver = yield* GitVcsDriver.GitVcsDriver; |
| 1458 | const fs = yield* FileSystem.FileSystem; |
| 1459 | const path = yield* Path.Path; |
| 1460 | yield* writeTextFile(cwd, ".gitattributes", "stable.txt filter=probe\n"); |
| 1461 | yield* writeTextFile(cwd, "stable.txt", "unchanged\n"); |
| 1462 | yield* writeTextFile( |
| 1463 | cwd, |
| 1464 | ".git/filter.cjs", |
| 1465 | 'require("node:fs").appendFileSync(".git/filter-runs", "read\\n"); process.stdin.pipe(process.stdout);', |
| 1466 | ); |
| 1467 | yield* git(cwd, ["config", "filter.probe.clean", "node .git/filter.cjs"]); |
| 1468 | yield* fs.utimes(path.join(cwd, "stable.txt"), 1_699_999_999.5, 1_699_999_999.5); |
| 1469 | yield* git(cwd, ["add", "."]); |
| 1470 | yield* git(cwd, ["commit", "-m", "cache stable file"]); |
| 1471 | if (splitIndex) yield* git(cwd, ["update-index", "--split-index"]); |
| 1472 | const indexPath = path.join(cwd, ".git", "index"); |
| 1473 | yield* fs.utimes(indexPath, 1_700_000_000, 1_700_000_000); |
| 1474 | const originalIndex = yield* fs.readFile(indexPath); |
| 1475 | const originalMtime = (yield* fs.stat(indexPath)).mtime; |
| 1476 | yield* writeTextFile(cwd, ".git/filter-runs", ""); |
| 1477 | yield* writeTextFile(cwd, "untracked.txt", "new\n"); |
| 1478 | const preview = yield* driver.getReviewDiffPreview({ cwd }); |
| 1479 | assert.deepStrictEqual( |
| 1480 | preview.sources.find((source) => source.kind === "working-tree")!.files, |
| 1481 | [{ path: "untracked.txt", previousPath: null, additions: 1, deletions: 0 }], |
| 1482 | ); |
| 1483 | assert.strictEqual(yield* fs.readFileString(path.join(cwd, ".git/filter-runs")), ""); |
| 1484 | assert.deepStrictEqual(yield* fs.readFile(indexPath), originalIndex); |
| 1485 | assert.deepStrictEqual((yield* fs.stat(indexPath)).mtime, originalMtime); |
| 1486 | }), |
| 1487 | ); |
| 1488 | } |
| 1489 | |
| 1452 | 1490 | for (const [timestamp, splitIndex] of [ |
| 1453 | 1491 | [1_700_000_000, false], |
| 1454 | 1492 | [1_700_000_000.9999, false], |