From 12652bfd524697241b893d4a4e1672ecc3608f2c Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 14 Apr 2022 00:37:13 +0800 Subject: support git commit as require version --- xmake/core/package/package.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'xmake/core/package/package.lua') diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index c7ae4901b..43d4e1307 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1016,10 +1016,17 @@ function _instance:version_set(version, source) self._BRANCH = version elseif source == "tag" then self._TAG = version + elseif source == "commit" then + self._COMMIT = version end -- save version string - self._VERSION_STR = version + if source == "commit" then + -- we strip it to avoid long paths + self._VERSION_STR = version:sub(1, 8) + else + self._VERSION_STR = version + end end -- get branch version @@ -1032,9 +1039,14 @@ function _instance:tag() return self._TAG end +-- get commit version +function _instance:commit() + return self._COMMIT +end + -- is git ref? function _instance:gitref() - return self:branch() or self:tag() + return self:branch() or self:tag() or self:commit() end -- get the require info -- cgit v1.3.1