node-ignore icon indicating copy to clipboard operation
node-ignore copied to clipboard

directory ending with / not always correctly ignored

Open SamVerschueren opened this issue 3 years ago • 9 comments

Hi!

Thanks for this awesome package! I think I might found a small bug when using it.

With the following .gitignore contents

c/*
!c/bar.js

Running git check-ignore -v c/ results in

.gitignore:1:c/*        c/

Using ignore.test('c/') indicates that it's not ignored. This package correctly indicates that c/ is ignored if I change c/* in the .gitignore file to c/.

Kind regards Sam

SamVerschueren avatar Jan 10 '22 12:01 SamVerschueren

Confirmed. Really weird behavior of git check-ignore.

IMO, c/* means ignoring everything inside of directory c but not c itself.

I need to check the spec

However, this issue might not have side effects.

kaelzhang avatar Jan 10 '22 17:01 kaelzhang

The thing is that git check-ignore c is different and not ignored. But with / it is. It seems that once you add a / it thinks you are IN the directory and it's not the directory itself anymore.

SamVerschueren avatar Jan 10 '22 17:01 SamVerschueren

But I think this issue will not cause the situation that we copy wrong files (we always copy files instead of directories), so it is of low priority.

kaelzhang avatar Jan 10 '22 17:01 kaelzhang

The use case I'm having is that I use isomorphic-git which uses this package under the hood. I'm building git check-ignore on top of that and that's when I saw that it incorrectly checks the use case explained in the issue.

Would you be open for a PR to try to fix this use case?

SamVerschueren avatar Jan 11 '22 08:01 SamVerschueren

yes I would

Thesaintsfan2 avatar Jan 11 '22 18:01 Thesaintsfan2