diff options
| author | ruki <[email protected]> | 2022-03-13 16:49:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-03-13 16:49:46 +0800 |
| commit | fd3212860f087849cd59c0435f66da2aac52f32a (patch) | |
| tree | 902699a1d4d4a1ef7eb71f5d4c0e9e8da1fef9f5 | |
| parent | 321b13a3b93168eb840d3cb395300b5e43288307 (diff) | |
improve to pull repo
| -rw-r--r-- | xmake/modules/private/action/require/check.lua | 18 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/repository.lua | 20 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/install.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/repo/main.lua | 20 |
4 files changed, 30 insertions, 30 deletions
diff --git a/xmake/modules/private/action/require/check.lua b/xmake/modules/private/action/require/check.lua index 6b37eeb8b..943e6aad4 100644 --- a/xmake/modules/private/action/require/check.lua +++ b/xmake/modules/private/action/require/check.lua @@ -20,8 +20,12 @@ -- imports import("core.base.option") +import("core.base.task") +import("lib.detect.find_tool") import("private.async.runjobs") import("private.action.require.impl.package") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") import("private.action.require.impl.register_packages") import("private.action.require.impl.utils.get_requires") @@ -35,6 +39,20 @@ function main(requires_raw) return end + -- find git + environment.enter() + local git = find_tool("git") + environment.leave() + + -- pull all repositories first if not exists + -- + -- attempt to install git from the builtin-packages first if git not found + -- + if git and (not repository.pulled() or option.get("upgrade")) then + print("repo update") + task.run("repo", {update = true}) + end + -- install packages local packages = package.load_packages(requires, {requires_extra = requires_extra}) if packages then diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua index 6fb4fccdc..f6ad1b777 100644 --- a/xmake/modules/private/action/require/impl/repository.lua +++ b/xmake/modules/private/action/require/impl/repository.lua @@ -115,16 +115,18 @@ end function pulled() if global.get("network") ~= "private" then for _, repo in ipairs(repositories()) do - -- repository not found? or xmake has been re-installed - local repodir = repo:directory() - local updatefile = path.join(repodir, "updated") - if not os.isfile(updatefile) or (os.isfile(updatefile) and os.mtime(os.programfile()) > os.mtime(updatefile)) then - -- fix broken empty directory - -- @see https://github.com/xmake-io/xmake/issues/2159 - if os.isdir(repodir) and os.emptydir(repodir) then - os.tryrm(repodir) + if not os.isdir(repo:url()) then + -- repository not found? or xmake has been re-installed + local repodir = repo:directory() + local updatefile = path.join(repodir, "updated") + if not os.isfile(updatefile) or (os.isfile(updatefile) and os.mtime(os.programfile()) > os.mtime(updatefile)) then + -- fix broken empty directory + -- @see https://github.com/xmake-io/xmake/issues/2159 + if os.isdir(repodir) and os.emptydir(repodir) then + os.tryrm(repodir) + end + return false end - return false end end end diff --git a/xmake/modules/private/action/require/install.lua b/xmake/modules/private/action/require/install.lua index e27e627cb..c75df8a35 100644 --- a/xmake/modules/private/action/require/install.lua +++ b/xmake/modules/private/action/require/install.lua @@ -84,8 +84,6 @@ function main(requires_raw) environment.enter() local packages = install_packages(requires, {requires_extra = requires_extra}) if packages then - - -- check missing packages _check_missing_packages(packages) end environment.leave() diff --git a/xmake/plugins/repo/main.lua b/xmake/plugins/repo/main.lua index 4baa1f540..64240cd7a 100644 --- a/xmake/plugins/repo/main.lua +++ b/xmake/plugins/repo/main.lua @@ -94,39 +94,21 @@ function _update() -- pull all repositories local pulled = {} for _, repo in ipairs(repos) do - - -- the repository directory local repodir = repo:directory() - - -- remove repeat and only pull the first repository if not pulled[repodir] then if os.isdir(repodir) then - - -- update the local repository with the remote url + -- only update the local repository with the remote url if not os.isdir(repo:url()) then - - -- trace vprint("pulling repository(%s): %s to %s ..", repo:name(), repo:url(), repodir) - - -- pull it git.pull({verbose = option.get("verbose"), branch = repo:branch() or "master", repodir = repodir}) - - -- mark as updated io.save(path.join(repodir, "updated"), {}) end else - -- trace vprint("cloning repository(%s): %s to %s ..", repo:name(), repo:url(), repodir) - - -- clone it local remoteurl = proxy.mirror(repo:url()) or repo:url() git.clone(remoteurl, {verbose = option.get("verbose"), branch = repo:branch() or "master", outputdir = repodir}) - - -- mark as updated io.save(path.join(repodir, "updated"), {}) end - - -- pull this repository ok pulled[repodir] = true end end |
