Skip to content

Observe .gitignore when globbing markdown files. #2

Closed

Description

@webern

The PR #1 agent helpfully pointed out this was not in scope for the PR:

reading .gitignore: every *.md outside .git is scanned, nothing else is

It is an absolute necessity! Feature request!

Activity

  1. webern commented on Sep 23, 2026

    @webern
    OwnerAuthor

    Recommendation: replace the hand-rolled walk with the ignore crate

    This came up in review on #1. The directory walk in src/glob/walk.rs is written by hand, and pattern matching already uses globset. The ignore crate comes from ripgrep, like globset, and is its directory walker. Switching to it is how this issue should be done.

    • It reads .gitignore, .ignore, .git/info/exclude and the global git excludes, with the same semantics as git. That includes nested .gitignore files and negations.
    • It already does what walk.rs does by hand: not following symlinks, skipping .git, and giving a clear error for a directory it cannot read.
    • WalkBuilder has a switch for each filter (git_ignore, hidden, parents and so on). Whether deslag honours .gitignore can then be a config option if one is ever needed.
    • It can walk in parallel (build_parallel), which will matter on large repos.
    • Several of its dependencies, globset included, are already in the tree.

    Alternatives considered:

    • walkdir: smaller, but it does not read .gitignore, so this issue would still need ignore or a hand-written gitignore parser.
    • The glob crate: its pattern syntax differs from the globset patterns the config uses, and it cannot prune directories while walking.

    The change should be confined to walk.rs: build a WalkBuilder over the root, keep the RepoFile output and the sorting, and add unit tests for an ignored file, a nested .gitignore, and a negation. The /deslag-build-doctrine skill governs adding the dependency.

    Deferred from #1 to keep that PR's scope as it is.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions