Jonathan Doliver
Jonathan Doliver

Reputation: 51

When commiting to GitHub, where should 3rd party libraries like jQuery be stored to not affect the language stats?

I want to include the actual jQuery code in my project somewhere, but I want GitHub to ignore the content of the 3rd party files.

Upvotes: 2

Views: 816

Answers (3)

pchaigno
pchaigno

Reputation: 13093

As Zanon noted, GitHub uses the open source project Linguist to compute language statistics. There are several cases where Linguist ignores a file:

Your jQuery files are minified. In that case, Linguist should detect it and consider the file generated. Generated files are not counted towards the overall statistics.

Certain libraries are explicitly excluded. As Zanon noted, there is, in vendor.yml, a list of patterns that Linguist will ignore. jQuery files are explicitly excluded through this list. All .min.(js|css) files are also excluded.

Your file is considered documentation. This would probably not be your case, but Linguist also defines a list of documentation patterns that are excluded from statistics.

You can tell Linguist to ignore some files. You can use Linguist overrides to instruct Linguist to ignore some of your files. If your jQuery files are not minified and do not match any of the known patterns, you'd have to use Linguist overrides to exclude them.

Upvotes: 1

Zanon
Zanon

Reputation: 30760

GitHub uses Linguist to identify your repo main language. So you can define the paths for your vendored code (like jQuery) at lib/linguist/vendor.yml and GitHub will ignore them when calculating the repo stats.

Checking code you didn't write, such as JavaScript libraries, into your git repo is a common practice, but this often inflates your project's language stats and may even cause your project to be labeled as another language. By default, Linguist treats all of the paths defined in lib/linguist/vendor.yml as vendored and therefore doesn't include them in the language statistics for a repository.

Upvotes: 1

El Duderino
El Duderino

Reputation: 1392

Set it up as a Git submodule

git submodule add https://github.com/jquery/jquery jquery

But I would probably fork it first though just in case it ever breaks compatibility or if you want to make changes. Which is the only reason I would think you would want to keep it all in there.

Upvotes: 0

Related Questions