diff options
| author | ruki <[email protected]> | 2021-08-21 16:08:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-08-21 16:08:29 +0800 |
| commit | 8b3f30b4200b371e118bd31857d1d48c17b2969d (patch) | |
| tree | fea531ab7a4a0f34d28b7938d1235baa4d6994a0 /xmake/modules | |
| parent | 03edbeb91a3b4e5d6d113949d433424497431613 (diff) | |
improve to get repo commit
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/require/impl/lock_packages.lua | 13 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/repository.lua | 14 |
2 files changed, 21 insertions, 6 deletions
diff --git a/xmake/modules/private/action/require/impl/lock_packages.lua b/xmake/modules/private/action/require/impl/lock_packages.lua index 3eba5d00f..0e340e602 100644 --- a/xmake/modules/private/action/require/impl/lock_packages.lua +++ b/xmake/modules/private/action/require/impl/lock_packages.lua @@ -40,11 +40,14 @@ function _lock_package(instance) result.branch = instance:branch() result.tag = instance:tag() if repo then - local lastcommit = try {function() - if os.isdir(path.join(repo:directory(), ".git")) then - return git.lastcommit({repodir = repo:directory()}) - end - end} + local lastcommit + local manifest = instance:manifest_load() + if manifest and manifest.repo then + lastcommit = manifest.repo.commit + end + if not lastcommit then + lastcommit = repo:commit() + end result.repo = {url = repo:url(), commit = lastcommit, branch = repo:branch()} end return result diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua index 1acbfb618..4f1e44f27 100644 --- a/xmake/modules/private/action/require/impl/repository.lua +++ b/xmake/modules/private/action/require/impl/repository.lua @@ -160,7 +160,19 @@ function packagedir(packagename, opt) end packagedirs[cachekey] = foundir or {} end - return foundir[1], foundir[2] + + -- save the current commit + local dir = foundir[1] + local repo = foundir[2] + if repo and not repo:commit() then + local lastcommit = try {function() + if os.isdir(path.join(repo:directory(), ".git")) then + return git.lastcommit({repodir = repo:directory()}) + end + end} + repo:commit_set(lastcommit) + end + return dir, repo end -- get artifacts manifest from repositories |
