115 lines
3.7 KiB
Lua
Executable File
115 lines
3.7 KiB
Lua
Executable File
#!/usr/bin/env luajit
|
|
package.path = (arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "lib" .. package.config:sub(1, 1) .. "?.lua;" .. package.path
|
|
local utility = require "utility"
|
|
|
|
-- TEMP import repos from export, add target information to mirrors
|
|
local export = utility.load_data("export.json")
|
|
local data = utility.load_data("respositories.json")
|
|
data.respositories["https://gitea.tangentfox.com/"] = {}
|
|
local old_site = data.respositories["https://gitea.tangentfox.com/"]
|
|
|
|
for name, repo in pairs(export.repositories) do
|
|
local org = repo.organization
|
|
if not old_site[org] then old_site[org] = {} end
|
|
old_site[org][name] = { description = repo.description, website = repo.website, }
|
|
end
|
|
|
|
for url, org in pairs(data.mirrors["https://github.com/"]) do
|
|
for name, repo in pairs(org) do
|
|
repo.target = "https://gitea2.tangentfox.com/mirrors/" .. name
|
|
end
|
|
end
|
|
|
|
utility.save_data(data)
|
|
os.exit()
|
|
|
|
-- 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.",
|
|
["bullet-hell"] = {
|
|
organization = "prototype",
|
|
description = "A prototype bullet hell game!",
|
|
},
|
|
neralie = {
|
|
organization = "tools",
|
|
description = "A simple clock for the Neralie decimal time format.",
|
|
website = "https://wiki.xxiivv.com/site/time",
|
|
},
|
|
}
|
|
|
|
-- TODO figure out how to use API to automatically set these up
|
|
local mirrors = {
|
|
"markdown.lua",
|
|
"love-pe",
|
|
"slam",
|
|
}
|
|
|
|
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") -- TODO figure out why I had this? do I need to manually push each branch or does that happen automatically?
|
|
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
|
|
-- TODO figure out how to set a description as well
|
|
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
|
|
-- TODO figure out how to set their descriptions and URLs as well
|
|
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
|
|
|
|
-- TODO figure out how to set up the push sync using the API
|