Files
one-off-scripts/rescue-from-github.lua
2025-07-21 06:43:59 +00:00

115 lines
3.9 KiB
Lua

#!/usr/bin/env luajit
-- TODO add support for private repos by making it warn the user
-- defaults: organization "tangent", public, a string alone means the description
local repositories = {
["2dcraft"] = "A 2D infinite world survival game concept. (Minetest meets Factorio?)",
auroraclone = "Another attempted clone of Aurora, the 4X spreadsheet game.",
["52-cards"] = "Playing cards.",
BSG = "Battlestar Galactica fan-game (not even prototype yet).",
["bullet-hell"] = {
organization = "prototype",
description = "A prototype bullet hell game!",
},
["Drabble-Readings"] = "Recordings of me reading my drabble (for submission to the 100 Word Stories Podcast).",
erectus = {
organization = "prototype",
description = "Basic simulation of an enclosed space & life support systems.",
},
fade = "A very impermanent drawing tool.",
Fluid = {
organization = "prototype",
description = "A better system for basic simulation of fluids in containers.",
},
ideas = "design docs / misc. ideas",
neralie = {
organization = "tools",
description = "A simple clock for the Neralie decimal time format.",
},
owen = {
organization = "prototype",
description = "Small polygonal ship generator.",
},
particular = {
organization = "prototype",
description = "A super basic particle simulator (better as a visualizer.. of nothing in particular).",
},
RGB = "My first successful game, where you have to try to match colors using the 3 mouse buttons.", -- default org: tangent, string means description
sever = {
organization = "prototype",
description = "Prototype simplistic engine simulation for generating power.",
},
["Simple-Kerbal-Mods"] = "KSP Agencies!",
slab = "A very not usable (yet?) Love2D GUI library.",
SpaceLove = "My first \"fly a fighter\" prototype... FROM 2014! D:",
["The-Snap"] = "The Snap balances your browsing habits by closing a random half of open tabs.",
ThompsonWasAClone = "shit Thomas Was Alone clone",
xi = {
organization = "prototype",
description = "A borderless fullscreen \"screensaver\" of a galactic travel network.",
},
}
local organizations = {}
local repository_names = {}
for name, info in pairs(repositories) do
if type(info) == "string" then
info = { description = info }
repositories[name] = info
end
if not info.organization then
info.organization = "tangent"
end
organizations[info.organization] = true
table.insert(repository_names, info.organization .. "/" .. name)
-- TODO figure out how to detect and exclude repos that don't need to be cloned (check what exists on my domain!)
os.execute("git clone https://TangentFoxy@github.com/TangentFoxy/" .. name)
-- os.execute("cd " .. name .. " && git branch")
end
-- if true then os.exit() end
organizations = (function()
local ordered = {}
for name in pairs(organizations) do
table.insert(ordered, name)
end
table.sort(ordered)
return ordered
end)()
table.sort(repository_names)
-- TODO figure out how to use the API to do this automatically
print("Create the following organizations:")
for _, name in ipairs(organizations) do
print(" " .. name)
end
print("Press enter to continue.")
io.read("*line")
-- TODO figure out how to use the API to do this automatically
print("Create the following repos:")
for _, name in ipairs(repository_names) do
print(" " .. name)
end
print("Press enter to continue.")
io.read("*line")
-- NOTE assumes main branch is the only thing that exists / matters
-- TODO make it detect and handle or warn about other branches
for name, info in pairs(repositories) do
local command = "cd " .. name
command = command .. " && git remote set-url origin https://tangent@gitea.tangentfox.com/" .. info.organization .. "/" .. name .. ".git"
command = command .. " && git push -u origin main"
os.execute(command)
os.execute("sleep 1") -- I assume my server can't handle it as well as GitHub's
end