Skip to content

Commit 2f0137e

Browse files
committed
Add an indexing option to delete persistent path exclusions
* README.md: Mention new `delete_persistent_exclusions' indexing opt. * bdx/cli.py (IndexingOptionParamType.CONVERTERS): Add `delete_persistent_exclusions'. * bdx/index.py (IndexingOptions): Add `delete_persistent_exclusions' option. (index_binary_directory): Use it. * tests/test_index.py (test_indexing_delete_persistent_exclusions): New test.
1 parent 7aecb1e commit 2f0137e

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ Available options:
9191
- `persist_exclusions` - if True (False by default), then exclusions provided
9292
with `--exclude` option are saved for future runs.
9393

94+
- `delete_persistent_exclusions` - if True (False by default), then delete all
95+
previous `--exclude` exclusions saved with `persist_exclusions` option.
96+
9497
### Disassembling ###
9598

9699
After a directory is indexed, you can disassemble symbols matching a search

bdx/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class IndexingOptionParamType(click.ParamType):
240240
"min_symbol_size": IntRange(min=0),
241241
"use_dwarfdump": BoolParamType(),
242242
"persist_exclusions": BoolParamType(),
243+
"delete_persistent_exclusions": BoolParamType(),
243244
}
244245

245246
def convert(self, value, param, ctx):

bdx/index.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class IndexingOptions:
5858
min_symbol_size: int = 1
5959
use_dwarfdump: bool = True
6060
persist_exclusions: bool = False
61+
delete_persistent_exclusions: bool = False
6162

6263

6364
@dataclass(frozen=True)
@@ -1069,7 +1070,12 @@ def index_binary_directory(
10691070
if index.binary_dir() is None and not dry_run:
10701071
index.set_binary_dir(bindir_path)
10711072

1072-
saved_exclusions = list(index.exclusions())
1073+
if options.delete_persistent_exclusions:
1074+
if not dry_run:
1075+
index.set_exclusions([])
1076+
saved_exclusions = []
1077+
else:
1078+
saved_exclusions = list(index.exclusions())
10731079
for excl in saved_exclusions:
10741080
debug("Loading saved exclusion: {}", excl)
10751081
if excl not in exclusions:

tests/test_index.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,26 @@ def test_indexing_uses_persistent_exclusions(fixture_path, tmp_path):
380380
assert all([not p.name.endswith(".cpp.o") for p in paths])
381381

382382

383+
def test_indexing_delete_persistent_exclusions(fixture_path, tmp_path):
384+
index_path = tmp_path / "index"
385+
index_binary_directory(
386+
fixture_path,
387+
index_path,
388+
IndexingOptions(persist_exclusions=True),
389+
exclusions=[Exclusion("**/*.cpp.o")],
390+
)
391+
index_binary_directory(
392+
fixture_path,
393+
index_path,
394+
IndexingOptions(delete_persistent_exclusions=True),
395+
exclusions=[],
396+
)
397+
with SymbolIndex.open(index_path, readonly=True) as index:
398+
symbols = list(index.search("*:*"))
399+
paths = [s.path for s in symbols]
400+
assert any([p.name.endswith(".cpp.o") for p in paths])
401+
402+
383403
def test_searching_by_wildcard(readonly_index):
384404
symbols = set(readonly_index.search("name:a_*"))
385405
assert symbols

0 commit comments

Comments
 (0)