From 3482c270e2d95680d7aebda29cc11b2eb5009dfc Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 29 Oct 2018 23:59:08 +0800 Subject: support package revision --- xmake/actions/require/impl/action/download.lua | 8 ++++---- xmake/core/package/package.lua | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xmake/actions/require/impl/action/download.lua b/xmake/actions/require/impl/action/download.lua index 6fc0d5f3c..3c93e0bdf 100644 --- a/xmake/actions/require/impl/action/download.lua +++ b/xmake/actions/require/impl/action/download.lua @@ -44,7 +44,7 @@ function _emptychars() end -- checkout codes from git -function _checkout(package, url, sourcedir) +function _checkout(package, url, sourcedir, url_alias) -- use previous source directory if exists local packagedir = path.join(sourcedir, package:name()) @@ -65,14 +65,14 @@ function _checkout(package, url, sourcedir) -- only shadow clone this branch git.clone(url, {depth = 1, branch = package:version_str(), outputdir = packagedir}) - -- download package from tags or versions? + -- download package from revision, tag or version? else -- clone whole history and tags git.clone(url, {outputdir = packagedir}) -- attempt to checkout the given version - git.checkout(package:version_str(), {repodir = packagedir}) + git.checkout(package:revision(url_alias) or package:version_str(), {repodir = packagedir}) end -- move to source directory @@ -180,7 +180,7 @@ function main(package) -- download package local sourcedir = "source" if git.checkurl(url) then - _checkout(package, url, sourcedir) + _checkout(package, url, sourcedir, url_alias) else _download(package, url, sourcedir, url_alias, url_excludes) end diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index a4ab50855..3554c0e72 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -177,6 +177,11 @@ function _instance:sha256(url_alias) end end +-- get revision(commit, tag, branch) of the url_alias@version_str, only for git url +function _instance:revision(url_alias) + return self:sha256(url_alias) +end + -- this package is from system/local/global? -- -- @param kind the from kind -- cgit v1.3.1