Skip to content

Commit 21d7e72

Browse files
committed
tools/script_manager - resolved conflicts
1 parent 05d555e commit 21d7e72

File tree

1 file changed

+66
-53
lines changed

1 file changed

+66
-53
lines changed

tools/script_manager.lua

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ local LUA_SCRIPT_REPO = "https://github.com/darktable-org/lua-scripts.git"
9595
local LUA_API_VER = "API-" .. dt.configuration.api_version_string
9696

9797

98+
-- - - - - - - - - - - - - - - - - - - - - - - -
99+
-- P R E F E R E N C E S
100+
-- - - - - - - - - - - - - - - - - - - - - - - -
101+
102+
dt.preferences.register(MODULE, "check_update", "bool",
103+
"check for updated scripts on start up",
104+
"automatically update scripts to correct version",
105+
true)
106+
107+
local check_for_updates = dt.preferences.read(MODULE, "check_update", "bool")
108+
98109
-- - - - - - - - - - - - - - - - - - - - - - - -
99110
-- L O G L E V E L
100111
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -860,66 +871,69 @@ end
860871
-- - - - - - - - - - - - - - - - - - - - - - - -
861872
-- M A I N P R O G R A M
862873
-- - - - - - - - - - - - - - - - - - - - - - - -
863-
local repo_data = get_repo_status(LUA_DIR)
864-
local current_branch = get_current_repo_branch(LUA_DIR)
865-
local clean = is_repo_clean(repo_data)
866-
local repo = LUA_DIR
867874

868875
-- ensure shortcuts module knows widgets belong to script_manager
869876

870877
script_manager_running_script = "script_manager"
871878

872-
if current_branch then
873-
if sm.executables.git and clean and
874-
(current_branch == "master" or string.match(current_branch, "^API%-")) then -- only make changes to clean branches
875-
local branches = get_repo_branches(LUA_DIR)
876-
if current_branch ~= LUA_API_VER and current_branch ~= "master" then
877-
-- probably upgraded from an earlier api version so get back to master
878-
-- to use the latest version of script_manager to get the proper API
879-
checkout_repo_branch(repo, "master")
880-
log.msg(log.screen, "lua API version reset, please restart darktable")
881-
elseif LUA_API_VER == current_branch then
882-
-- do nothing, we are fine
883-
log.msg(log.debug, "took equal branch, doing nothing")
884-
elseif string.match(LUA_API_VER, "dev") then
885-
-- we are on a dev API version, so checkout the dev
886-
-- api version or checkout/stay on master
887-
log.msg(log.debug, "took the dev branch")
888-
local match = false
889-
for _, branch in ipairs(branches) do
890-
log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER)
891-
if LUA_API_VER == branch then
892-
match = true
893-
log.msg(log.info, "checking out repo development branch " .. branch)
894-
checkout_repo_branch(repo, branch)
879+
if check_for_updates then
880+
local repo_data = get_repo_status(LUA_DIR)
881+
local current_branch = get_current_repo_branch(LUA_DIR)
882+
local clean = is_repo_clean(repo_data)
883+
local repo = LUA_DIR
884+
885+
if current_branch then
886+
if sm.executables.git and clean and
887+
(current_branch == "master" or string.match(current_branch, "^API%-")) then -- only make changes to clean branches
888+
local branches = get_repo_branches(LUA_DIR)
889+
if current_branch ~= LUA_API_VER and current_branch ~= "master" then
890+
-- probably upgraded from an earlier api version so get back to master
891+
-- to use the latest version of script_manager to get the proper API
892+
checkout_repo_branch(repo, "master")
893+
log.msg(log.screen, "lua API version reset, please restart darktable")
894+
elseif LUA_API_VER == current_branch then
895+
-- do nothing, we are fine
896+
log.msg(log.debug, "took equal branch, doing nothing")
897+
elseif string.match(LUA_API_VER, "dev") then
898+
-- we are on a dev API version, so checkout the dev
899+
-- api version or checkout/stay on master
900+
log.msg(log.debug, "took the dev branch")
901+
local match = false
902+
for _, branch in ipairs(branches) do
903+
log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER)
904+
if LUA_API_VER == branch then
905+
match = true
906+
log.msg(log.info, "checking out repo development branch " .. branch)
907+
checkout_repo_branch(repo, branch)
908+
end
895909
end
896-
end
897-
if not match then
898-
if current_branch == "master" then
899-
log.msg(log.info, "staying on master, no dev branch yet")
900-
else
901-
log.msg(log.info, "no dev branch available, checking out master")
902-
checkout_repo_branch(repo, "master")
910+
if not match then
911+
if current_branch == "master" then
912+
log.msg(log.info, "staying on master, no dev branch yet")
913+
else
914+
log.msg(log.info, "no dev branch available, checking out master")
915+
checkout_repo_branch(repo, "master")
916+
end
903917
end
904-
end
905-
elseif #branches > 0 and LUA_API_VER > branches[#branches] then
906-
log.msg(log.info, "no newer branches, staying on master")
907-
-- stay on master
908-
else
909-
-- checkout the appropriate branch for API version if it exists
910-
log.msg(log.info, "checking out the appropriate API branch")
911-
local match = false
912-
for _, branch in ipairs(branches) do
913-
log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER)
914-
if LUA_API_VER == branch then
915-
match = true
916-
log.msg(log.info, "checking out repo branch " .. branch)
917-
checkout_repo_branch(repo, branch)
918-
log.msg(log.screen, "you must restart darktable to use the correct version of the lua")
918+
elseif #branches > 0 and LUA_API_VER > branches[#branches] then
919+
log.msg(log.info, "no newer branches, staying on master")
920+
-- stay on master
921+
else
922+
-- checkout the appropriate branch for API version if it exists
923+
log.msg(log.info, "checking out the appropriate API branch")
924+
local match = false
925+
for _, branch in ipairs(branches) do
926+
log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER)
927+
if LUA_API_VER == branch then
928+
match = true
929+
log.msg(log.info, "checking out repo branch " .. branch)
930+
checkout_repo_branch(repo, branch)
931+
log.msg(log.screen, "you must restart darktable to use the correct version of the lua")
932+
end
933+
end
934+
if not match then
935+
log.msg(log.warn, "no matching branch found for " .. LUA_API_VER)
919936
end
920-
end
921-
if not match then
922-
log.msg(log.warn, "no matching branch found for " .. LUA_API_VER)
923937
end
924938
end
925939
end
@@ -929,7 +943,6 @@ scan_scripts(LUA_DIR)
929943
log.msg(log.debug, "finished processing scripts")
930944

931945

932-
933946
-- - - - - - - - - - - - - - - - - - - - - - - -
934947
-- U S E R I N T E R F A C E
935948
-- - - - - - - - - - - - - - - - - - - - - - - -

0 commit comments

Comments
 (0)