Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gitattributes for linguist examples

Are there any concrete examples, in order to detect wrong languages in GitHub via Linguist attributes?

Source: https://github.com/github/linguist

  • linguist-documentation
  • linguist-language
  • linguist-vendored
like image 810
Vitali Avatar asked Nov 17 '16 15:11

Vitali


People also ask

What is gitattributes?

A gitattributes file is a simple text file that gives attributes to pathnames. Each line in gitattributes file is of form: pattern attr1 attr2 ... That is, a pattern followed by an attributes list, separated by whitespaces. Leading and trailing whitespaces are ignored.

How does GitHub determine programming language?

GitHub uses the open source Linguist library to determine file languages for syntax highlighting and repository statistics. Language statistics will update after you push changes to your default branch.


1 Answers

Examples can be found in Linguist's documentation. What you want can be achieved with linguist-language attributes.

linguist-language

With the following attribute, Linguist detects all .rb files as being Java files.

*.rb linguist-language=Java

linguist-vendored

With the following attribute, Linguist detects files in the special-vendored-path directory (notice the mandatory trailing *) as vendored and excludes them from statistics.

special-vendored-path/* linguist-vendored

linguist-documentation

Without the following attribute, Linguist would detect the file docs/formatter.rb as documentation and exclude it from statistics.

docs/formatter.rb linguist-documentation=false

linguist-detectable

With the following attribute, Linguist counts SQL files in statistics. Without this attribute, only programming and markup languages are counted in statistics.

*.sql linguist-detectable=true
like image 77
pchaigno Avatar answered Oct 16 '22 16:10

pchaigno