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

Modifying .gitattributes to ignore .html files has no effect #4769

Closed
4 tasks done
brymon68 opened this issue Jan 14, 2020 · 6 comments
Closed
4 tasks done

Modifying .gitattributes to ignore .html files has no effect #4769

brymon68 opened this issue Jan 14, 2020 · 6 comments

Comments

@brymon68
Copy link

brymon68 commented Jan 14, 2020

Preliminary Steps / Problem Description

I have the following public repo: https://github.com/sandialabs/scot

Our git repo says it is 51.8% html which is not true. Our .gitattributes file looks like:

*.pl linguist-detectable=true
*.js linguist-detectable=true
*.html linguist-detectable=false
*.htm inguist-detectable=false
public/libs/* linguist-vendored
scot-ui/public/libs/ linguist-vendored
docs/* linguist-documentation

Yet there are no changes to the percentages. I want HTML fully removed from our percentage makeup. Any ideas how we can accomplish this? I have tried the github-linguist package on Ubuntu as well and no matter what combination .I used, I cant get percentages to change. For instance I also tried:

public/*.html linguist-vendor
scot-ui/public/*.html linguist-vendor

Please confirm you have...

URL of the affected repository:

https://github.com/sandialabs/scot

Last modified on:

01/14/2020

Expected language:

Javascript / Perl

Detected language:

HTML / Javascript

@lildude
Copy link
Member

lildude commented Jan 14, 2020

Our git repo says it is 51.8% html which is not true.

It is 100% true 😁 As per the README.md:

The percentages are calculated based on the bytes of code for each language as reported by the List Languages API.

If we look at the breakdown by size we see:

HTML 22.7 MB
JavaScript 18.4 MB
Perl 1.23 MB
CSS 273 KB
Perl 6 181 KB
Shell 156 KB

So why is HTML so high when you're not expecting it?

Because these two bad boys are massive (your entire repo is surprisingly big too):

  • public/cyberchef.htm @ 11.4 MB
  • scot-ui/public/cyberchef.htm @ 11.4 MB

So why aren't your .gitattributes changes not taking effect?

For a couple of reasons:

  • your paths don't catch all instances of HTML, especially the two massive files. These files are so massive they're hiding the fact some of your changes would be taking effect.
  • when targetting the extensions, you're specifically targetting .html files and completely missing the .htm files, which are your two biggest culprits.
  • your second example is using the wrong attribute name.

If you really don't want any HTML files to be considered, then you need to cater for all the paths and all the extensions and ensure the attribute is correctly spelt.

If the content of the two public dirs are entirely generated, you might want to consider marking them as such so any duplicate or generated files don't count towards the stats too.

@brymon68
Copy link
Author

@lildude - Thank you for catching the typos. I have corrected those but am still noticing the percentages no updating:

$ cat .gitattributes
public/* linguist-generated
scot-ui/public/* linguist-generated

$ github-linguist
52.90%  HTML
42.84%  JavaScript
2.87%   Perl
0.62%   CSS
0.41%   Perl 6
0.35%   Shell

Shouldn't' that eliminate any directories or subdirectories being included in linguist's stats?

@brymon68
Copy link
Author

brymon68 commented Jan 14, 2020

Should have read the docs better...committed and now have a much better percentage. Sorry for confusion and thanks for help!

@d33tah
Copy link

d33tah commented Oct 29, 2021

@brymon68 do you happen to remember what is it that you did that solved that issue for you?

@Syed-Amjad-Ali
Copy link

Hi! Thank you so much guys , I came here and my problem was solved .
I added a file in repository named ".gitattributes." (note the two dots)
and then added the single line text below. "*.html linguist-detectable=false"
btw this is my repository https://github.com/Syed-Amjad-Ali/Google-Data-Analytics-Capstone-1

@lmarkrol
Copy link

just create .gitattributes in the root folder of your repository, and give it these contents:

* linguist-vendored
*.js linguist-vendored=false

This example tells GitHub/Linguist to ignore all files and look at .js files. You can also add another language you want as long as the format files are included in your repository

@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 1, 2023
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