@@ -207,13 +207,18 @@ local function get_repo_status(repo)
207
207
return nil
208
208
end
209
209
210
- local function get_current_repo_branch (repo_data )
210
+ local function get_current_repo_branch (repo )
211
211
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
213
218
if not branch then
214
- log .msg (log .error , " no branch detected in repo_data\n repo_data: \n " .. repo_data )
219
+ log .msg (log .error , " no current branch detected in repo_data" )
215
220
else
216
- log .msg (log .info , " \n current repo branch is " .. branch )
221
+ log .msg (log .info , " current repo branch is " .. branch )
217
222
end
218
223
return branch
219
224
end
@@ -240,12 +245,12 @@ end
240
245
241
246
242
247
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
247
249
log .msg (log .info , " repo is dirty" )
248
250
return false
251
+ else
252
+ log .msg (log .info , " repo is clean" )
253
+ return true
249
254
end
250
255
end
251
256
848
853
-- M A I N P R O G R A M
849
854
-- - - - - - - - - - - - - - - - - - - - - - - -
850
855
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 )
852
857
local clean = is_repo_clean (repo_data )
853
858
local repo = LUA_DIR
854
859
0 commit comments