From 53d9a42a1a59ab6d55b1b5b7c95c6b15e08288f7 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Mon, 5 Jul 2021 22:49:39 -0400 Subject: [PATCH] [script_manager] modified git interface to not rely on locale --- tools/script_manager.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/script_manager.lua b/tools/script_manager.lua index d2e2367..98f5bb8 100644 --- a/tools/script_manager.lua +++ b/tools/script_manager.lua @@ -87,7 +87,7 @@ local MIN_BUTTONS_PER_PAGE = 5 local MAX_BUTTONS_PER_PAGE = 20 local DEFAULT_BUTTONS_PER_PAGE = 10 -local DEFAULT_LOG_LEVEL = log.error +local DEFAULT_LOG_LEVEL = log.debug local LUA_DIR = dt.configuration.config_dir .. PS .. "lua" local LUA_SCRIPT_REPO = "https://github.com/darktable-org/lua-scripts.git" @@ -207,11 +207,16 @@ local function get_repo_status(repo) return nil end -local function get_current_repo_branch(repo_data) +local function get_current_repo_branch(repo) local branch = nil - branch = string.match(repo_data, "On branch (.-)\n") + local p = io.popen("cd " .. repo .. CS .. "git branch") + if p then + local data = p:read("*a") + p:close() + branch = string.match(data, "\n%* (.-)\n") + end if not branch then - log.msg(log.error, "no branch detected in repo_data\nrepo_data:\n" .. repo_data) + log.msg(log.error, "no current branch detected in repo_data") else log.msg(log.info, "\ncurrent repo branch is " .. branch) end @@ -240,12 +245,12 @@ end local function is_repo_clean(repo_data) - if string.match(repo_data, "working tree clean") then - log.msg(log.info, "repo is clean") - return true - else + if string.match(repo_data, "\n%s-%a.-%a:%s-%g-\n") then log.msg(log.info, "repo is dirty") return false + else + log.msg(log.info, "repo is clean") + return true end end @@ -848,7 +853,7 @@ 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 current_branch = get_current_repo_branch(LUA_DIR) local clean = is_repo_clean(repo_data) local repo = LUA_DIR