r/github • u/wqonart • Aug 03 '26
Question GitHub reads the source code wrong?
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?
37
u/Lots-o-bots Aug 03 '26
you included your .wrangler dir in the repo. it should have been in your .gitignore
5
u/wqonart Aug 03 '26
Thank you 🙏🏻
21
u/TheSodesa Aug 03 '26 edited Aug 03 '26
You might want to go even further and only allow file types you actually want in your project in the
.gitignorefile:# 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/**/*.astroYou can add folders and file types similarly for other languages. The symbol
*can be used as a wildcard, and**as a recursive wildcard.4
4
u/Masterflitzer Aug 03 '26
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 Aug 03 '26
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
0
3
u/wqonart Aug 03 '26
Thank you all for the feedback. The problem was .wrangler output and it is solved now 🙏🏻
156
u/ferrybig Aug 03 '26
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)
81
u/confuseddork24 Aug 03 '26
It's actually based on bytes, not line counts. https://github.com/github-linguist/linguist/blob/main/docs%2Fhow-linguist-works.md
59
u/Akari202 Aug 03 '26
Explains why a Jupyter notebook quickly becomes the majority language as soon as you have output stored
26
u/confuseddork24 Aug 03 '26
This is exactly how I learned about it lol
8
u/Xerax Aug 04 '26
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 Aug 04 '26
Interactive python notebooks are useful and used frequently for learning, temporary stuff and in the machine learning field
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 Aug 04 '26
yes i don't usually keep training apps in my prod codebase
1
u/Street_Teaching_7434 Aug 04 '26
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.
1
u/throw4w4y40 Aug 07 '26
Am I the only one asking "what the hell is astro?"
1
u/wqonart Aug 07 '26
Astro is a web framework and static site generator build on top of Node.js. The Astro code is simply HTML, CSS and JavaScript under the same document with some tweaks and shortcuts. If you know for example 11ty or Jekyll, it is very similar. Astro allows you develop your website faster, with clear project structure and you can code parts of a website as components, create dynamic layouts and set rules, how your page should generate. In the end during build, Astro compile your entire project to simple, lightweight, pure static .html document.
1
u/Local_Interaction_99 Aug 07 '26
That is the definition of a javascript framework… a JAVASCRIPT, the github code analysis is just the endings e.g. .js => javascript it doesnt check for framework)
1
8
u/T-J_H Aug 03 '26
Honestly, who cares. But if you want to dive into it, try running linguist yourself
3
u/Masterflitzer Aug 03 '26
caring is good, in this case it helped OP discover a bug in his gitignore
1
3
u/RenegadeSultaNGG Aug 03 '26
JavaScript in your repo contains more Bytes than Astro. It counts Bytes, not lines of code.
3
u/Minecraft_Lets_Play Aug 03 '26
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
2
u/Wonderful-Writer146 Aug 03 '26
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 Aug 03 '26
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
0
u/Wonderful-Writer146 Aug 04 '26
That I am not sure of. It can completely remove on language from showing in uour stats though. But you can check with Ai
69
u/phenxdesign Aug 03 '26
Not sure .wrangler/ should be push to git... It contains all the js that github counts as source code