Author Topic: Controlling language specifications of Git repositories using .gitignore  (Read 2323 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
I was noticing that OP2MapImager was being flagged as a C project by GitHub, which is incorrect since most all the source code is C++.

Turns out GitHub was counting all the FreeImage code files in the language count, which skewed the results heavily.

While not a huge deal, I thought this was worth fixing so when someone stumbles on a project they don't dismiss it since it appears to be written mostly in C or some other language, when it actually is not.

I added the following info to the .gitattributes file, which fixed the repo to list as only a C++ project:


$ cat .gitattributes
FreeImage/* linguist-vendored

ReadMe.txt linguist-documentation


So, lesson here is if you are going to include library code/header files, etc in your repository, you can flag them as linguist-vendored so they don't skew your language stats.

Also, if you have a significant number of documentation files in .txt, .xml, .md, etc, you can flag them as linguish-documentation and also exclude them from the count.

Although this all is probably not worth the time to curate unless something major is skewing the results as a single ReadMe.txt isn't going to throw off the language stats. (This might be a bad example as I don't know if GitHub auto-filters out ReadMe files from stats).

https://github.com/github/linguist#using-gitattributes

-Brett
« Last Edit: September 30, 2017, 06:19:38 PM by Vagabond »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Controlling language specifications of Git repositories using .gitignore
« Reply #1 on: October 01, 2017, 02:49:34 AM »
Ahh, good to have this documented somewhere. I ran into that in leeor_net's NAS2D library, and had wondered what those lines in .gitattributes did. I'd never really noticed GitHub classifying languages used in repos. Actually, to be honest, I'm still not even sure where this is displayed.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Re: Controlling language specifications of Git repositories using .gitignore
« Reply #2 on: October 01, 2017, 03:10:26 AM »
Hooman,

Check out the pics I took below. Both the bubbles and the line graph are affected by tags in the .gitattributes. You can actually click each language on the graph and it will list all files of each language type.

-Brett
« Last Edit: October 01, 2017, 03:12:19 AM by Vagabond »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Controlling language specifications of Git repositories using .gitignore
« Reply #3 on: October 01, 2017, 04:10:34 AM »
Ahh, I see. You have to click on the colored line for the language percentage breakdown to appear. The other one is on the organization's page. I kept finding myself at the dashboard when looking for the organization's page.