Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitattributes not working #5439

Closed
flack opened this issue Jul 2, 2021 · 4 comments
Closed

gitattributes not working #5439

flack opened this issue Jul 2, 2021 · 4 comments
Labels

Comments

@flack
Copy link
Contributor

flack commented Jul 2, 2021

Describe the bug

I have the following lines in .gitattributes:

https://github.com/flack/openpsa/blob/c19ae95c45782bebb38f6ad4a2113e6f1c4818cf/.gitattributes#L7-L16

unfortunately, linguist ignores them completely, both when I run it locally and on github, too.

Expected behaviour

The listed folders should be excluded

Additional notes

I have tried (locally) to remove all lines from .gitattributes and just add a single static/* linguist-vendored, but even that doesn't work. Clearly, I'm missing something, but I have no idea what, my code looks like all the examples I could find online

@flack flack added the Bug label Jul 2, 2021
@flack
Copy link
Contributor Author

flack commented Jul 2, 2021

Nevermind, I figured it out: You have to use ** to actually exclude the subtree. Would be good to mention that in the docs

@flack flack closed this as completed Jul 2, 2021
@lildude
Copy link
Member

lildude commented Jul 3, 2021

Would be good to mention that in the docs

It is… in the gitattributes and gitignore docs (as this has nothing to do with Linguist; Linguist just takes advantage of the functionality). This has come up plenty times in the discussions and older issues. I think my comment at #5175 (comment) provides a good overview and reference to all relevant docs and demonstrates how to check the attributes without involving Linguist.

@flack
Copy link
Contributor Author

flack commented Jul 3, 2021

Yes, I know, it's mostly my problem. I've tried reading that git manual many times, but after a couple of lines my eyes just glaze over. Not sure if it's the layout or just this jargon filled writing style, but for the life of me I can't make sense of that and usually end up copy n pasting stuff from stackoverflow instead..

I do think though that you could reduce the load of confused tickets like mine if the documentation here

https://github.com/github/linguist/blob/master/docs/overrides.md#documentation

would just use the more common case as an example. Most people probably will want to exclude the entire project-docs/ tree and not just the files directly in that folder. So if the example would simply be changed to project-docs/** linguist-documentation copy n paste would have worked out of the box and I would never have had to bother you guys with this ticket. Also (at least for me), seeing ** gives me a hint that this is basically working like paths in Grunt e.g., so I would have figured out the rest from there (while only seeing * kind of let me to believe it's working like globs on the Linux shell, because for my simple mind, linguist seems more like a tool that would iterate over files)

@eps1lon
Copy link

eps1lon commented Jul 15, 2021

It is… in the gitattributes and gitignore docs (as this has nothing to do with Linguist; Linguist just takes advantage of the functionality).

@lildude Are you referring to the requirement of adding **? Because gitignore does not need that. If I add src/ then every file in src will be ignored e.g. src/module/index.js will be ignored as well as src/index.js.

igormunkin added a commit to luavela/luavela that referenced this issue Dec 12, 2022
.gitattribute parsing rules have been changed in rugged[1] between
v0.28.5 and v1.0.0 (I believe something changed in libgit2, but it
requires a bit more time to found the particular revision and I also
guess it is required only for the history, so I gave up). As a result
linguist[2] fails to find all files to be suppressed that are specified
via the pattern in .gitattributes entry. Several users have been also
experienced the same effect (for more info see github-linguist/linguist#5175 and
github-linguist/linguist#5439).

The fix itself is quite trivial: to suppress the files located not only
in the specified directory, but also all in its subdirectories, double
asterisk glob has to be used.

[1]: https://github.com/libgit2/rugged
[2]: https://github.com/github/linguist

Signed-off-by: Igor Munkin <imun@cpan.org>
igormunkin added a commit to luavela/luavela that referenced this issue Dec 12, 2022
.gitattribute parsing rules have been changed in rugged[1] between
v0.28.5 and v1.0.0 (I believe something changed in libgit2, but it
requires a bit more time to found the particular revision and I also
guess it is required only for the history, so I gave up). As a result
linguist[2] fails to find all files to be suppressed that are specified
via the pattern in .gitattributes entry. Several users have been also
experienced the same effect (for more info see github-linguist/linguist#5439 and
github-linguist/linguist#5451).

The fix itself is quite trivial: to suppress the files located not only
in the specified directory, but also all in its subdirectories, double
asterisk glob has to be used.

[1]: https://github.com/libgit2/rugged
[2]: https://github.com/github/linguist

Signed-off-by: Igor Munkin <imun@cpan.org>
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants