Skip to content

RFC: include and exclude files by shebang contents and other criteria#648

Open
tomeon wants to merge 2 commits intonumtide:mainfrom
tomeon:mimetype-detection
Open

RFC: include and exclude files by shebang contents and other criteria#648
tomeon wants to merge 2 commits intonumtide:mainfrom
tomeon:mimetype-detection

Conversation

@tomeon
Copy link

@tomeon tomeon commented Nov 9, 2025

Intended for cases like scripts, which may lack extensions indicating their file/language type.

An incidental change is the introduction of the format.Matcher interface and various types implementing this interface. The idea is to encapsulate various bits of logic:

  1. Does this matcher match the supplied path (for the matcher-specific sense of "match")?
  2. Should this matcher be ignored (e.g. because it has no configured glob patterns)?
  3. Is this matcher for including or excluding files?

I do not have very much experience in Go, so I'm not certain whether this approach is a good idea or, if so, whether it is implemented sensibly. The intentions are:

  1. To simplify the use of matchers (assembling a CompositeMatcher is a bit verbose/unwieldy, but using it is IMO straightforward -- one call to Wants(path) for each path under consideration), and
  2. To provide a basis for implementing additional inclusion/exclusion logic.

Thanks in advance for your consideration!

Loading
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.

4 participants