|
209 | 209 |
|
210 | 210 | local function get_current_repo_branch(repo)
|
211 | 211 | local branch = nil
|
212 |
| - local p = io.popen("cd " .. repo .. CS .. "git branch") |
| 212 | + local p = io.popen("cd " .. repo .. CS .. "git branch --all") |
213 | 213 | if p then
|
214 | 214 | local data = p:read("*a")
|
215 | 215 | p:close()
|
@@ -857,56 +857,58 @@ local current_branch = get_current_repo_branch(LUA_DIR)
|
857 | 857 | local clean = is_repo_clean(repo_data)
|
858 | 858 | local repo = LUA_DIR
|
859 | 859 |
|
860 |
| -if sm.executables.git and clean and |
861 |
| - (current_branch == "master" or string.match(current_branch, "^API%-")) then -- only make changes to clean branches |
862 |
| - local branches = get_repo_branches(LUA_DIR) |
863 |
| - if current_branch ~= LUA_API_VER and current_branch ~= "master" then |
864 |
| - -- probably upgraded from an earlier api version so get back to master |
865 |
| - -- to use the latest version of script_manager to get the proper API |
866 |
| - checkout_repo_branch(repo, "master") |
867 |
| - log.msg(log.screen, "lua API version reset, please restart darktable") |
868 |
| - elseif LUA_API_VER == current_branch then |
869 |
| - -- do nothing, we are fine |
870 |
| - log.msg(log.debug, "took equal branch, doing nothing") |
871 |
| - elseif string.match(LUA_API_VER, "dev") then |
872 |
| - -- we are on a dev API version, so checkout the dev |
873 |
| - -- api version or checkout/stay on master |
874 |
| - log.msg(log.debug, "took the dev branch") |
875 |
| - local match = false |
876 |
| - for _, branch in ipairs(branches) do |
877 |
| - log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER) |
878 |
| - if LUA_API_VER == branch then |
879 |
| - match = true |
880 |
| - log.msg(log.info, "checking out repo development branch " .. branch) |
881 |
| - checkout_repo_branch(repo, branch) |
| 860 | +if current_branch then |
| 861 | + if sm.executables.git and clean and |
| 862 | + (current_branch == "master" or string.match(current_branch, "^API%-")) then -- only make changes to clean branches |
| 863 | + local branches = get_repo_branches(LUA_DIR) |
| 864 | + if current_branch ~= LUA_API_VER and current_branch ~= "master" then |
| 865 | + -- probably upgraded from an earlier api version so get back to master |
| 866 | + -- to use the latest version of script_manager to get the proper API |
| 867 | + checkout_repo_branch(repo, "master") |
| 868 | + log.msg(log.screen, "lua API version reset, please restart darktable") |
| 869 | + elseif LUA_API_VER == current_branch then |
| 870 | + -- do nothing, we are fine |
| 871 | + log.msg(log.debug, "took equal branch, doing nothing") |
| 872 | + elseif string.match(LUA_API_VER, "dev") then |
| 873 | + -- we are on a dev API version, so checkout the dev |
| 874 | + -- api version or checkout/stay on master |
| 875 | + log.msg(log.debug, "took the dev branch") |
| 876 | + local match = false |
| 877 | + for _, branch in ipairs(branches) do |
| 878 | + log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER) |
| 879 | + if LUA_API_VER == branch then |
| 880 | + match = true |
| 881 | + log.msg(log.info, "checking out repo development branch " .. branch) |
| 882 | + checkout_repo_branch(repo, branch) |
| 883 | + end |
882 | 884 | end
|
883 |
| - end |
884 |
| - if not match then |
885 |
| - if current_branch == "master" then |
886 |
| - log.msg(log.info, "staying on master, no dev branch yet") |
887 |
| - else |
888 |
| - log.msg(log.info, "no dev branch available, checking out master") |
889 |
| - checkout_repo_branch(repo, "master") |
| 885 | + if not match then |
| 886 | + if current_branch == "master" then |
| 887 | + log.msg(log.info, "staying on master, no dev branch yet") |
| 888 | + else |
| 889 | + log.msg(log.info, "no dev branch available, checking out master") |
| 890 | + checkout_repo_branch(repo, "master") |
| 891 | + end |
890 | 892 | end
|
891 |
| - end |
892 |
| - elseif #branches > 0 and LUA_API_VER > branches[#branches] then |
893 |
| - log.msg(log.info, "no newer branches, staying on master") |
894 |
| - -- stay on master |
895 |
| - else |
896 |
| - -- checkout the appropriate branch for API version if it exists |
897 |
| - log.msg(log.info, "checking out the appropriate API branch") |
898 |
| - local match = false |
899 |
| - for _, branch in ipairs(branches) do |
900 |
| - log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER) |
901 |
| - if LUA_API_VER == branch then |
902 |
| - match = true |
903 |
| - log.msg(log.info, "checking out repo branch " .. branch) |
904 |
| - checkout_repo_branch(repo, branch) |
905 |
| - log.msg(log.screen, "you must restart darktable to use the correct version of the lua") |
| 893 | + elseif #branches > 0 and LUA_API_VER > branches[#branches] then |
| 894 | + log.msg(log.info, "no newer branches, staying on master") |
| 895 | + -- stay on master |
| 896 | + else |
| 897 | + -- checkout the appropriate branch for API version if it exists |
| 898 | + log.msg(log.info, "checking out the appropriate API branch") |
| 899 | + local match = false |
| 900 | + for _, branch in ipairs(branches) do |
| 901 | + log.msg(log.debug, "checking branch " .. branch .. " against API " .. LUA_API_VER) |
| 902 | + if LUA_API_VER == branch then |
| 903 | + match = true |
| 904 | + log.msg(log.info, "checking out repo branch " .. branch) |
| 905 | + checkout_repo_branch(repo, branch) |
| 906 | + log.msg(log.screen, "you must restart darktable to use the correct version of the lua") |
| 907 | + end |
| 908 | + end |
| 909 | + if not match then |
| 910 | + log.msg(log.warn, "no matching branch found for " .. LUA_API_VER) |
906 | 911 | end
|
907 |
| - end |
908 |
| - if not match then |
909 |
| - log.msg(log.warn, "no matching branch found for " .. LUA_API_VER) |
910 | 912 | end
|
911 | 913 | end
|
912 | 914 | end
|
|
0 commit comments