Search code examples
gitgithubgitattributesgithub-linguist

Github Linguist overrides with wildcard


I want to set some GitHub's Linguist overrides in my .gitattributes file, more specifically I want to remove some ".vb" files from being taken into an account for determining the language statistics:

Solution 1/Vb/My Project/AssemblyInfo.vb
Solution 1/Vb/My Project/Resources.Designer.vb
Solution 1/Vb/My Project/Settings.Designer.vb
Solution 2/Vb/My Project/AssemblyInfo.vb
Solution 2/Vb/My Project/Resources.Designer.vb
Solution 2/Vb/My Project/Settings.Designer.vb
...

It's mentioned here that we can:

use standard git-style path matchers for the files you want to override

So I tried the followings, but they're not working:

*/*/My Project/*.vb linguist-generated=true

*/*/My[[:space:]]Project/*.vb linguist-generated=true

**/My Project/* linguist-generated=true

**/My[[:space:]]Project/* linguist-generated=true

Solution

  • The following path matches your files:

    */*/My?Project/*.vb linguist-generated
    

    Note that this also works:

    **/My?Project/*.vb linguist-generated
    

    Unfortunately, git does not support white space escaping in .gitattributes' paths. [[:space:]] is only for regular expressions (wordRegex). ? will match any character and not only spaces, but it might be enough in your case.