2

I have a (private) project on Gitlab which uses GameMaker, and the .yy files were being detected as Yacc. I looked up how to change this, so I came across .gitattributes files, as described here and here. I created a .gitattributes file in the project directory with the following content:

*.yy linguist-language=GameMaker JSON
*.yy linguist-detectable=true
*.yyp linguist-language=GameMaker JSON
*.yyp linguist-detectable=true

The files are no longer being detected as Yacc, but they are also not detected as "GameMaker JSON", Gitlab now shows the repository as 100% GameMaker Language. I have tried both *.yy linguist-detectable syntax without the =true and with it, I have tried writing GameMaker-JSON with hyphens instead of spaces, and I have confirmed that the .gitattributes file was pushed onto the main branch (which is the only branch). How can I resolve this so that the .yy and .yyp files get recognized correctly, am I missing something?

torek
  • 448,244
  • 59
  • 642
  • 775
Tajoshu
  • 47
  • 10
  • 1
    Does GitLab document that they use Linguist? It's a GitHub project, as far as I'm aware, and not all hosting platforms use it. – bk2204 Sep 01 '22 at 01:02
  • @bk2204 from a quick google search, these seem to confirm that gitlab does use linguist: [1](https://twitter.com/gitlab/status/969676227459059713), [2](https://gitlab.com/gitlab-org/gitlab/-/issues/5093#note_146918627) And as I said, it did at least have the effect that it no longer shows up as Yacc. – Tajoshu Sep 01 '22 at 02:25
  • 1
    Just to troubleshoot, try specifying another language. I'm not sure that "gamemaker json" is a [language recognized by linguist](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). – sytech Sep 01 '22 at 16:43
  • @sytech wait, I thought the point of the gitattributes was that you can specify your own language name, even if it's not included in the list of languages that linguist knows by default, is that not possible? Linguist does include "Game Maker language", which uses the .gml extension, but they probably wouldn't make .yy get recognised as belonging to gamemaker because the extension is also used by Yacc which is more popular. If it is not possible within gitattributes alone, is there a way to add a language to the list of recognized languages locally (for this project or this gitlab account etc) – Tajoshu Sep 01 '22 at 17:38
  • I just noticed that .yy and .yyp are listed in linguist's languages.yml file as JSON extensions, in addition to .yy also being listed for Yacc, I guess it somehow prioritises Yacc over JSON here. Maybe I should just set it to be recognised as "JSON" – Tajoshu Sep 01 '22 at 17:42
  • 1
    I'm not intimately familiar with linguist, but my understanding is that you can change how linguist recognizes/includes files, but the language must be _known_ to linguist. I wouldn't expect that you can just make up a new arbitrary language, for example (but maybe I'm wrong here and you _can_ do that somehow). In any case, setting it to `JSON` or `Game Maker Language` sounds reasonable if the contents fit those descriptions... See also: [linguist#4129](https://github.com/github/linguist/issues/4129). – sytech Sep 01 '22 at 18:00

1 Answers1

2

It seems I mistakenly assumed that linguist allows you to specify custom language names in .gitattributes, but to my current knowledge, that is unfortunately not possible. I will henceforth specify to mark .yy and .yyp files as JSON in my project (refer to this comment I made), which I have already confirmed to work correctly.

My intention was to mark files that are specifically used as GameMaker project files or asset files (which are created and used by the GameMaker editor and not intended to be edited manually) differently from other files with JSON syntax (GameMaker also allows you to parse data from JSON files within your game code, these files would usually use the .json extension and not .yy or .yyp).

For now, it seems advisable for GameMaker projects to either specify .yy and .yyp as JSON or specify them to not be counted by linguist at all, since they aren't code that is manually written by the user.

Tajoshu
  • 47
  • 10