From 67a1dde6dcf40c2f5d7f8f9855ecf6b71a1cc6ca Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 11:59:32 +0200 Subject: [PATCH 01/10] far-bisect: update to use as commandline script (via LuaShell) --- Macros/scripts/far-bisect/far-bisect.lua | 31 +++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index 8b533f82..3a0ee17f 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -24,7 +24,7 @@ local Info = { Title = Title; } -local ThisDir = (...):match(".+\\") +local ThisDir = (_filename or ...):match(".+\\") local Opt = {} do local fOpt, fOptMsg = loadfile(ThisDir.."far-bisect.cfg") @@ -672,17 +672,26 @@ function State:Main() end end -Macro { - description=Title; - area="Shell"; key=MacroKey; - action=function() - local data = get_data_from_dialog() - if data then CreateState(data):Main(); end - end; -} - -package.loaded["farbisect"] = { +local M = { FAR1_OFFSET = FAR1_OFFSET; AUTO_GOOD = AUTO_GOOD; Main = function(data) mf.postmacro(function() CreateState(data):Main() end) end; } + +local function dlgBisect() + local data = get_data_from_dialog() + if data then CreateState(data):Main(); end +end + +if Macro then + package.loaded["farbisect"] = M + Macro { + description=Title; + area="Shell"; key=MacroKey; + action=dlgBisect; + } +elseif _cmdline then + mf.postmacro(dlgBisect) +else + return M +end From 06fe18e5eb08a1adb064e962690a11053f3f01f2 Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 12:02:48 +0200 Subject: [PATCH 02/10] far-bisect: prevent exit when no local builds available --- Macros/scripts/far-bisect/far-bisect.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index 3a0ee17f..c802252b 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -543,8 +543,8 @@ function State:Make_Local_Build_List(arch) end) end if buildlist[1] == nil then - far.Message("No Far builds are found.", Title, nil, "w") - mf.exit() + --far.Message("No Far builds are found.", Title, nil, "w") --fixme + --mf.exit() end return buildlist end From 6bea9d013c5ef1bf05ff3edf04a194eb977fdc7c Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 12:07:00 +0200 Subject: [PATCH 03/10] far-bisect: new minbuild combobox item: >= 3.0.5342 (First release at Github) --- Macros/scripts/far-bisect/far-bisect.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index c802252b..19c71575 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -61,11 +61,13 @@ local START_DEFAULT_FARCONFIG = 2917 -- Default.farconfig invented local START_LUAFARSTABLE = 3300 -- LuaFAR and Macro API become more or less stable local START_LUAPREFIX = 3880 -- command line prefix "lua:" instead of "macro:post" local START_BIGREFACTOR_DONE = 3924 -- completion of refactoring started in 3896 +local START_GITHUB = 5342 -- first available at Github release + -- indexes into the dialog's combobox: must be consecutive and start with 1 local INDEX_FAR1, INDEX_FAR2, INDEX_FAR3, INDEX_LUAMACRO, INDEX_LUAFARSTABLE, - INDEX_BIGREFACTOR = 1,2,3,4,5,6 + INDEX_BIGREFACTOR, INDEX_GITHUB = 1,2,3,4,5,6,7 local MinBuilds = { [INDEX_FAR1 ] = nil; @@ -74,6 +76,7 @@ local MinBuilds = { [INDEX_LUAMACRO ] = START_LUAMACRO; [INDEX_LUAFARSTABLE ] = START_LUAFARSTABLE; [INDEX_BIGREFACTOR ] = START_BIGREFACTOR_DONE; + [INDEX_GITHUB ] = START_GITHUB; } local PLUG_LF4ED = { ApiName="lf4ed"; Dir="lf4ed"; } @@ -130,6 +133,7 @@ local function create_dialog_items() [INDEX_LUAMACRO ] = {Text=">= 3.0.2851 (LuaMacro)"}; [INDEX_LUAFARSTABLE ] = {Text=">= 3.0.3300 (LuaFAR stable)"}; [INDEX_BIGREFACTOR ] = {Text=">= 3.0.3924 (Big Refactoring completed)"}; + [INDEX_GITHUB ] = {Text=">= 3.0.5342 (First release at Github)"}; }; }, ------------------------------------------------------------------------------ {tp="text"; text="&Command line arguments:"; }, From b876f55f7d05582ebf8de29e8a3a43e662ec2bbc Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 12:14:22 +0200 Subject: [PATCH 04/10] far-bisect: prepare for having different download locations --- Macros/scripts/far-bisect/far-bisect.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index 19c71575..a1c8863e 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -571,7 +571,7 @@ function State:Make_Web_Build_List(arch) for name, build, date in page:gmatch(patt) do build = tonumber(build) if not dates[build] or dates[build] > date then - map[build] = name + map[build] = Opt.FarNightlyDir..name dates[build] = date end end @@ -584,7 +584,7 @@ function State:MakeBuildList(arch) local map = self:Make_Web_Build_List(arch) or {} for build,name in pairs(map) do if not self.mArchiveMap[build] then - self.mArchiveMap[build] = Opt.FarNightlyDir .. name + self.mArchiveMap[build] = name table.insert(buildlist, build) end end From f38433a7376cd1aabb89dd075eb7b6143a98692a Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 12:26:02 +0200 Subject: [PATCH 05/10] far-bisect: use Github releases as primary builds source --- Macros/scripts/far-bisect/far-bisect.cfg | 8 +++++++ Macros/scripts/far-bisect/far-bisect.lua | 28 +++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Macros/scripts/far-bisect/far-bisect.cfg b/Macros/scripts/far-bisect/far-bisect.cfg index 13716571..406c3273 100644 --- a/Macros/scripts/far-bisect/far-bisect.cfg +++ b/Macros/scripts/far-bisect/far-bisect.cfg @@ -18,3 +18,11 @@ InstallDir = [[%TEMP%\Fartest]] Wget = [[C:\Shmuel_Home\Programs\EXE32\wget\wget.exe]] FarNightlyPage = [[https://farmanager.com/nightly.php]] FarNightlyDir = [[https://farmanager.com/nightly/]] + +-- required: gh.exe from https://cli.github.com/ +-- Ref: +-- * https://docs.github.com/en/rest/releases +-- * https://jqlang.github.io/jq/manual/ +local gh = "gh" +ListReleasesCmd = gh ..[[ api -X GET "repos/FarGroup/FarManager/releases?per_page=100" --jq ".[] | .name, (.assets.[].browser_download_url | select(.|test(\"7z$\") and (test(\"\\.pdb\") or test(\"ARM64\")|not)))"]] +ListFileTmp = [[github.releases.tmp]] diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index a1c8863e..1eb3a92a 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -553,6 +553,32 @@ function State:Make_Local_Build_List(arch) return buildlist end +local function parseGithubList(fname,arch,map) + local build + for line in io.lines(fname) do + local b = line:match"^v3%.0%.(%d+)" + if b then + b = assert(tonumber(b,10),b) + build = map[b] and "skip" or b + elseif build~="skip" then + if line:match("."..arch..".",1,true) then + map[build] = line + build = "skip" + end + end + end +end + +function State:Make_Github_Build_List(arch) + if not Opt.ListReleasesCmd then return end + + local map = {} + local fname = Opt.InstallDir.."\\"..Opt.ListFileTmp + win.system(Opt.ListReleasesCmd..">"..fname) + parseGithubList(fname,arch,map) + return map +end + function State:Make_Web_Build_List(arch) local fname = Opt.InstallDir.."\\"..Opt.FarNightlyPage:match("[^/]+$") win.DeleteFile(fname) -- prevent wget from creating files with suffixes @@ -581,7 +607,7 @@ end function State:MakeBuildList(arch) local buildlist = self:Make_Local_Build_List(arch) if self.web ~= "none" then - local map = self:Make_Web_Build_List(arch) or {} + local map = State:Make_Github_Build_List(arch) or self:Make_Web_Build_List(arch) or {} for build,name in pairs(map) do if not self.mArchiveMap[build] then self.mArchiveMap[build] = name From 279e680f606d6c3f376ab1c104a3960f33da46ff Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 12:47:09 +0200 Subject: [PATCH 06/10] far-bisect: use pre-created github releases filelist --- Macros/scripts/far-bisect/far-bisect.cfg | 1 + Macros/scripts/far-bisect/far-bisect.lua | 13 ++++++++++++- .../scripts/far-bisect/update.github.releases.cmd | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Macros/scripts/far-bisect/update.github.releases.cmd diff --git a/Macros/scripts/far-bisect/far-bisect.cfg b/Macros/scripts/far-bisect/far-bisect.cfg index 406c3273..43ba1af4 100644 --- a/Macros/scripts/far-bisect/far-bisect.cfg +++ b/Macros/scripts/far-bisect/far-bisect.cfg @@ -26,3 +26,4 @@ FarNightlyDir = [[https://farmanager.com/nightly/]] local gh = "gh" ListReleasesCmd = gh ..[[ api -X GET "repos/FarGroup/FarManager/releases?per_page=100" --jq ".[] | .name, (.assets.[].browser_download_url | select(.|test(\"7z$\") and (test(\"\\.pdb\") or test(\"ARM64\")|not)))"]] ListFileTmp = [[github.releases.tmp]] +ListFile = [[github.releases]] diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index 1eb3a92a..5ce051d9 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -554,12 +554,14 @@ function State:Make_Local_Build_List(arch) end local function parseGithubList(fname,arch,map) - local build + local build, overlap + local first = true for line in io.lines(fname) do local b = line:match"^v3%.0%.(%d+)" if b then b = assert(tonumber(b,10),b) build = map[b] and "skip" or b + if first then overlap = map[b]; first = false end elseif build~="skip" then if line:match("."..arch..".",1,true) then map[build] = line @@ -567,6 +569,7 @@ local function parseGithubList(fname,arch,map) end end end + return overlap end function State:Make_Github_Build_List(arch) @@ -576,6 +579,14 @@ function State:Make_Github_Build_List(arch) local fname = Opt.InstallDir.."\\"..Opt.ListFileTmp win.system(Opt.ListReleasesCmd..">"..fname) parseGithubList(fname,arch,map) + + fname = Opt.ListFile:find":" and Opt.ListFile or ThisDir..Opt.ListFile + if win.GetFileAttr(fname) then + local overlap = parseGithubList(fname,arch,map) + if not overlap then + far.Message("'github.releases' file needs to be updated!", Title, nil, "w") + end + end return map end diff --git a/Macros/scripts/far-bisect/update.github.releases.cmd b/Macros/scripts/far-bisect/update.github.releases.cmd new file mode 100644 index 00000000..044250fc --- /dev/null +++ b/Macros/scripts/far-bisect/update.github.releases.cmd @@ -0,0 +1,6 @@ +@echo off +SET GH=gh +SET max=15 +echo Recreating github.releases database... +del github.releases +for /l %%x in (1, 1, %max%) do echo %%x/%max% & %GH% api -X GET "repos/FarGroup/FarManager/releases?page=%%x&per_page=100" --jq ".[] | .name, (.assets.[].browser_download_url | select(.|test(\"7z$\") and (test(\"\\.pdb\") or test(\"ARM64\")|not)))">>github.releases From 3ee3d4feaa6d60c0119f85d7acafbde477eec47e Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Tue, 30 May 2023 12:51:31 +0200 Subject: [PATCH 07/10] far-bisect: minor improvement in cfg --- Macros/scripts/far-bisect/far-bisect.cfg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Macros/scripts/far-bisect/far-bisect.cfg b/Macros/scripts/far-bisect/far-bisect.cfg index 43ba1af4..01ffaba1 100644 --- a/Macros/scripts/far-bisect/far-bisect.cfg +++ b/Macros/scripts/far-bisect/far-bisect.cfg @@ -1,12 +1,13 @@ -- highlight: lua +local base = [[C:\Shmuel_Home\BB\F\Today\Far\Archive\Versions\]] FarArchives = { - x86 = { [[C:\Shmuel_Home\BB\F\Today\Far\Archive\Versions\1.75\x86]], - [[C:\Shmuel_Home\BB\F\Today\Far\Archive\Versions\2.0\x86]], - [[C:\Shmuel_Home\BB\F\Today\Far\Archive\Versions\3.0\x86]] }; + x86 = { base..[[1.75\x86]], + base..[[2.0\x86]], + base..[[3.0\x86]] }; - x64 = { [[C:\Shmuel_Home\BB\F\Today\Far\Archive\Versions\2.0\x64]], - [[C:\Shmuel_Home\BB\F\Today\Far\Archive\Versions\3.0\x64]] }; + x64 = { base..[[2.0\x64]], + base..[[3.0\x64]] }; } PlugArchives = [[S:\Progr\published\luaforge_github\LuaFAR\releases]] From fb966a5ff6c09067927f486abaa1769aefe69286 Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Sun, 4 Jun 2023 16:53:18 +0200 Subject: [PATCH 08/10] far-bisect: improve update.github.releases.cmd --- .../far-bisect/update.github.releases.cmd | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Macros/scripts/far-bisect/update.github.releases.cmd b/Macros/scripts/far-bisect/update.github.releases.cmd index 044250fc..175f3012 100644 --- a/Macros/scripts/far-bisect/update.github.releases.cmd +++ b/Macros/scripts/far-bisect/update.github.releases.cmd @@ -1,6 +1,20 @@ @echo off -SET GH=gh -SET max=15 -echo Recreating github.releases database... -del github.releases -for /l %%x in (1, 1, %max%) do echo %%x/%max% & %GH% api -X GET "repos/FarGroup/FarManager/releases?page=%%x&per_page=100" --jq ".[] | .name, (.assets.[].browser_download_url | select(.|test(\"7z$\") and (test(\"\\.pdb\") or test(\"ARM64\")|not)))">>github.releases +set file=github.releases +set GH=gh +set max=100 +del %file% +echo Recreating %file% database... + +setlocal enabledelayedexpansion +set lastsize=0 +for /l %%x in (1, 1, %max%) do ( + echo %%x.. + %GH% api -X GET "repos/FarGroup/FarManager/releases?page=%%x&per_page=100" --jq ".[] | .name, (.assets.[].browser_download_url | select(.|test(\"7z$\") and (test(\"\\.pdb\") or test(\"ARM64\")|not)))">>%file% + call :setsize %file% + if !size!==!lastsize! goto :eof + set lastsize=!size! +) +goto :eof + +:setsize +set size=%~z1 From c720749f100ba57830406d61a372b51191f3236c Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:25:16 +0200 Subject: [PATCH 09/10] far-bisect: fix "CD" when current disk differs from that where far installed --- Macros/scripts/far-bisect/far-bisect.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index 5ce051d9..32477f19 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -506,7 +506,7 @@ function State:Test_build(build) end end if cmdline:find("^%S") then cmdline = " "..cmdline; end - cmdline = ("cd %s && Far.exe%s"):format(install_path, cmdline) + cmdline = ("cd /D %s && Far.exe%s"):format(install_path, cmdline) -- /compose command line for Far.exe while true do panel.GetUserScreen() From 9f0d4ef48c37045b08a15f719abda5f15248c3d2 Mon Sep 17 00:00:00 2001 From: johnd0e <1838643+johnd0e@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:27:39 +0200 Subject: [PATCH 10/10] far-bisect: escape quotes in macrocode --- Macros/scripts/far-bisect/far-bisect.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Macros/scripts/far-bisect/far-bisect.lua b/Macros/scripts/far-bisect/far-bisect.lua index 32477f19..97778797 100644 --- a/Macros/scripts/far-bisect/far-bisect.lua +++ b/Macros/scripts/far-bisect/far-bisect.lua @@ -502,7 +502,7 @@ function State:Test_build(build) if self.macrocode and self.macrocode:find("%S") then if build >= 1515 then -- Mantis#0001338: Префикс в параметрах ком.строки local macrocode = (build < START_LUAPREFIX and "macro:post " or "lua:")..self.macrocode - cmdline = ('%s "%s"'):format(cmdline, macrocode) + cmdline = ('%s "%s"'):format(cmdline, macrocode:gsub('"','\\"')) end end if cmdline:find("^%S") then cmdline = " "..cmdline; end