Skip to content

Commit 040a83f

Browse files
authored
Merge pull request darktable-org#343 from wpferguson/sm_i18n_git_fix
script_manager: fix i18n git integration
2 parents c96c523 + 2bc23a1 commit 040a83f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tools/script_manager.lua

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,18 @@ local function get_repo_status(repo)
207207
return nil
208208
end
209209

210-
local function get_current_repo_branch(repo_data)
210+
local function get_current_repo_branch(repo)
211211
local branch = nil
212-
branch = string.match(repo_data, "On branch (.-)\n")
212+
local p = io.popen("cd " .. repo .. CS .. "git branch")
213+
if p then
214+
local data = p:read("*a")
215+
p:close()
216+
branch = string.match(data, "\n%* (.-)\n")
217+
end
213218
if not branch then
214-
log.msg(log.error, "no branch detected in repo_data\nrepo_data:\n" .. repo_data)
219+
log.msg(log.error, "no current branch detected in repo_data")
215220
else
216-
log.msg(log.info, "\ncurrent repo branch is " .. branch)
221+
log.msg(log.info, "current repo branch is " .. branch)
217222
end
218223
return branch
219224
end
@@ -240,12 +245,12 @@ end
240245

241246

242247
local function is_repo_clean(repo_data)
243-
if string.match(repo_data, "working tree clean") then
244-
log.msg(log.info, "repo is clean")
245-
return true
246-
else
248+
if string.match(repo_data, "\n%s-%a.-%a:%s-%a%g-\n") then
247249
log.msg(log.info, "repo is dirty")
248250
return false
251+
else
252+
log.msg(log.info, "repo is clean")
253+
return true
249254
end
250255
end
251256

@@ -848,7 +853,7 @@ end
848853
-- M A I N P R O G R A M
849854
-- - - - - - - - - - - - - - - - - - - - - - - -
850855
local repo_data = get_repo_status(LUA_DIR)
851-
local current_branch = get_current_repo_branch(repo_data)
856+
local current_branch = get_current_repo_branch(LUA_DIR)
852857
local clean = is_repo_clean(repo_data)
853858
local repo = LUA_DIR
854859

0 commit comments

Comments
 (0)