Skip to content

fix: normalize generated paths and ignore Stacklit outputs#11

Closed
aayushprsingh wants to merge 1 commit intoglincker:masterfrom
aayushprsingh:fix/windows-path-and-self-scan
Closed

fix: normalize generated paths and ignore Stacklit outputs#11
aayushprsingh wants to merge 1 commit intoglincker:masterfrom
aayushprsingh:fix/windows-path-and-self-scan

Conversation

@aayushprsingh
Copy link
Copy Markdown
Contributor

Summary

  • normalize walked file paths to forward slashes for stable cross-platform output
  • exclude Stacklit generated output files from future scans
  • add tests covering slash normalization and generated output ignore rules

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

  • go test ./...
  • go build ./...
  • go vet ./...

@aayushprsingh
Copy link
Copy Markdown
Contributor Author

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.

@thegdsks thegdsks requested a review from Copilot April 12, 2026 23:04
Copy link
Copy Markdown
Member

@thegdsks thegdsks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@thegdsks
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +102 to +104
// Normalize path separators so generated output and ignore matching stay stable across OSes.
rel = filepath.ToSlash(rel)

Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@thegdsks
Copy link
Copy Markdown
Member

Closing in favor of #12 which includes these changes. Thanks!

@thegdsks thegdsks closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants