121 lines
3.9 KiB
Lua
Executable File
121 lines
3.9 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"
|
|
|
|
local extract_bundles = function(path)
|
|
utility.list(path, function(file_name)
|
|
local _, name, extension = utility.split_path_components(file_name)
|
|
if not extension or not (extension == "bundle") then return end -- only work on bundles
|
|
|
|
local output_path, repo_name
|
|
if extension then
|
|
repo_name = name:sub(1, -(#extension + 2) - #("-main"))
|
|
output_path = path .. "/" .. repo_name
|
|
end
|
|
|
|
if utility.path_exists(output_path) then
|
|
return
|
|
end
|
|
|
|
os.execute("git clone " .. name:enquote() .. " " .. output_path:enquote())
|
|
-- TEMP since I happen to be moving Minecraft organization items right now..
|
|
-- os.execute("git clone " .. name:enquote() .. " " .. output_path:enquote()
|
|
-- .. " && cd " .. output_path:enquote()
|
|
-- .. " && git remote set-url origin https://tangent@gitea2.tangentfox.com/Minecraft/" .. repo_name
|
|
-- .. " && git push origin")
|
|
end)
|
|
end
|
|
|
|
extract_bundles(".")
|
|
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
|