diff options
| author | ruki <[email protected]> | 2026-03-03 23:51:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-03 23:51:59 +0800 |
| commit | 193e80cbad47912de959fe34b3e66614bfacd5e2 (patch) | |
| tree | db8c4c3ae760f4e75a73a6451b15ccea9400eb46 | |
| parent | bfe054a81df11f3d06c2a00667520109990e29cf (diff) | |
improve repositories api
| -rw-r--r-- | xmake/actions/create/template.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/package/repository.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/repository.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/repo/main.lua | 4 |
4 files changed, 7 insertions, 6 deletions
diff --git a/xmake/actions/create/template.lua b/xmake/actions/create/template.lua index 8b7e4be99..eb9e10b16 100644 --- a/xmake/actions/create/template.lua +++ b/xmake/actions/create/template.lua @@ -40,7 +40,7 @@ function rootinfos() local results = {} -- get template directories from global repositories - local repos = repository.repositories(true, {network = false}) + local repos = repository.repositories({global = true, network = false}) if repos then for _, repo in ipairs(repos) do local templatesdir = path.join(repo:directory(), "templates") diff --git a/xmake/core/sandbox/modules/import/core/package/repository.lua b/xmake/core/sandbox/modules/import/core/package/repository.lua index 32eee5279..f4269bb9e 100644 --- a/xmake/core/sandbox/modules/import/core/package/repository.lua +++ b/xmake/core/sandbox/modules/import/core/package/repository.lua @@ -62,9 +62,11 @@ end -- get all repositories from global or local directory -- -- opt: +-- - global = true: load global repositories -- - network = false: do not access network resources (skip fasturl sorting) -function sandbox_core_package_repository.repositories(is_global, opt) +function sandbox_core_package_repository.repositories(opt) opt = opt or {} + local is_global = opt.global -- load repositories from repository cache local repositories = {} diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua index ba0c9205f..3df59c42c 100644 --- a/xmake/modules/private/action/require/impl/repository.lua +++ b/xmake/modules/private/action/require/impl/repository.lua @@ -117,7 +117,7 @@ function repositories() return _g._REPOSITORIES end -- get all repositories (local first) - local repos = table.join(repository.repositories(false), repository.repositories(true)) + local repos = table.join(repository.repositories({global = false}), repository.repositories({global = true})) _g._REPOSITORIES = repos return repos end @@ -220,4 +220,3 @@ function artifacts_manifest(packagename, version) end end end - diff --git a/xmake/plugins/repo/main.lua b/xmake/plugins/repo/main.lua index cb21992e7..5ca614da5 100644 --- a/xmake/plugins/repo/main.lua +++ b/xmake/plugins/repo/main.lua @@ -106,7 +106,7 @@ function _update() local task = function () -- get all repositories (local first) - local repos = table.join(repository.repositories(false), repository.repositories(true)) + local repos = table.join(repository.repositories({global = false}), repository.repositories({global = true})) if name then for _, repo in ipairs(repos) do if repo:name() == name then @@ -184,7 +184,7 @@ function _list(is_global) local count = 0 for _, position in ipairs(is_global and "global" or {"local", "global"}) do print("%s repositories:", position) - for _, repo in pairs(repository.repositories(position == "global")) do + for _, repo in pairs(repository.repositories({global = position == "global"})) do print(" %s %s%s", repo:name(), repo:url(), repo:branch() and (" " .. repo:branch()) or "") count = count + 1 end |
