소스 검색

improve autoupdate

ruki 1 년 전
부모
커밋
f37f033e9e
1개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 13 1
      scripts/checkupdate.lua

+ 13 - 1
scripts/checkupdate.lua

@@ -98,6 +98,18 @@ function _check_version_from_github_releases(package, url)
     end
 end
 
+function _version_is_behind_conditions(package)
+    local scriptfile = path.join(package:scriptdir(), "xmake.lua")
+    local file = io.open(scriptfile)
+    for line in file:lines() do
+        local pos = line:find("add_versions", 1, true) or line:find("add_versionfiles", 1, true)
+        if pos and pos > 5 then
+            return true
+        end
+    end
+    file:close()
+end
+
 function main(package)
     local checkers = {
         ["https://github%.com/.-/.-/archive/refs/tags/.*"] = _check_version_from_github_tags,
@@ -105,7 +117,7 @@ function main(package)
     }
     for _, url in ipairs(package:urls()) do
         for pattern, checker in pairs(checkers) do
-            if url:match(pattern) then
+            if url:match(pattern) and not _version_is_behind_conditions(package) then
                 return checker(package, url)
             end
         end