Skip to content

Commit 6af180a

Browse files
committed
[script_manager] after numerous attempts to solve this with just pattern
matching I realized the lack of conditionals made it impossible to solve in that manner, so I resorted to splitting the output into lines and testing each line.
1 parent 040a83f commit 6af180a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tools/script_manager.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ local MIN_BUTTONS_PER_PAGE = 5
8787
local MAX_BUTTONS_PER_PAGE = 20
8888
local DEFAULT_BUTTONS_PER_PAGE = 10
8989

90-
local DEFAULT_LOG_LEVEL = log.error
90+
local DEFAULT_LOG_LEVEL = log.debug
9191

9292
local LUA_DIR = dt.configuration.config_dir .. PS .. "lua"
9393
local LUA_SCRIPT_REPO = "https://github.com/darktable-org/lua-scripts.git"
@@ -213,14 +213,20 @@ local function get_current_repo_branch(repo)
213213
if p then
214214
local data = p:read("*a")
215215
p:close()
216-
branch = string.match(data, "\n%* (.-)\n")
216+
local branches = du.split(data, "\n")
217+
for _, b in ipairs(branches) do
218+
log.msg(log.debug, "branch for testing is " .. b)
219+
branch = string.match(b, "^%* (.-)$")
220+
if branch then
221+
log.msg(log.info, "current repo branch is " .. branch)
222+
return branch
223+
end
224+
end
217225
end
218226
if not branch then
219227
log.msg(log.error, "no current branch detected in repo_data")
220-
else
221-
log.msg(log.info, "current repo branch is " .. branch)
222228
end
223-
return branch
229+
return nil
224230
end
225231

226232
local function get_repo_branches(repo)

0 commit comments

Comments
 (0)