Is it possible to exclude files from git language statistics?
Asked Answered
A

2

87

Silly question and not on something that is so necessary, but is it possible to exclude files from Github's language statistics aggregation on top?

I have checked some external CSS and JavaScript frameworks to be compressed along with the rest of the source code. They get measured as part of the project although they have not been contributed from a team member. This means that the status bar does not reflect the exact state of the project.

Abbreviated answered 27/9, 2013 at 14:7 Comment(4)
Can you provide the example? Generally, you can use regex to declare exclude filesMicrobicide
@Microbicide No, because the project is private. Where can the regex be supplied?Abbreviated
See help.github.com/articles/…. It looks like if the file name matches a regex in that yaml file it won’t count towards the project language.Rundell
@Rundell Is it possible to post this as an answer, so that I can accept it?Abbreviated
B
107

GitHub uses the Linguist library for source code detection; Linguist treats all of the paths defined in its' vendor.yml as vendored and won't include them in the language statistics for a repository.

Update:

From comments below, currrent instructions are here: https://github.com/github/linguist/blob/master/docs/overrides.md

Original answer:

You can specify something different for your repo by editing your repo's .gitattributes file. To treat a path as a vendored file, add the path followed by linguist-vendored:

special-vendored-path/* linguist-vendored

To treat an otherwise vendored path as unvendored, use linguist-vendored=false:

jquery.js linguist-vendored=false

Source

Bayard answered 15/11, 2014 at 17:59 Comment(3)
Is there a way to ignore all files in one directory then?Dime
@AndréClérigo The link has changed. Instructions on how to override default behavior can be found here. There you can also find the way to ignore directories.Weight
Link to the documentation has changed, it's now located here: github.com/github/linguist/blob/master/docs/overrides.mdProsecute
R
11

From the Github Help page My repository is marked as the wrong language:

Linguist excludes certain file names and paths from statistics. Check out the vendor.yml file for a list of these exclusions.

Pull requests with new exclusion patterns are always welcome.

So if your javascsript/css files match a regexp in that Yaml file they shouldn’t be included in the stats. If they don’t, you could add them and create a pull-request.

Rundell answered 27/9, 2013 at 16:16 Comment(1)
See Eugene Fidelin's answer for an up-to-date answer.Lollis

© 2022 - 2024 — McMap. All rights reserved.