Build (or rebuild) the content search index for the repository. Indexes files in the working copy while respecting `.gitignore`, `.ignore`, `.atomicignore` (and the global ignore file), and skipping Atomic-internal directories (`.atomic`, `.git`, `.vault`). The index is stored at `.atomic/content-index/`. Discovery is owned here rather than delegated to syntext's `Index::build`: syntext's walker
(repo_root: &Path)
| 23 | /// walker (for its symlink resolution and size handling), then drop the paths |
| 24 | /// Atomic excludes before handing the corpus to `build_from_file_records`. |
| 25 | pub fn build_content_index(repo_root: &Path) -> Result<(), ContentSearchError> { |
| 26 | let config = content_config(repo_root); |
| 27 | |
| 28 | let (files, _skips) = syntext::index::walk::enumerate_files(&config)?; |
| 29 | let ignore_rules = crate::ignore::IgnoreRules::load_for_enrichment(repo_root); |
| 30 | let records: Vec<ExternalFileRecord> = files |
| 31 | .into_iter() |
| 32 | .filter(|(_absolute, relative, _size)| { |
| 33 | !crate::ignore::is_enrichment_internal(relative) |
| 34 | && !ignore_rules.is_ignored(relative, false) |
| 35 | }) |
| 36 | .map( |
| 37 | |(absolute_path, relative_path, size_bytes)| ExternalFileRecord { |
| 38 | absolute_path, |
| 39 | relative_path, |
| 40 | size_bytes, |
| 41 | }, |
| 42 | ) |
| 43 | .collect(); |
| 44 | |
| 45 | let _index = Index::build_from_file_records(config, records)?; |
| 46 | Ok(()) |
| 47 | } |
| 48 | |
| 49 | /// Incrementally update the content index after file changes. |
| 50 | /// |