[script_manager] Added API awareness so that the correct version of

scripts that match the API version of darktable are
                 used.

[Changelog.md]   Updated the change log with the latest changes.
This commit is contained in:
Bill Ferguson
2021-07-01 21:45:38 -04:00
parent 5da64a7da0
commit 56ec258cc7
2 changed files with 145 additions and 6 deletions

View File

@@ -1,21 +1,41 @@
## Changes from most recent to oldest
**02 Jul 2021 - wpferguson - merged API-7.0.0-dev branch to master
* API-7.0.0 is darktable 3.6
* breaking changes
* register_event argments changed
* register_action arguments changed
* register_selection arguments changed
* register_event arguments changed
* scripts updated to API-7.0.0 compatibility
* script_manger updated to be API aware and check out the proper branch
based on darktable API version
** 19 Jun 2021 - wpferguson - fix issue 312, image_path_in_ui**
**01 Jul 2021 - wpferguson - created branch for API-6.1.0 - darktable 3.4
** 02 Jun 2021 - wpferguson - fix contrib/quicktag**
**20 Jun 2021 - wpferguson - created branches for older API versions
* API-6.0.0 - darktable 3.2.1
* API-5.0.2 - darktable 3.0
* API-5.0.1 - darktable 2.6.1
* API-5.0.0 - darktable 2.4
* API-4.0.0 - darktable 2.2
* API-3.0.0 - darktable 2.0
**19 Jun 2021 - wpferguson - fix issue 312, image_path_in_ui**
**02 Jun 2021 - wpferguson - fix contrib/quicktag**
* set new entry field is_password to false so entry
is visible to user while typing.
** 19 Mar 2021 - wpferguson - fixed crash in contrib/HDRmerge.lua**
**19 Mar 2021 - wpferguson - fixed crash in contrib/HDRmerge.lua**
* Made generated filename routine gracefully handle names that
are not in the expected format.
** 15 Mar 2021 - scheckmedia - updated contrib/photils.lua**
**15 Mar 2021 - scheckmedia - updated contrib/photils.lua**
* refactor print method
* add option to apply selected tags from a single image to multiple images
* add setting parameter to enable/disable the export of an image before tag suggestion
** 25 Feb 2021 - wpferguson - added detached mode to contrib/gimp.lua**
**25 Feb 2021 - wpferguson - added detached mode to contrib/gimp.lua**
* Added run_detached checkbox to the exporter GUI. Selecting run_detached
let's GIMP keep running and accepting additional images. It does not return

View File

@@ -92,6 +92,8 @@ local DEFAULT_LOG_LEVEL = log.error
local LUA_DIR = dt.configuration.config_dir .. PS .. "lua"
local LUA_SCRIPT_REPO = "https://github.com/darktable-org/lua-scripts.git"
local LUA_API_VER = "API-" .. dt.configuration.api_version_string
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
@@ -99,7 +101,7 @@ local LUA_SCRIPT_REPO = "https://github.com/darktable-org/lua-scripts.git"
local old_log_level = log.log_level()
log.log_level(log.debug)
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
@@ -192,6 +194,62 @@ local function pref_write(name, pref_type, value)
dt.preferences.write(MODULE, name, pref_type, value)
end
-- git interface
local function get_repo_status(repo)
local p = io.popen("cd " .. repo .. CS .. "git status")
if p then
local data = p:read("*a")
p:close()
return data
end
dt.print_error("unable to get status of " .. repo)
return nil
end
local function get_current_repo_branch(repo_data)
local branch = nil
branch = string.match(repo_data, "On branch (.-)\n")
dt.print_log("\ncurrent rep branch is " .. branch)
return branch
end
local function get_repo_branches(repo)
local branches = {}
local p = io.popen("cd " .. repo .. CS .. "git pull --all" .. CS .. "git branch --all")
if p then
local data = p:read("*a")
p:close()
dt.print_log("data is \n" .. data)
local branch_data = du.split(data, "\n")
for _, line in ipairs(branch_data) do
dt.print_log("line is " .. line)
local branch = string.gsub(line, "%s+remotes/%a+/", "")
if string.match(branch, "API") then
dt.print_log("found branch - " .. branch)
table.insert(branches, branch)
end
end
end
return branches
end
local function is_repo_clean(repo_data)
if string.match(repo_data, "working tree clean") then
dt.print_log("repo is clean")
return true
else
dt.print_log("repo is dirty")
return false
end
end
local function checkout_repo_branch(repo, branch)
dt.print_log("checkout out branch " .. branch .. " from repository " .. repo)
os.execute("cd " .. repo .. CS .. "git checkout " .. branch)
end
local function update_combobox_choices(combobox, choice_table, selected)
local items = #combobox
local choices = #choice_table
@@ -785,9 +843,70 @@ end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N P R O G R A M
-- - - - - - - - - - - - - - - - - - - - - - - -
local repo_data = get_repo_status(LUA_DIR)
local current_branch = get_current_repo_branch(repo_data)
local clean = is_repo_clean(repo_data)
local repo = LUA_DIR
if sm.executables.git and clean and
(current_branch == "master" or string.match(current_branch, "^API%-")) then -- only make changes to clean branches
local branches = get_repo_branches(LUA_DIR)
if current_branch ~= LUA_API_VER and current_branch ~= "master" then
-- probably upgraded from an earlier api version so get back to master
-- to use the latest version of script_manager to get the proper API
checkout_repo_branch(repo, "master")
log.msg(log.screen, "lua API version reset, please restart darktable")
elseif LUA_API_VER == current_branch then
-- do nothing, we are fine
log.msg(log.debug, "took equal branch, doing nothing")
elseif string.match(LUA_API_VER, "dev") then
-- we are on a dev API version, so checkout the dev
-- api version or checkout/stay on master
log.msg(log.debug, "took the dev branch")
local match = false
for _, branch in ipairs(branches) do
log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER)
if LUA_API_VER == branch then
match = true
log.msg(log.info, "checking out repo development branch " .. branch)
checkout_repo_branch(repo, branch)
end
end
if not match then
if current_branch == "master" then
log.msg(log.info, "staying on master, no dev branch yet")
else
log.msg(log.info, "no dev branch available, checking out master")
checkout_repo_branch(repo, "master")
end
end
elseif LUA_API_VER > branches[#branches] then
log.msg(log.info, "no newer branches, staying on master")
-- stay on master
else
-- checkout the appropriate branch for API version if it exists
log.msg(log.info, "checking out the appropriate API branch")
local match = false
for _, branch in ipairs(branches) do
log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER)
if LUA_API_VER == branch then
match = true
log.msg(log.info, "checking out repo branch " .. branch)
checkout_repo_branch(repo, branch)
log.msg(log.screen, "you must restart darktable to use the correct version of the lua")
end
end
if not match then
log.msg(log.warn, "no matching branch found for " .. LUA_API_VER)
end
end
end
scan_scripts(LUA_DIR)
log.msg(log.debug, "finished processing scripts")
-- - - - - - - - - - - - - - - - - - - - - - - -
-- U S E R I N T E R F A C E
-- - - - - - - - - - - - - - - - - - - - - - - -