github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.32k stars 4.26k forks source link

.gitattributes not working - wrong language statistics #3681

Closed henriquearthur closed 7 years ago

henriquearthur commented 7 years ago

My repository shows wrong language statistics, as in the image:

henriquearthur habbosecurity habbo es fansite

The percentages for HTML, CSS and Javascript are wrong, because I also include in the repository a directory contaning third-party plugins.

What I want is that the language statistics ignore two folders and all subfolders and files inside it: src/bower_components and public/semantic.

This is my .gitattributes file:

public/semantic/* linguist-vendored=true
src/bower_components/* linguist-vendored=true

I also tried without the =true (I believe it's unnecessary) and it doesn't work.

Using the search, I found that almost all my HTML, CSS and Javascript files are inside those two folders. Only two files are in another folder.

I don't know what I'm doing wrong here. Can anyone help?

lildude commented 7 years ago

Is this repo public? If so, can you provide a link so we can see what you're seeing.

ghost commented 7 years ago

This might be related to #3665 - unless .gitattributes is meant to show no change if a language isn't known to linguist. For what it's worth, the repo where I tried to use this https://github.com/tethercode/stdlib (but this might be unrelated to this bug report if .gitattributes entries for unknown languages are intentionally ignored)

henriquearthur commented 7 years ago

@lildude the repo is not public but I have added you as a collaborator.

henriquearthur commented 7 years ago

@JonasT I don't see how it could be related to that issue since I'm not using unknown languages here. It's only web application languages: HTML, CSS, JS and PHP.

lildude commented 7 years ago

Thanks @henriquearthur.

I've taken a look at your repo and the language statistics are correct and they are correctly ignoring your vendored directories.

From the GitHub staff interface I can see your repository language breakdown as follows (% manually added and the output manually simplified and wildcarded to protect the content of your repo):

380KB (27.88%)  HTML
345KB (25.35%)  CSS
335KB (24.61%)  JavaScript
301KB (22.11%)  PHP
619B (0.04%)   ApacheConf

PHP:
app/**/*.php
db/**/*.php
phinx.php
public/index.php

HTML:
app/**/*.twig
public/index.html

JavaScript:
gulp/**/*.js
gulpfile.js
src/js/*.js
src/plugins-js/*.js

ApacheConf:
public/.htaccess

CSS:
src/plugins-css/*.css
src/scss/*.scss

Linguist on the CLI would report the same thing.

As you can see public/semantic/* and src/bower_components/* aren't included so everything is working as expected.

Please feel free to remove me as a contributor to your repo.

henriquearthur commented 7 years ago

@lildude ok! I understand now, thank you. I didn't see a change when I edited the .gitattributes, so I thought it was wrong.

With the directory list, it is clear now. It would be very interesting if we could see a directory list like that on the repo.

Thanks.