Skip to content

Commit bfac2c9

Browse files
committed
Add ignore-change update regression coverage (#1782)
1 parent b7934f8 commit bfac2c9

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 1782
5+
affected:
6+
- src/CodeIndex/Cli/IndexCommandRunner.Update.cs
7+
- tests/CodeIndex.Tests/IndexCommandRunnerTests.cs
8+
---
9+
10+
## English
11+
12+
- **Partial update ignore-file changes are now covered by regression tests (#1782)** - `--files` updates that include `.gitignore` or `.cdidxignore` fall back to a full scan so newly ignored stale rows are purged from the index.
13+
14+
## 日本語
15+
16+
- **部分更新で ignore file が変わった場合の挙動を回帰テストで固定しました (#1782)** - `.gitignore``.cdidxignore` を含む `--files` 更新は full scan に切り替わり、新たに ignore 対象になった古い行を index から削除します。

tests/CodeIndex.Tests/IndexCommandRunnerTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4529,6 +4529,41 @@ public void Run_FullScan_WithMalformedIgnoreRule_ReturnsSuccessWithWarningInstea
45294529
}
45304530
}
45314531

4532+
[Fact]
4533+
public void Run_UpdateMode_WhenIgnoreFileChanges_FallsBackToFullScanAndPurgesNowIgnoredRows()
4534+
{
4535+
var projectRoot = CreateTempProject();
4536+
try
4537+
{
4538+
File.WriteAllText(Path.Combine(projectRoot, "generated.py"), "print('generated')\n");
4539+
File.WriteAllText(Path.Combine(projectRoot, "keep.py"), "print('keep')\n");
4540+
4541+
var initialExitCode = IndexCommandRunner.Run([projectRoot, "--json"], _jsonOptions);
4542+
Assert.Equal(CommandExitCodes.Success, initialExitCode);
4543+
4544+
var dbPath = Path.Combine(projectRoot, ".cdidx", "codeindex.db");
4545+
Assert.Contains("generated.py", ReadIndexedPaths(dbPath));
4546+
4547+
File.WriteAllText(Path.Combine(projectRoot, ".gitignore"), "*.py\n!keep.py\n");
4548+
4549+
var (exitCode, json) = RunAndCaptureJson([projectRoot, "--files", ".gitignore", "--json"]);
4550+
4551+
Assert.Equal(CommandExitCodes.Success, exitCode);
4552+
Assert.Equal("success", json.GetProperty("status").GetString());
4553+
Assert.Equal("incremental", json.GetProperty("mode").GetString());
4554+
4555+
var indexedPaths = ReadIndexedPaths(dbPath);
4556+
Assert.DoesNotContain("generated.py", indexedPaths);
4557+
Assert.Contains("keep.py", indexedPaths);
4558+
Assert.Contains(".gitignore", indexedPaths);
4559+
}
4560+
finally
4561+
{
4562+
SqliteConnection.ClearAllPools();
4563+
DeleteDirectory(projectRoot);
4564+
}
4565+
}
4566+
45324567
[Fact]
45334568
public void Run_FullScan_SubdirectoryProjectRoot_UsesRepositoryIgnoreCaseConfigWhenTrue()
45344569
{

0 commit comments

Comments
 (0)