From a25cf41154e0c94f237f17bb9c0d58012c11a75d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 11 Jan 2024 00:55:40 +0800 Subject: [PATCH] improve to check pending --- scripts/autoupdate.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/autoupdate.lua b/scripts/autoupdate.lua index a4e40a0e7..939f5ab15 100644 --- a/scripts/autoupdate.lua +++ b/scripts/autoupdate.lua @@ -37,16 +37,9 @@ function _get_all_packages() return packages end -function _update_version(instance, version, shasum) +function _is_pending(instance, version) local branch = "autoupdate-" .. instance:name() .. "-" .. version - local branch_current = os.iorun("git branch --show-current"):trim() local repourl = "https://github.com/xmake-io/xmake-repo.git" - os.vexec("git reset --hard HEAD") - os.execv("git", {"branch", "-D", branch}, {try = true}) - os.vexec("git checkout dev") - os.vexec("git pull %s dev", repourl) - os.vexec("git branch %s", branch) - os.vexec("git checkout %s", branch) local is_pending = false local remote_branches = os.iorun("git ls-remote --head %s", repourl) if remote_branches then @@ -58,6 +51,19 @@ function _update_version(instance, version, shasum) end end end + return is_pending +end + +function _update_version(instance, version, shasum) + local branch = "autoupdate-" .. instance:name() .. "-" .. version + local branch_current = os.iorun("git branch --show-current"):trim() + local repourl = "https://github.com/xmake-io/xmake-repo.git" + os.vexec("git reset --hard HEAD") + os.execv("git", {"branch", "-D", branch}, {try = true}) + os.vexec("git checkout dev") + os.vexec("git pull %s dev", repourl) + os.vexec("git branch %s", branch) + os.vexec("git checkout %s", branch) local scriptfile = path.join(instance:scriptdir(), "xmake.lua") if os.isfile(scriptfile) and not is_pending then local inserted = false @@ -94,7 +100,7 @@ function main(maxcount) if os.isfile(checkupdate_filepath) and count < maxcount then local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true}) local version, shasum = checkupdate(instance) - if version and shasum then + if version and shasum and not _is_pending(instance, version) then cprint("package(%s): new version ${bright}%s${clear} found, shasum: ${bright}%s", instance:name(), version, shasum) _update_version(instance, version, shasum) count = count + 1