Clear remaining M0/M1 bugs on master (T-22, T-25, T-27, T-31, T-35)

This commit is contained in:
Boki 2026-11-27 16:19:09 -05:00
parent 9e259ca43b
commit b20fc28e45
8 changed files with 245 additions and 252 deletions

View file

@ -1,6 +1,6 @@
import { describe, expect, test } from 'bun:test';
import { createHash } from 'node:crypto';
import { chmodSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { prepareDataset } from '../../apps/stock/orchestrator/src/data/historical-dataset';
@ -353,4 +353,36 @@ describe('existing-path research benchmark', () => {
expect(afterDelete.source.dirty).toBe(true);
});
});
test('identity hashes tracked files as deleted when their parent directory is replaced by a regular file (T-25)', () => {
withTempGitRepo(repoDir => {
const dirPath = join(repoDir, 'nested');
const nestedFile = join(dirPath, 'file.txt');
mkdirSync(dirPath, { recursive: true });
writeFileSync(nestedFile, 'hello\n');
runGit(repoDir, ['add', 'nested/file.txt']);
runGit(repoDir, [
'-c',
'user.name=Test User',
'-c',
'user.email=test@example.com',
'commit',
'-m',
'add nested file',
]);
rmSync(dirPath, { recursive: true, force: true });
writeFileSync(dirPath, 'now a regular file\n');
const result = identity({ sourceRoot: repoDir });
expect(result.source.contentSha256).toBe(
expectedSourceSha256([
['nested', sha256(readFileSync(dirPath))],
['nested/file.txt', 'deleted'],
['tracked.txt', sha256(readFileSync(join(repoDir, 'tracked.txt')))],
])
);
expect(result.source.dirty).toBe(true);
});
});
});