summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-08-21 16:08:29 +0800
committerruki <[email protected]>2021-08-21 16:08:29 +0800
commit8b3f30b4200b371e118bd31857d1d48c17b2969d (patch)
treefea531ab7a4a0f34d28b7938d1235baa4d6994a0
parent03edbeb91a3b4e5d6d113949d433424497431613 (diff)
improve to get repo commit
-rw-r--r--tests/projects/package/toolchain_muslcc/xmake-requires.lock28
-rw-r--r--xmake/core/package/package.lua1
-rw-r--r--xmake/core/package/repository.lua10
-rw-r--r--xmake/modules/private/action/require/impl/lock_packages.lua13
-rw-r--r--xmake/modules/private/action/require/impl/repository.lua14
5 files changed, 46 insertions, 20 deletions
diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock
index 906fba5ed..4379fdf79 100644
--- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock
+++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock
@@ -7,25 +7,25 @@
buildhash = "cd4169a7cb484832b2f70d2174072ca2",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "4498f11267de5112199152ab030ed139c985ad5a",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "2.71"
},
["automake#ddbdd8b8f76d455a8c0ef45fffe37160"] = {
- buildhash = "7a090c93706241f983f0d821a162e8a5",
+ buildhash = "5b4ee7b727764ece8aa3e149603cfc7a",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
- version = "1.16.1"
+ version = "1.16.4"
},
["cmake#ddbdd8b8f76d455a8c0ef45fffe37160"] = {
buildhash = "a6d18f8c0bf347d980f8bb762583c91a",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "4498f11267de5112199152ab030ed139c985ad5a",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "3.21.0"
@@ -34,7 +34,7 @@
buildhash = "7dd9c224447e46698ac73d29f58b1d73",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "6.2.1"
@@ -43,7 +43,7 @@
buildhash = "f649e1fb365e442e8f79f372fd91483b",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "0.22"
@@ -52,7 +52,7 @@
buildhash = "d894fc29f2fb4c45a0f48bc2c6ece273",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "v1.3.4"
@@ -61,7 +61,7 @@
buildhash = "0c01b22920be4876b1de74629194eb8f",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "2.2.0"
@@ -70,7 +70,7 @@
buildhash = "64584ec84a4743ecb740b598b263ffa6",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "2.4.6"
@@ -79,7 +79,7 @@
buildhash = "fd0e83e5759b442a970327ebb1c89793",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "1.4.19"
@@ -88,7 +88,7 @@
buildhash = "11062c09ebeb484594488ad73ddbcd1f",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "20210202"
@@ -97,7 +97,7 @@
buildhash = "84fd7f9b9f7a47709512cfc85cd9e5f7",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "0.29.2"
@@ -106,7 +106,7 @@
buildhash = "be90a245b8bb48e6b08a1a15bdcad467",
repo = {
branch = "master",
- commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375",
+ commit = "eda7adee81bac151f87c507030cc0dd8ab299462",
url = "https://gitee.com/tboox/xmake-repo.git"
},
version = "1.2.11"
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index d68f782e4..a2b4163e5 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -628,6 +628,7 @@ function _instance:manifest_save()
manifest.repo.name = repo:name()
manifest.repo.url = repo:url()
manifest.repo.branch = repo:branch()
+ manifest.repo.commit = repo:commit()
end
-- save manifest
diff --git a/xmake/core/package/repository.lua b/xmake/core/package/repository.lua
index 6485b426f..fd9a275f1 100644
--- a/xmake/core/package/repository.lua
+++ b/xmake/core/package/repository.lua
@@ -74,6 +74,16 @@ function _instance:branch()
return self._BRANCH
end
+-- get the current commit
+function _instance:commit()
+ return self._COMMIT
+end
+
+-- set the commit
+function _instance:commit_set(commit)
+ self._COMMIT = commit
+end
+
-- is global repository?
function _instance:is_global()
return self._IS_GLOBAL
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