Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Integrating Git with the Scratch editor
- sf97ahgf
-
100+ posts
Integrating Git with the Scratch editor
I have a feeling the Git protocol is likely HTTP. Otherwise, it likely uses basic TCP connections, which I know of a proxy that's usable.Great question, I have thought about this before. The userscript would be possible to integrate, but it still relies on a backend to manage Git projects locally, so that would have to be turned into a centralized server which would probably be a privacy and scaling headache ~snip~
- Steve0Greatness
-
1000+ posts
Integrating Git with the Scratch editor
ajskateboarder is likely talking Git when they say “the Git backend,” not a forge like GitHub, Gitea, or GitLab. Also, just FWI, Git is usually pushed and pulled either using HTTP or SSH. I have a feeling the Git protocol is likely HTTP. Otherwise, it likely uses basic TCP connections, which I know of a proxy that's usable.
I do feel like these problems are partially solvable, but not fully. Git, being an open source program, could likely either be reimplemented as a JavaScript library, or be recompiled to WASM, but I'm not sure if it being compiled to WASM would mean it would be callable like how its currently done on the backend of Scratch.git. Given the way that WASM has been used by various other projects, I believe it is able to be given data upon being called by JavaScript.
Additionally, moving to a fully browser-based version would bring up the idea of how stuff would be stored. I highly doubt that TurboWarp provides a way to inject files into the SB3 of a project while saving it, so something would likely have to be bodged in order to get the data from Git to be able to be read from and wrote to without requiring the user to save a whole different file in addition to SB3.
Last edited by Steve0Greatness (Sept. 7, 2024 02:05:44)
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
I was able to dust off my homelab today so I'm trying to make the project viewer a bit more useful
- https://scratch-git-api.ajskateboarder.org can currently diff two project files and return a scratchblocks text diff and a commit message. It also has GitHub login flow working sorta (not naming any routes go find them yourself :33)
- https://scratch-git.ajskateboarder.org has the old frontend basically copy-pasted in for now
(its all behind cloudflare so dont be dumb)
Also thanks for 20 stars
- https://scratch-git-api.ajskateboarder.org can currently diff two project files and return a scratchblocks text diff and a commit message. It also has GitHub login flow working sorta (not naming any routes go find them yourself :33)
- https://scratch-git.ajskateboarder.org has the old frontend basically copy-pasted in for now
(its all behind cloudflare so dont be dumb)
Also thanks for 20 stars

Last edited by ajskateboarder (Oct. 7, 2024 23:01:11)
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
Development will be moving to the project viewer with whatever time I can manage. Anyways time for random notes

The project player is pretty much customized Scaffolding because TurboWarp embeds can't simply load project JSON and assets from sources outside of Scratch. I basically inject a control bar into the wrappers that scaffolding creates (sc-layers i believe) with some handlers for different things. And yes, the fullscreen button actually goes fullscreen lol
The “open in new window” buttons just opens the commit directly on GitHub or scratchgit.glitch.me, but sooner or later I'll rip the diff windows from the main scratch.git app (I should try to find a different name for the site version) and put them on this site. By that point you'll essentially have a Git site without the editor
This could be a possible step towards hosting the TurboWarp HTML online with the main app injected

The project player is pretty much customized Scaffolding because TurboWarp embeds can't simply load project JSON and assets from sources outside of Scratch. I basically inject a control bar into the wrappers that scaffolding creates (sc-layers i believe) with some handlers for different things. And yes, the fullscreen button actually goes fullscreen lol
The “open in new window” buttons just opens the commit directly on GitHub or scratchgit.glitch.me, but sooner or later I'll rip the diff windows from the main scratch.git app (I should try to find a different name for the site version) and put them on this site. By that point you'll essentially have a Git site without the editor
This could be a possible step towards hosting the TurboWarp HTML online with the main app injected
Last edited by ajskateboarder (Oct. 27, 2024 19:21:03)
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
Big bump, I forgot about this project for a bit. I was in the process of adding checking out commits, but I found a ton of dumb oversights in previous code I wrote, the main one being this horrible script formatter which fails to parse 99% of projects
Also the frontend is just a pain to work on because of a ton of arbitrary design choices; I treated it more like a React project. I'll see what I can fix though
and thanks for the issues and PRs
Also the frontend is just a pain to work on because of a ton of arbitrary design choices; I treated it more like a React project. I'll see what I can fix though

and thanks for the issues and PRs
Last edited by ajskateboarder (Feb. 10, 2025 18:55:35)
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
Yeah this is right. Although in this case, I have only tested pulling with Gitea (standard username/password auth) and GitHub (device flow auth API), so if there's some other service with non-standard auth, it probably won't workajskateboarder is likely talking Git when they say “the Git backend,” not a forge like GitHub, Gitea, or GitLab. Also, just FWI, Git is usually pushed and pulled either using HTTP or SSH. I have a feeling the Git protocol is likely HTTP. Otherwise, it likely uses basic TCP connections, which I know of a proxy that's usable.
this horrible script formatter which fails to parse 99% of projectsI dropped in a new script formatter which is much more efficient ( I was in the process of adding checking out commits, but I found a ton of dumb oversights in previous code I wrote, the main one being here) and it seems to work with projects out in the wild. The purpose of this formatter is specifically to find which scripts have changed in a project (without generating scratchblocks)
The frontend already uses parse-sb3-blocks, but sending every script in a project over the websocket to check for diffs is an immense waste of time, and would happen on every save. So here we have it
Also, very small fix, but you should be able to see rounded inputs in diffs now
Here's the release: https://github.com/ajskateboarder/scratch-git/releases/tag/0.0.92
I also switched it to AGPL to reflect Scratch lol
Last edited by ajskateboarder (Feb. 18, 2025 18:37:07)
- scratchcode1_2_3
-
1000+ posts
Integrating Git with the Scratch editor
Is there a way to use it with the online editor
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
I tried running the code with a userscript manager on Is there a way to use it with the online editorhttps://turbowarp.org/editor but it fails to find some class names

