Giter Club home page Giter Club logo

wildmatch's Introduction

wildmatch

CI status

package wildmatch is a reimplementation of Git's wildmatch.c-style filepath pattern matching.

For more information, see the godoc.

wildmatch's People

Contributors

bk2204 avatar chrisd8088 avatar dependabot[bot] avatar ttaylorr avatar zkry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wildmatch's Issues

Bring pattern matching more closely in line with Git

In general, our pattern matching in this library doesn't match Git's behavior. We should overhaul our pattern matching such that it does indeed match, ensure that we have options for both gitignore and gitattributes, and add sufficient tests.

One approach that may be interesting is to convert to a regex-based implementation, although a less dramatic overhaul preserving the current code is also a possibility.

End of pattern incorrect matches (ex. "file.txt/" will match "file.txt")

There are a couple of cases where the functionality of wildmatch differs from the .gitattributes style match. This is concerning the end of match strings. There are actually two cases.

The first is when the match string ends in a /, indicating a directory. This will incorrectly match a non-directory file. For example, the search string file.txt/ will match file.txt.

The other case is that /** double star endings, would match files in a similar way to above. So for example, file.txt/** matches file.txt.

Support case-(in)sensitivity

@larsxschneider wisely points out in 5d24d97#r27205600:

AFAIK Git's pattern matching also depends on the file system in use. E.g. foo would match FOO on macOS and Windows but not on Linux with a case sensitive file system. Would it be useful in downstream projects if Match() had an additional parameter that defines case sensitivity?

I agree that this would be useful functionality. I am considering changing the API in the following manner:

type opt func(w *Wildmatch)

var CaseSensitive opt
var CaseInsensitive opt
var FilesystemSensitivity opt

func New(pattern string, opts ...opt) *Wildmatch { ... }

Which will allow the user to opt in to case insensitivity, or defer to the filesystem.

Mismatch of **/* for multiple directories

As mentioned in git-lfs/git-lfs#3406, we incorrectly consider **/*/unicorns/*.bin not to match data/rainbows/unicorns/0ee357d9-bc00-4c78-8738-7debdf909d26.bin, although the pattern **/unicorns/*.bin does work.

We should update this pattern such that both patterns match that string.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.