fix(autoplan): list renames as delete and add so a renamed secret file stays out of the draft (GST-1164)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-11-03 03:56:52 +00:00
1 parent e16009e054
commit 029ff4e0af
3 files changed
+25 -4

No files matched your search

+21
View File
@@ -423,6 +423,27 @@ describe('draft capture edges', () => {
expect(diff).toContain('+export const JITTER = 0.1;');
});
test('a secret file renamed on the branch stays out under both names', () => {
const cwd = repo('rename-envrc', false);
git(cwd, 'checkout', '-q', 'main');
fs.writeFileSync(path.join(cwd, '.envrc'), 'dotenv_if_exists marker-zz9-old\n');
git(cwd, 'add', '.envrc');
git(cwd, 'commit', '-q', '-m', 'direnv');
git(cwd, 'checkout', '-q', 'feature');
git(cwd, 'merge', '-q', 'main');
git(cwd, 'mv', '.envrc', '.envrc.local');
fs.appendFileSync(path.join(cwd, '.envrc.local'), 'dotenv_if_exists marker-zz9-new\n');
fs.appendFileSync(path.join(cwd, 'lib', 'worker.ts'), 'export const JITTER = 0.1;\n');
const { ps, prompt } = lean('rename-envrc', cwd);
const diff = fs.readFileSync(path.join(ps.snapshot_dir, 'draft.diff'), 'utf8');
for (const text of [diff, prompt]) {
expect(text).not.toContain('marker-zz9');
expect(text).toContain('# draft: .envrc left out (its name looks like a secret)');
expect(text).toContain('# draft: .envrc.local left out (its name looks like a secret)');
}
expect(diff).toContain('+export const JITTER = 0.1;');
});
test('a key inside an ordinary file is redacted, untracked or edited in the working tree', () => {
const cwd = repo('redact', true);
fs.writeFileSync(path.join(cwd, 'lib', 'client.ts'), `export const KEY = '${FAKE_KEY}';\n`);