@@ -95,6 +95,17 @@ local LUA_SCRIPT_REPO = "https://github.com/darktable-org/lua-scripts.git"
95
95
local LUA_API_VER = " API-" .. dt .configuration .api_version_string
96
96
97
97
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
+
98
109
-- - - - - - - - - - - - - - - - - - - - - - - -
99
110
-- L O G L E V E L
100
111
-- - - - - - - - - - - - - - - - - - - - - - - -
@@ -860,66 +871,69 @@ end
860
871
-- - - - - - - - - - - - - - - - - - - - - - - -
861
872
-- M A I N P R O G R A M
862
873
-- - - - - - - - - - - - - - - - - - - - - - - -
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
867
874
868
875
-- ensure shortcuts module knows widgets belong to script_manager
869
876
870
877
script_manager_running_script = " script_manager"
871
878
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
895
909
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
903
917
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 )
919
936
end
920
- end
921
- if not match then
922
- log .msg (log .warn , " no matching branch found for " .. LUA_API_VER )
923
937
end
924
938
end
925
939
end
@@ -929,7 +943,6 @@ scan_scripts(LUA_DIR)
929
943
log .msg (log .debug , " finished processing scripts" )
930
944
931
945
932
-
933
946
-- - - - - - - - - - - - - - - - - - - - - - - -
934
947
-- U S E R I N T E R F A C E
935
948
-- - - - - - - - - - - - - - - - - - - - - - - -
0 commit comments