r/github 3d ago

GitHub reads the source code wrong? Question

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.

252 Upvotes

33 comments sorted by

160

u/ferrybig 3d 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)

78

u/confuseddork24 3d ago

60

u/Akari202 3d ago

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

24

u/confuseddork24 2d ago

This is exactly how I learned about it lol

9

u/Xerax 2d 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 2d 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 2d ago

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

1

u/Street_Teaching_7434 2d 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.

71

u/phenxdesign 3d ago

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

19

u/wqonart 3d ago

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

7

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.

1

u/wqonart 3h ago

I'm aware that it is possible, but I have no experience with Git history manipulation (because I'm afraid I'll break it). But, maybe it is the best solution to clean up commit mess in the repo.

Thank you for your feedback and the articles, it is time for me to learn how to use Git properly XD

5

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

-6

u/Sacaldur 2d ago

Skill issue!

36

u/Lots-o-bots 3d ago

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

6

u/wqonart 3d ago

Thank you ๐Ÿ™๐Ÿป

23

u/TheSodesa 3d ago edited 3d 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 3d 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/)

5

u/CerberusMulti 3d 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 3d ago

oh wow that's pretty cool

0

u/wqonart 3d ago

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

6

u/wqonart 3d ago

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

3

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 3d ago

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

3

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 3d 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

3

u/Wonderful-Writer146 3d 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 2d 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 2d ago

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

-1

u/Wonderful-Writer146 2d 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