Skip to content

Commit 8f6c2c8

Browse files
authored
Merge pull request darktable-org#345 from wpferguson/sm_git_branch_pattern_matching
Solution to pattern matching current git directory
2 parents 86cc22d + a6d5001 commit 8f6c2c8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tools/script_manager.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)