diff options
| author | ruki <[email protected]> | 2017-09-04 16:46:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-04 16:46:30 +0800 |
| commit | 4fead28a91b650fd7268e708afdf4dc97935d454 (patch) | |
| tree | acbc0c9f1e34689d8b3858f76acfd87861bf2499 /xmake/plugins | |
| parent | 08ec1c7dcab891641f6b2fb6a61c2c3b210f5f55 (diff) | |
add require to build and optmize ping
Diffstat (limited to 'xmake/plugins')
| -rw-r--r-- | xmake/plugins/repo/main.lua | 65 | ||||
| -rw-r--r-- | xmake/plugins/repo/xmake.lua | 22 |
2 files changed, 75 insertions, 12 deletions
diff --git a/xmake/plugins/repo/main.lua b/xmake/plugins/repo/main.lua index 565b8edac..344e4eb4e 100644 --- a/xmake/plugins/repo/main.lua +++ b/xmake/plugins/repo/main.lua @@ -65,6 +65,62 @@ function _remove(name, is_global) cprint("${bright}remove %s repository(%s): %s ok!", ifelse(is_global, "global", "local"), name, url) end +-- update repositories +function _update() + + -- trace + printf("updating repositories .. ") + if option.get("verbose") then + print("") + end + + -- create a pull task + local task = function () + + -- get all repositories (local first) + local repos = table.join(repository.repositories(false), repository.repositories(true)) + + -- pull all repositories + local pulled = {} + for _, repo in ipairs(repos) do + + -- the repository directory + local repodir = path.join(repository.directory(repo.global), repo.name) + + -- remove repeat and only pull the first repository + if not pulled[repodir] then + if os.isdir(repodir) then + + -- trace + vprint("pulling repository(%s): %s to %s ..", repo.name, repo.url, repodir) + + -- pull it + git.pull({verbose = option.get("verbose"), branch = "master", repodir = repodir}) + else + -- trace + vprint("cloning repository(%s): %s to %s ..", repo.name, repo.url, repodir) + + -- clone it + git.clone(repo.url, {verbose = option.get("verbose"), branch = "master", outputdir = repodir}) + end + + -- pull this repository ok + pulled[repodir] = true + end + end + end + + -- pull repositories + if option.get("verbose") then + task() + else + process.asyncrun(task) + end + + -- trace + cprint("${green}ok") +end + -- clear all repositories function _clear(is_global) @@ -82,7 +138,7 @@ function _clear(is_global) end -- list all repositories -function _list(is_global) +function _list() -- list all repositories local count = 0 @@ -140,6 +196,11 @@ function main() _remove(option.get("name"), option.get("global")) + -- update repository url + elseif option.get("update") then + + _update() + -- clear all repositories elseif option.get("clear") then @@ -148,7 +209,7 @@ function main() -- list all repositories elseif option.get("list") then - _list(option.get("global")) + _list() -- show help else diff --git a/xmake/plugins/repo/xmake.lua b/xmake/plugins/repo/xmake.lua index dafd7ae26..cb15e87fb 100644 --- a/xmake/plugins/repo/xmake.lua +++ b/xmake/plugins/repo/xmake.lua @@ -42,13 +42,15 @@ task("repo") -- options , options = { - {'a', "add", "k", nil, "Add the given remote repository url." } - , {'r', "remove", "k", nil, "Remove the given remote repository url." } - , {'l', "list", "k", nil, "List all added repositories." } - , {'g', "global", "k", nil, "Save repository to global. (default: local)" } - , {'c', "clear", "k", nil, "Clear all added repositories." } - , { } - , {nil, "name", "v", nil, "The repository name." } - , {nil, "url", "v", nil, "The repository url" } - } - } + {'a', "add", "k", nil, "Add the given remote repository url." } + , {'r', "remove", "k", nil, "Remove the given remote repository url." } + , {'u', "update", "k", nil, "Update all local repositories from the remote." } + , {'c', "clear", "k", nil, "Clear all added repositories." } + , { } + , {'l', "list", "k", nil, "List all added repositories." } + , {'g', "global", "k", nil, "Save repository to global. (default: local)" } + , { } + , {nil, "name", "v", nil, "The repository name." } + , {nil, "url", "v", nil, "The repository url" } + } + } |
