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

Does linguist load global/system gitattributes? #4283

Closed
raphaelyancey opened this issue Oct 1, 2018 · 9 comments
Closed

Does linguist load global/system gitattributes? #4283

raphaelyancey opened this issue Oct 1, 2018 · 9 comments

Comments

@raphaelyancey
Copy link

raphaelyancey commented Oct 1, 2018

I'm trying to make some languages detectable widly for every repository on a server.

I created a /etc/gitattributes (system) and a /home/git/.gitattributes (user-global) but neither of them seems to be taken into account, only a .gitattribute in the repository root.

Does linguist load global/system gitattributes?

Edit: the user-wide config is ~/.config/git/attributes and not /home/git/.gitattributes (but doesn't work either)

@pchaigno
Copy link
Contributor

pchaigno commented Oct 1, 2018

Linguist runs on GitHub.com (and GitLab.com) so it cannot know the content of files on your local system; if the .gitattributes file is not pushed to GitHub.com, Linguist won't see it.

@raphaelyancey
Copy link
Author

@pchaigno In this case it is a self-hosted GitLab instance. So linguist has access to all the repositories on the server. I'd like linguist (in this GitLab) to detect some other files that are not the programming type, like .pd (Pure Data).

According to git docs, if no .gitattributes is present in the repository root directory, it should try ~/.gitattributes and $(prefix)/etc/gitattributes right?

@pchaigno
Copy link
Contributor

pchaigno commented Oct 1, 2018

According to git docs, if no .gitattributes is present in the repository root directory, it should try ~/.gitattributes and $(prefix)/etc/gitattributes right?

We use Rugged::Repository.fetch_attributes to retrieve the .gitattributes values. I don't know if it tries the global settings first. @vmg might know more since he authored that code.

@lildude
Copy link
Member

lildude commented Oct 1, 2018

Hmmm, I'm pretty sure GitLab doesn't take /etc/gitattributes into account when assessing a repository, regardless of whether Linguist does or not.

@raphaelyancey
Copy link
Author

Hmmm, I'm pretty sure GitLab doesn't take /etc/gitattributes into account when assessing a repository, regardless of whether Linguist does or not.

I followed the whole path from a /languages API request on GitLab and I ended up on this function, which seems to simply call linguist with the repository path and a ref as parameters, and parse its output. Attributes handling seems to happen deeper than GitLab app, in Rugged as @pchaigno pointed out.

I just tested Rugged on local repositories (bare and non-bare) and it only takes .gitattributes (non-bare) and info/attributes (bare) into account when reading attributes with .fetch_attributes(). Didn't catch ~/.gitattributes (and not tested with /etc/attributes).

Should I fill a issue over there?

@ZJvandeWeg
Copy link

GitLabber here, at the time of writing we don't read anything outside of the repository for linguist. Just to confirm, like previously stated by @pcantrell in #4283 (comment)

@raphaelyancey My understanding is that it would be filed against either Rugged, the Ruby wrapper around LibGit2, or Libgit2 itself.

@pchaigno
Copy link
Contributor

pchaigno commented Oct 4, 2018

Closing in favor of libgit2/rugged#765.

@ineshbose
Copy link

Does this mean that if I want to test changes to my .gitattributes, I need to push to remote everytime?

@lildude
Copy link
Member

lildude commented Jan 11, 2023

Does this mean that if I want to test changes to my .gitattributes, I need to push to remote everytime?

No. If you have Linguist installed locally, you can commit your changes to the repo and run Linguist against the repo.

If you don't have Linguist installed locally, then yes, you will need to commit your changes, push, and then wait for GitHub to run Linguist against your repo.

PS. this really should have been a new discussion rather than a comment on an issue that was closed over 4 years ago 😉

@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
None yet
Projects
None yet
Development

No branches or pull requests

5 participants