-
Notifications
You must be signed in to change notification settings - Fork 1
/
repo.lua
42 lines (36 loc) · 1.05 KB
/
repo.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
37
38
39
40
41
42
local p = premake
local pkg = p.extensions.pkg
pkg.repo = pkg.repo or {}
local repo = pkg.repo
-- Index in array: major version
-- Element value: max minor version (nil means not supported)
-- 1.0.0 -> 1.0.*
repo.supportedRepoVersions = { nil, 0 }
function repo:new(api, path)
local object = {
api = api,
path = path,
loaded = false,
cleanable = api:isCleanable(),
pkgs = {},
exts = {}
}
setmetatable(object, self)
self.__index = self
return object
end
function repo:splitRepoName(name)
local pindex = name:find("+", 1, true)
if not pindex then return nil, name end
local repoapi = name:sub(1, pindex - 1)
local repopath = name:sub(pindex + 1)
return repoapi, repopath
end
function repo:isVersionSupported(version)
if version.major < 0 then return false end
if version.major > #self.supportedRepoVersions then return false end
local maxMinor = self.supportedRepoVersions[version.major + 1]
if maxMinor == nil then return false end
if version.minor < 0 then return false end
return version.minor <= maxMinor
end