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

Suggestion: if .gitattributes has an override with linguist-language=UNKNOWN, then add it with a new random color to code line stats anyway #7

Closed
ell1e opened this issue Jan 29, 2021 · 5 comments

Comments

@ell1e
Copy link

ell1e commented Jan 29, 2021

I have the following suggestion which would be really great to have on gitea which at least from my googling uses this library: it would be great if when a repo's .gitattributes file contains an override with linguist-language=UNKNOWN (as in the language isn't known to linguist) if then that language would be added with the given name UNKNOWN and any choice of unused color to the statistics such that it shows up on gitea's stats bar. This would be a really great addition for creators of small languages that have repos on gitea instances without admin access to allow them to mark their source files such that the overall repo stats are correct, even though that obviously still won't fix the missing syntax highlighting.

@dayvonjersen
Copy link
Owner

dayvonjersen commented Jan 30, 2021

Hi thanks for your suggestion :)

I really don't remember how this thing works or how to code in general anymore, does what you're asking have anything to do with this: #5 ?

If not or "sort of but not really", I'd be glad to add/change whatever needs doing. It will probably take me some time to get around to it myself, so it might be more expeditious if you wanted to try to tackle it yourself and I could merge it or whatever

EDIT: it looks like I made this at some point: https://github.com/dayvonjersen/linguist/compare/feature/gitattributes
I have zero memory of this but would it do the thing?

@ell1e
Copy link
Author

ell1e commented Jan 30, 2021

Well currently, .gitattributes overrides can only name languages that exist / are already known to linguist. Others are dropped in the final stats, this is both the case on GitHub and gitea right now (the latter which is using this go linguist project here, isn't it?).

This feature request is basically "carry through made up languages in .gitattributes to the final stats." If that leaves any associated properties like the color for the bar (if that is also configured in go linguist) missing then just pick any color e.g. based on a name hash, randomness, or whatever.

This basically allows people to make up new languages the gitea instance doesn't globally know about on the spot by just setting a new name in the overrides. Useful for projects that implement & contain files in a niche language that isn't otherwise really tracked by any linguist library since it's too niche, so that these niche languages aren't just entirely ignored in the project's code stats.

@dayvonjersen
Copy link
Owner

dayvonjersen commented Jan 30, 2021

Ah, I understand now. I believe this would do that as it doesn't appear to cross-check the linguist-language specified against anything: https://github.com/dayvonjersen/linguist/compare/feature/gitattributes

I guess I never merged it because I expected to merge #5 once it was working ...

If something is reading a .gitattributes file it isn't using this library currently.

I know you said you were trying to avoid taking this issue over to @gitea but they're quite nice from what I remember. I don't know if they're using this library; I remember I made a language bar prototype for gogs which got rejected and someone at gitea saw it and wanted to add that feature, and I know that they did eventually but I honestly don't know if they used any of my code or designs.

Unfortunately, you're gonna have to take this up with them because even if I do add this feature (and I think I will, thank you sincerely for making me aware of it) I don't think it will solve your problem there :\

-day

EDIT: ofc I got curious and looked and yes they have their own thing here: https://github.com/go-gitea/gitea/blob/511f6138d4b5b7a464a8fa3d7f8fc52bec3789a4/modules/git/repo_language_stats_nogogit.go
and don't use my library at all, which makes sense cause I remember now Unknwon made his own thing for gogs instead of merging my PR and gitea is based on gogs mhm yes nods I totally understand now
google search results probably link you to go-gitea/gitea#2165 which as you can see someone else picked up my slack and made their own thing go-gitea/gitea#4824 which is what got worked on and eventually merged here go-gitea/gitea#8037

very interesting i feel like we're solving a mystery 🔍

@ell1e
Copy link
Author

ell1e commented Jan 30, 2021

@dayvonjersen thanks so much for finding this out! I made a gitea ticket now: go-gitea/gitea#14528

@ell1e
Copy link
Author

ell1e commented Nov 14, 2023

Closing this since gitea implemented this now! 🎉

@ell1e ell1e closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants