2016-12-11 19:24:52 +00:00
|
|
|
local git = require('git')
|
|
|
|
|
2017-10-08 21:45:01 +00:00
|
|
|
local fs = _G.fs
|
|
|
|
|
2016-12-11 19:24:52 +00:00
|
|
|
local gitfs = { }
|
|
|
|
|
2017-09-16 00:27:56 +00:00
|
|
|
function gitfs.mount(dir, repo)
|
2018-01-24 22:39:38 +00:00
|
|
|
if not repo then
|
|
|
|
error('gitfs syntax: repo')
|
|
|
|
end
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2018-01-24 22:39:38 +00:00
|
|
|
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)
|
|
|
|
node.size = entry.size
|
|
|
|
end
|
|
|
|
end
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return gitfs
|