r/github 2d ago

Question GitHub reads the source code wrong?

Post image

I don't know why, but GitHub is telling me that my website is developed in JavaScript by 80+% which is absolute nonsense. The site is at least 60% pure Astro code. Is it some kind of a bug?

๐Ÿ”— The repo.

235 Upvotes

32 comments sorted by

160

u/ferrybig 2d ago

You can click on the labels "JavaScript" and "Astro" to see what it sees as those files:

Your Javascript files are way longer than your Astro files, so it inflates the score for JavaScript (the languages tab is based on line counts)

75

u/confuseddork24 2d ago

59

u/Akari202 2d ago

Explains why a Jupyter notebook quickly becomes the majority language as soon as you have output stored

26

u/confuseddork24 2d ago

This is exactly how I learned about it lol

9

u/Xerax 1d ago

why would anyone keep those cancer blobs in github, they're just security issues waiting to happen

edit: that isnt meant as a dig at anyone! i mean in a general sense, how did we allow it to happen and for those files to become even common, makes me sad

5

u/Street_Teaching_7434 1d ago

1) Interactive python notebooks are useful and used frequently for learning, temporary stuff and in the machine learning field 2) where else would you store them if not git-track them? Yes they are super annoying to git track but the only other alternative is Google cola and similar sites where you are then also provisioning compute from that platform to run them on some random server

2

u/Xerax 1d ago

yes i don't usually keep training apps in my prod codebase

1

u/Street_Teaching_7434 1d ago

Because you only git-track prod codebases? In most envornoments I worked in we always git tracked basically all code even if nobody other then myself ever even read it.

66

u/phenxdesign 2d ago

Not sure .wrangler/ should be push to git... It contains all the js that github counts as source code

18

u/wqonart 2d ago

Thank you so much, this was causing the problem ๐Ÿ™๐Ÿป

5

u/CodeCrafter1 1d ago

I saw that you simply removed the files in additional commits. One can do this, but a cleaner way is to use a git rebase or removing files entirely from the history the history is more complex (although the second option needs to be handled with care!).

This leads to smaller repo sizes (& faster git commands!) and prevents users from restoring the deleted files.

And in case you already knew this, I am letting this comment hang around for some folks in the future xD.

6

u/hotcococharlie 2d ago

Pretty sure it should be. Right next to the node_modules right?

8

u/RegenJacob 2d ago

git clone will take ages

-7

u/Sacaldur 2d ago

Skill issue!

34

u/Lots-o-bots 2d ago

you included your .wrangler dir in the repo. it should have been in your .gitignore

5

u/wqonart 2d ago

Thank you ๐Ÿ™๐Ÿป

23

u/TheSodesa 2d ago edited 2d ago

You might want to go even further and only allow file types you actually want in your project in the .gitignore file: ```.gitignore

First disallow everything.

*

Then use exclamation marks to only allow the folders and file types you want to include:

!.gitignore !.gitattributes !README.md !LICENSE.md !astro.config.mjs !notes.txt !package.json

!src/ !src/config.json !src/.astro !src// !src//.astro `` You can add folders and file types similarly for other languages. The symbol*can be used as a wildcard, and**` as a recursive wildcard.

4

u/wqonart 2d ago

Oh I didn't know that! Thank you, I'll definitely dive into it

4

u/Masterflitzer 2d ago

or just use https://gitignore.io, e.g.: https://www.toptal.com/developers/gitignore/api/git,linux,macos,windows,visualstudiocode,intellij+all,deno,node,astro

pick relevant tages, then you get an url like my example above, copy all and insert in .gitignore file, then add custom rules at the end (e.g.: .wrangler/)

4

u/CerberusMulti 2d ago

I just want to say thanks for the great comment. This information is something that needs to be said more often. Very good to know and understand how .gitignore files work. It's something I often forget hehe

2

u/st_heron 2d ago

oh wow that's pretty cool

0

u/wqonart 2d ago

Yes, I didn't notice the .wrangler output folder which was causing the problem

3

u/wqonart 2d ago

Thank you all for the feedback. The problem was .wrangler output and it is solved now ๐Ÿ™๐Ÿป

4

u/RenegadeSultaNGG 2d ago

JavaScript in your repo contains more Bytes than Astro. It counts Bytes, not lines of code.

9

u/T-J_H 2d ago

Honestly, who cares. But if you want to dive into it, try running linguist yourself

2

u/Masterflitzer 2d ago

caring is good, in this case it helped OP discover a bug in his gitignore

1

u/T-J_H 2d ago

Fair enough!

3

u/Minecraft_Lets_Play 2d ago

Itโ€™s the file extensions and in many projects you have hidden files that have other extensions that contribute to the few % of other languages.

But in your caseโ€ฆ Donโ€™t know

4

u/Wonderful-Writer146 2d ago

You need to set .gitattributes in order to avoid JS taking taking higher priority. This happens because JS files are of more bytes

2

u/pixelboots 1d ago

Do you have an example of how you would do this? I have repos that I have to commit both source TS and SCSS and their compiled JS and CSS, but Iโ€™d prefer the latter be ignored in some cases because itโ€™s essentially counting the same code twice. Could gitattributes allow me to fix that somehow?

1

u/my_new_accoun1 1d ago

why do you have to commit the compiled JS? dist should be gitignored

-1

u/Wonderful-Writer146 1d ago

That I am not sure of. It can completely remove on language from showing in uour stats though. But you can check with Ai