fix: normalize generated paths and ignore Stacklit outputs#11
fix: normalize generated paths and ignore Stacklit outputs#11aayushprsingh wants to merge 1 commit intoglincker:masterfrom
Conversation
|
Concrete repro from Windows:\n\n1. Run stacklit generate in the repo\n2. Generated outputs emit repo-relative paths with \ instead of /\n3. stacklit.json / DEPENDENCIES.md also get scanned back into the next run, so output drifts unnecessarily\n\nThis patch fixes both issues by normalizing walked paths to slash form and excluding Stacklit's own configured outputs from future scans. |
|
Good fix, path normalization and the scan exclusion work well. Tests look solid. Just noticed PR #12 includes all of this plus determinism fixes. If that's right I'll merge that one and close this to keep things clean. Let me know if I'm misreading the overlap. |
There was a problem hiding this comment.
Pull request overview
This PR aims to make Stacklit’s filesystem scanning deterministic across operating systems by normalizing walked file paths to forward slashes and by excluding Stacklit-generated outputs from subsequent scans (to avoid self-referential drift).
Changes:
- Normalize walker-relative paths to forward slashes for stable cross-platform output and ignore matching.
- Introduce
Config.ScanIgnore()to extend ignore rules with configured Stacklit output paths. - Update engine/CLI usage and add tests to cover slash normalization and output ignore behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/walker/walker.go | Normalizes walked relative paths to forward slashes before ignore matching and collecting results. |
| internal/walker/walker_test.go | Updates expectations to use forward-slash paths for cross-platform stability. |
| internal/engine/engine.go | Uses cfg.ScanIgnore() so configured outputs are excluded from scans. |
| internal/config/config.go | Adds ScanIgnore() to append output paths (normalized) to ignore patterns. |
| internal/config/config_test.go | Adds test ensuring output paths are included and normalized in ScanIgnore(). |
| internal/cli/diff.go | Loads config and uses ScanIgnore() when walking files for merkle comparison. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Normalize path separators so generated output and ignore matching stay stable across OSes. | ||
| rel = filepath.ToSlash(rel) | ||
|
|
There was a problem hiding this comment.
Now that walker normalizes walked paths with filepath.ToSlash(rel), extraIgnore patterns containing OS-native separators (e.g., "dir\file.go" coming from Windows configs or filepath.Join) will no longer match and will silently stop ignoring files. Consider normalizing extraIgnore entries to forward slashes (and/or documenting that patterns must use '/'), so ignore behavior remains consistent across OSes after this change.
|
Closing in favor of #12 which includes these changes. Thanks! |
Summary
Why
On Windows, generated repo-relative paths were emitted with backslashes, which made output nondeterministic across operating systems and could interfere with ignore matching.
Stacklit also scanned its own generated files (stacklit.json, DEPENDENCIES.md, stacklit.html), causing self-referential drift in generated metadata.
Validation