From 558d271ae085eea780cd75222927f25cd2ce5a9e Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Fri, 19 May 2017 20:55:19 -0400 Subject: [PATCH] branch support --- .gitignore | 1 + sys/apis/fs/gitfs.lua | 5 +++-- sys/apis/git.lua | 5 ++++- sys/apis/injector.lua | 11 ++++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b69bcf7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/ignore diff --git a/sys/apis/fs/gitfs.lua b/sys/apis/fs/gitfs.lua index c690580..3b62613 100644 --- a/sys/apis/fs/gitfs.lua +++ b/sys/apis/fs/gitfs.lua @@ -8,8 +8,9 @@ function gitfs.mount(dir, user, repo, branch) end local list = git.list(user, repo, branch) - for path, url in pairs(list) do - fs.mount(fs.combine(dir, path), 'urlfs', url) + for path, entry in pairs(list) do + local node = fs.mount(fs.combine(dir, path), 'urlfs', entry.url) + node.size = entry.size end end diff --git a/sys/apis/git.lua b/sys/apis/git.lua index ccaaf5f..e72199c 100644 --- a/sys/apis/git.lua +++ b/sys/apis/git.lua @@ -31,7 +31,10 @@ function git.list(user, repo, branch) for k,v in pairs(data.tree) do if v.type == "blob" then v.path = v.path:gsub("%s","%%20") - list[v.path] = string.format(FILE_URL, user, repo, branch, v.path) + list[v.path] = { + url = string.format(FILE_URL, user, repo, branch, v.path), + size = v.size, + } end end diff --git a/sys/apis/injector.lua b/sys/apis/injector.lua index f0014c3..5813106 100644 --- a/sys/apis/injector.lua +++ b/sys/apis/injector.lua @@ -1,4 +1,13 @@ -local DEFAULT_UPATH = 'https://raw.githubusercontent.com/kepler155c/opus/master/sys/apis' +local branch = 'master' +if fs.exists('.branch') then + local f = fs.open('.branch', "r") + if f then + branch = f.readAll() + f.close() + end +end + +local DEFAULT_UPATH = 'https://raw.githubusercontent.com/kepler155c/opus/' .. branch .. '/sys/apis' local PASTEBIN_URL = 'http://pastebin.com/raw' local GIT_URL = 'https://raw.githubusercontent.com'