r-lib / gert

Simple git client for R
https://docs.ropensci.org/gert/
Other
146 stars 31 forks source link

Add support for checking if a path would be ignored #204

Closed richfitz closed 1 year ago

richfitz commented 1 year ago

This PR adds support for libgit2's ignore parsing functions (https://libgit2.org/libgit2/#HEAD/group/ignore/git_ignore_path_is_ignored), to test if for a given repo a path would be ignored. This felt simple enough to implement before checking whether or not you'd be happy to support it - don't feel obliged to accept.

I've just reflected the C lib name here, as I think that's what you're mostly doing. This one does not really have a cli equivalent (you can get there with some options), so it might be worth renaming. Something like git_path_is_ignored would be snappier and avoid the unfortunate spacing issues in init.c.

My use case, in case you're curious, is that people use .gitignore files to indicate "generated" files quite often, so if we have access to files that are marked this way we can clean them out of source trees more easily within our workflow tooling.

jeroen commented 1 year ago

Thanks!

jeroen commented 1 year ago

I'm not sure we can do a CRAN update very soon-ish, but binaries are available from https://ropensci.r-universe.dev/gert

richfitz commented 1 year ago

No rush on my side, thanks for this. One potential issue though is that your version number 1.9000 is ahead of both cran and the likely next cran release - did you miss a minor version number in between?

jeroen commented 1 year ago

I anticipate that the next release will be 2.0 because of some breaking changes at least on Windows, caused by the upgrade of libgit2 (see the NEWS file).

richfitz commented 1 year ago

Ah, that makes total sense. I'll use >= 1.9000 then and all should work well

jeroen commented 1 year ago

I did a patch release for CRAN and included this commit in gert 1.9.3.