mirror of
https://github.com/kepler155c/opus
synced 2025-10-25 04:37:40 +00:00
reorganization
This commit is contained in:
@@ -2,12 +2,12 @@ local git = require('git')
|
||||
|
||||
local gitfs = { }
|
||||
|
||||
function gitfs.mount(dir, user, repo, branch)
|
||||
if not user or not repo then
|
||||
error('gitfs syntax: user, repo, [branch]')
|
||||
function gitfs.mount(dir, repo)
|
||||
if not repo then
|
||||
error('gitfs syntax: repo')
|
||||
end
|
||||
|
||||
local list = git.list(user, repo, branch)
|
||||
local list = git.list(repo)
|
||||
for path, entry in pairs(list) do
|
||||
if not fs.exists(fs.combine(dir, path)) then
|
||||
local node = fs.mount(fs.combine(dir, path), 'urlfs', entry.url)
|
||||
|
||||
@@ -6,8 +6,13 @@ local FILE_URL = 'https://raw.github.com/%s/%s/%s/%s'
|
||||
|
||||
local git = { }
|
||||
|
||||
function git.list(user, repo, branch)
|
||||
branch = branch or 'master'
|
||||
function git.list(repo)
|
||||
|
||||
local t = Util.split(repo, '(.-)/')
|
||||
|
||||
local user = t[1]
|
||||
local repo = t[2]
|
||||
local branch = t[3] or 'master'
|
||||
|
||||
local dataUrl = string.format(TREE_URL, user, repo, branch)
|
||||
local contents = Util.download(dataUrl)
|
||||
|
||||
@@ -379,8 +379,15 @@ function Util.download(url, filename)
|
||||
end
|
||||
|
||||
function Util.loadUrl(url, env) -- loadfile equivalent
|
||||
local c = Util.download(url)
|
||||
return load(c, url, nil, env)
|
||||
local s, m = pcall(function()
|
||||
local c = Util.download(url)
|
||||
return load(c, url, nil, env)
|
||||
end)
|
||||
|
||||
if s then
|
||||
return m
|
||||
end
|
||||
return s, m
|
||||
end
|
||||
|
||||
function Util.runUrl(env, url, ...) -- os.run equivalent
|
||||
@@ -390,7 +397,7 @@ function Util.runUrl(env, url, ...) -- os.run equivalent
|
||||
fn, m = pcall(function() fn(unpack(args)) end)
|
||||
end
|
||||
if not fn and m and m ~= '' then
|
||||
printError(m)
|
||||
-- printError(m)
|
||||
end
|
||||
return fn, m
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user