[script_manager] modified git interface to not rely on locale

This commit is contained in:
Bill Ferguson
2021-07-05 22:49:39 -04:00
parent 9a3eb7bc3e
commit 53d9a42a1a

View File

@@ -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