Compare commits
3
Commits
9b7c9b86f5
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fca4eee077 | ||
|
|
6fc0803095 | ||
|
|
c45a147e84 |
No files matched your search
@@ -1,4 +1,5 @@
|
||||
# repo-manager
|
||||
Script to automate mirroring and copying of git repos.
|
||||
|
||||
- [x] store repositories keyed by name (tree-style is better for avoiding conflicts while being specific and easy to follow)
|
||||
- [x] repositories have a ~~source~~ origin url and optional mirror URLs (just one for now, called `target`)
|
||||
@@ -37,6 +38,7 @@ The idea is to make a tree based on the *source* of a repo,
|
||||
with special keys for what to do with that source,
|
||||
and optional `target` URLs for mirroring.
|
||||
- `description`: Short description typically displayed in lists on hosting services.
|
||||
- `issues`: Like `redundant` below, this is a temporary tag for helping me sort things out.
|
||||
- `private`: If a repo needs to be created, it will be private only if this is true.
|
||||
- `redundant`: This repo really doesn't need to exist, but hasn't been removed yet. (This is essentially for my own notes.)
|
||||
- `target`: A repo URL to force-push to for mirroring.
|
||||
|
||||
+22
-16
@@ -2,25 +2,31 @@
|
||||
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/"]
|
||||
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
|
||||
|
||||
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, }
|
||||
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
|
||||
|
||||
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)
|
||||
extract_bundles(".")
|
||||
os.exit()
|
||||
|
||||
-- TODO add support for private repos by making it warn the user
|
||||
|
||||
Reference in new issue
Block a user