-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanifest.lua
36 lines (29 loc) · 937 Bytes
/
manifest.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local db = require 'plugins.miq.db'
local util = require 'plugins.miq.util'
local M = {}
local repoDir = USERDIR .. '/miq-repos/'
local function updateManifestCache(repo)
local f = io.open(repoDir .. util.repoDir(repo) .. '/manifest.json')
local content = f:read '*a'
db.addRepo(util.repoDir(repo), content)
end
-- repo is a string with the following format:
-- url:tag
-- example https://github.com/lite-xl/lite-xl-plugins.git:2.1
function M.downloadRepo(repo, dir)
local url = util.repoURL(repo)
local tag = util.repoTag(repo)
local dir = dir or repoDir .. util.repoDir(repo)
if not util.fileExists(repoDir .. util.repoDir(repo)) then
local out, code = util.exec {'git', 'clone', url, dir}
if code ~= 0 then
return out, code
end
end
local out, code = util.exec {'sh', '-c', string.format('cd %s && git checkout %s', dir, tag)}
if code == 0 then
updateManifestCache(repo)
end
return out, code
end
return M