Another git repository downloader

Started by SquidDev, May 18, 2019, 08:14 pm

Previous topic - Next topic

SquidDev

OK, so this is a silly little project I mostly knocked together a couple of years ago (June 2017) and then finished off this morning. I'm not going to pretend it's polished or well written, but it works!



No, I know what you're thinking, "Oh great, it's another git-get clone". But oh no, it's a git clone clone1. This should work with any Git repository2 (as long as it supports https), not just GitHub's!

If you fancy a play, you can download it: wget https://gist.githubusercontent.com/SquidDev/e0f82765bfdefd48b0b15a5c06c0603b/raw/clone.min.lua

I can't imagine this is really useful truth be told, but it's a nice POC. It may be a little slower than git-get. While the downloading is very fast, we then have to decompress the downloaded files, which isn't especially fast on ComputerCraft. On the bright side, it's not held to the same rate limits as GH's own API, so might be useful for servers or something.

1: Sadly you can't clone git-get, as it's not on git. Ironic really.
2: OK, so I haven't added timeout protection everywhere, so it will fail if downloading massive files. Like I said, it's not polished.
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

EveryOS

Now we just need a way to push to git!
Quick question, does this generate the .git/ folder?
~Google

SquidDev

Quote from: EveryOS on May 22, 2019, 01:07 pmNow we just need a way to push to git!
Quick question, does this generate the .git/ folder?
Pushing is a little bit harder, as you need to compress the files, and I'm not aware of a pre-existing pure Lua DEFLATE compressor (there's plenty of decompressors out there).

No, it doesn't generate the .git folder, though I suspect it wouldn't be too hard to add - we're downloading all the required information, just not bothering to keep it around afterwards.
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

EveryOS

Ok. Also, I think the original git-get does not work anymore (I think API v2 is down), so this definitely would be useful.
~Google