(i have looked into isomorphic-git, but it seems to be restricted by CORS and doesn't have object diffing)
(i have thought about linking libgit so you dont have to install Git)
Last edited by ajskateboarder (March 10, 2025 16:28:09)
- scratchcode1_2_3
-
1000+ posts
Integrating Git with the Scratch editor
Hmmm maybe I could use isomorphic git in my mod, by installing it with npm (instead of just linking the code which is what I assume you're doing since it's just a userscript and you get cors errors.)I tried running the code with a userscript manager on Is there a way to use it with the online editorhttps://turbowarp.org/editor but it fails to find some class namesI will look further into this, although it will still probably require the scratch.git server for the time being
(i have looked into isomorphic-git, but it seems to be restricted by CORS and doesn't have object diffing)
(i have thought about linking libgit so you dont have to install Git)
I could build it and try with the userscript to see if it works with isomorphic git via npm.
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
Installing from npm wouldn't fix CORS restrictions either - it still runs on the frontend. Also, I use rollup to bundle so I can use npm packages Hmmm maybe I could use isomorphic git in my mod, by installing it with npm (instead of just linking the code which is what I assume you're doing since it's just a userscript and you get cors errors.)
I could build it and try with the userscript to see if it works with isomorphic git via npm.

Last edited by ajskateboarder (March 12, 2025 11:04:46)
- scratchcode1_2_3
-
1000+ posts
Integrating Git with the Scratch editor
wait, you get cors errors for what exactly? what is it trying to access itInstalling from npm wouldn't fix CORS restrictions either - it still runs on the frontend. Also, I use rollup to bundle so I can use npm packages Hmmm maybe I could use isomorphic git in my mod, by installing it with npm (instead of just linking the code which is what I assume you're doing since it's just a userscript and you get cors errors.)
I could build it and try with the userscript to see if it works with isomorphic git via npm.(like van-js). When I meant linking libgit, I meant the C library
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
isomorphic-git would get CORS errors for cloning, pushing, pulling, stuff like that. You would need to run your own CORS proxy (most public CORS proxies are abused or immensely rate limited), and I feel that would make the project more complicated more than it has to bewait, you get cors errors for what exactly? what is it trying to access itInstalling from npm wouldn't fix CORS restrictions either - it still runs on the frontend. Also, I use rollup to bundle so I can use npm packages Hmmm maybe I could use isomorphic git in my mod, by installing it with npm (instead of just linking the code which is what I assume you're doing since it's just a userscript and you get cors errors.)
I could build it and try with the userscript to see if it works with isomorphic git via npm.(like van-js). When I meant linking libgit, I meant the C library
(and also because I hate javascript)
Last edited by ajskateboarder (March 13, 2025 21:41:16)
- ajskateboarder
-
1000+ posts
Integrating Git with the Scratch editor
There is an ongoing issue with opening file dialogs on MacOS. I'm suspecting this is an issue in the library I am using to open dialogs, but I am aware of it
- scratchcode1_2_3
-
1000+ posts
Integrating Git with the Scratch editor
(#1fiften)i tried it myself and it doesn't even work lol
There is an ongoing issue with opening file dialogs on MacOS. I'm suspecting this is an issue in the library I am using to open dialogs, but I am aware of it
like on windows for me it doesn't work at all
i wonder if it has something to do with me not having a cmd.exe
- PaxtonPenguin
-
100+ posts
Integrating Git with the Scratch editor
what do you have to do to your computer to remove the command prompt?(#1fiften)i tried it myself and it doesn't even work lol
There is an ongoing issue with opening file dialogs on MacOS. I'm suspecting this is an issue in the library I am using to open dialogs, but I am aware of it
like on windows for me it doesn't work at all
i wonder if it has something to do with me not having a cmd.exe
- scratchcode1_2_3
-
1000+ posts
Integrating Git with the Scratch editor
(#117)umm heh…heh…… umwhat do you have to do to your computer to remove the command prompt?(#1fiften)i tried it myself and it doesn't even work lol
There is an ongoing issue with opening file dialogs on MacOS. I'm suspecting this is an issue in the library I am using to open dialogs, but I am aware of it
like on windows for me it doesn't work at all
i wonder if it has something to do with me not having a cmd.exe
well i got locked out once and had to “hack” my way in and then i never fixed it back so now cmd is gone, which causes a few errors sometimes but it's fine. it's actually still there but it's not…. there
- gatgatcode
-
100+ posts
Integrating Git with the Scratch editor
do realize advertising userscripts is against the rules right?its a You mod not a userscript
- scratchcode1_2_3
-
1000+ posts
Integrating Git with the Scratch editor
Actually, it is one, but it's not for a browser, so… yeah idkdo realize advertising userscripts is against the rules right?its a You mod not a userscript
- Discussion Forums
- » Advanced Topics
-
» Integrating Git with the Scratch editor