Replace the hardcoded .gitignore + .clideignore read with the ordered ignore_files: chain from .pql/config.yaml (D-4) — the single ignore knob clide owns (D-3). readIgnoreFiles defaults to .gitignore (plus .clideignore when present) when the config is absent or malformed, and honours an explicit [] as "no file-based exclusions". Add walkFiles + the files.walk command: a recursive, ignore-pruned, capped flat file listing reused by quick-open (T-51) and the search engine (T-52). Closes the never-filed ignore-layering placeholder in files_commands.dart. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
2.0 KiB
Dart
55 lines
2.0 KiB
Dart
/// Reads the clide-owned keys from `.pql/config.yaml`.
|
|
///
|
|
/// Per [D-3] clide owns pql's `ignore_files:` key (and never touches
|
|
/// pql's `.pql/` index/cache data). Per [D-4] that key is the single
|
|
/// knob for ignore layering: an ordered list of gitignore-shaped files
|
|
/// at the workspace root, with later entries winning on per-pattern
|
|
/// conflicts. This module reads the list; the matcher itself lives in
|
|
/// [IgnoreSet] (see `ignore.dart`).
|
|
///
|
|
/// Flutter-free by construction — used by daemon-side file walking and
|
|
/// the search engine, both of which run under `dart test`.
|
|
library;
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:yaml/yaml.dart';
|
|
|
|
/// The ordered list of ignore-file names to layer when walking the
|
|
/// workspace, read from `ignore_files:` in `.pql/config.yaml`.
|
|
///
|
|
/// Resolution (per D-4):
|
|
/// * config present with an explicit `ignore_files:` list → that list
|
|
/// verbatim. An empty list disables file-based exclusions entirely
|
|
/// (the built-in `.git/` etc. still apply via [IgnoreSet.builtin]).
|
|
/// * config absent / malformed / missing the key → the default
|
|
/// `[.gitignore]`, plus `.clideignore` when that file exists
|
|
/// (clide-specific deviations, per D-4).
|
|
///
|
|
/// Never throws: a missing or unparseable config falls back to the
|
|
/// default, so a broken YAML file can't silently blank the ignore set.
|
|
List<String> readIgnoreFiles(Directory root) {
|
|
final cfg = File('${root.path}/.pql/config.yaml');
|
|
if (cfg.existsSync()) {
|
|
try {
|
|
final doc = loadYaml(cfg.readAsStringSync());
|
|
if (doc is YamlMap && doc.containsKey('ignore_files')) {
|
|
final raw = doc['ignore_files'];
|
|
if (raw is YamlList) {
|
|
return [
|
|
for (final e in raw)
|
|
if (e is String) e,
|
|
];
|
|
}
|
|
}
|
|
} catch (_) {
|
|
// Malformed YAML — fall through to the default below.
|
|
}
|
|
}
|
|
final names = <String>['.gitignore'];
|
|
if (File('${root.path}/.clideignore').existsSync()) {
|
|
names.add('.clideignore');
|
|
}
|
|
return names;
|
|
}
|