snowtrack / snowfs

SnowFS v1 - a fast, scalable version control file storage for graphic files :art:
https://www.snowtrack.io
GNU General Public License v3.0
1.3k stars 43 forks source link

Make snowignore more compatible with gitignore #277

Closed sebastianrath closed 2 years ago

sebastianrath commented 2 years ago

This PR brings .snowignore closer to .gitignore with improvements (see Negate below).

I tried many pattern matchers and micromatch is still the fastest, most feature complete and closest to .gitignore (with exceptions). Pattern matcher comparison table: https://github.com/micromatch/picomatch#library-comparisons

I disabled several features of micromatch as their future support by us is uncertain. Pattern features that are enabled for internal reasons are not covered and might break in the future. This PR description defines the supported patterns that we aim to support in future versions.

Supported Patterns

Pattern Ignore Not ignored
assets
tex
bas
assets
abc/tex
assets/tex
assets/test/abc.jpg
tex
bas
a/assets/b
a/b/c/assets
baz
baz/abc
aassets
assetsb
aassetsb
a-assets
assets-b
a-assets-b
a/b/c/assets.jpg
assets/tex assets/tex
assets/tex/baz
x/assets/tex
x/assets/tex/baz
assets
tex/assets
.jpg
.mov
.jpg
abc.jpg
assets/tex.jpg
assets/tex/bas.jpg
abc.mov
assets/tex.mov
assets/tex.mov/xyz
assets/tex/bas.mov
jpg
jpg.
assets.jpg.abc
assets/jpg.
assets/tex/jpg.baz
assets/tex.jpg.abc
assets/tex/bas.jpg.abc
*.log
!important.log
debug.log
trace.log
assets/test.log
assets/log.log
important.log
logs/important.log
pic.
tex.
pic.
pic.jpg
pic.jpg.abc
assets/pic.jpg
assets/pic.jpg.abc
assets/baz/pic.jpg
assets/baz/pic.jpg.abc
assets/tex.xyz
assets/tex.baz/xyz
pic
assets.pic
assets/tex/bas.pic
assets
!assets/tex/bas
assets
assets/tex
assets/tex/baz
x/assets
x/assets/tex
x/assets/tex/baz
assets/tex/bas
tex
tex/bas
assets//bas
!assets/
/bas/a
assets/tex/bas
assets/tex/bas/b
assets/tex/bas/c
assets/tex
assets/tex/bas/a
assets/tex/bas/b
/assets assets
assets/
assets/tex
assets/tex/
assets/tex/bas
assetso
assetso/
assetso/tex
x/assets
x/assets/
x/assets/tex
x/assets/tex/bas
/assets/ assets
assets/
assets/tex
assets/tex/
assets/tex/bas
assetso
assetso/
assetso/tex
x/assets
x/assets/
x/assets/tex
x/assets/tex/bas
/assets/** assets
assets/
assets/tex
assets/tex/
assets/tex/bas
assetso
assetso/
assetso/tex
x/assets
x/assets/
x/assets/tex
x/assets/tex/bas
**logs logs/monday/assets.tex
build/logs/debug.log
logs/debug.log
logs-files
file-log
log/logs.txt
**/logs/debug.log logs/debug.log
build/logs/debug.log
logs/build/debug.log
/assets/tex assets/tex
assets/tex/
assets/tex/bas
assetso
assetso/
assetso/tex
x/assets
x/assets/
x/assets/tex
x/assets/tex/bas
/assets/tex/ assets/tex
assets/tex/
assets/tex/bas
assetso
assetso/
assetso/tex
x/assets
x/assets/
x/assets/tex
x/assets/tex/bas
/assets/tex/** assets/tex
assets/tex/
assets/tex/bas
assetso
assetso/
assetso/tex
x/assets
x/assets/
x/assets/tex
x/assets/tex/bas
assets/*/baz assets/tex/baz
x/assets/tex/baz
x/assets/tex/baz/y
assets
assets/tex
assets/baz
assets/*/baz/ assets/tex/baz
x/assets/tex/baz
x/assets/tex/baz/y
assets
assets/tex
assets/baz
assets/*/baz/** assets/tex/baz
x/assets/tex/baz
x/assets/tex/baz/y
assets
assets/tex
assets/baz
debug[01].log debug0.log
debug1.log
assets/debug0.log
assets/debug1.log
debug2.log
debug01.log
assets/debug2.log
assets/debug01.log
debug?.log debug0.log
debugg.log
assets/debugg.log
debug10.log
assets/tex[1-4].jpg assets/tex1.jpg
assets/tex2.jpg
assets/tex3.jpg
assets/tex4.jpg
assets/tex0.jpg
assets/tex5.jpg
assets/tex6.jpg
assets/tex7.jpg
assets/tex8.jpg
assets/tex11.jpg
tex1.jpg
tex11.jpg

Negate

The nain difference between .gitignore is the way how negatives are handled. They are more complicated in Git as you need to exclude the parent directory first. This is not needed with .snowignore.

For more information check this SO question. From the gitignore documentation:

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 2178577987

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ignore.ts 16 23 69.57%
<!-- Total: 39 46 84.78% -->
Files with Coverage Reduction New Missed Lines %
src/odb.ts 4 93.3%
src/io.ts 6 85.0%
src/repository.ts 47 86.71%
<!-- Total: 57 -->
Totals Coverage Status
Change from base Build 2164716031: 3.7%
Covered Lines: 1839
Relevant Lines: 2118

💛 - Coveralls
daniellanner commented 2 years ago

Awesome! LGTM ❤️ 🚀