Skip to content

Commit

Permalink
[origin/main: ahead 12] 형태를 지원하기 위해 awk 구문 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
deptno committed Oct 15, 2023
1 parent c27ad96 commit 10c043d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/lab/gx/lib/get_git_branch_info.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
local get_git_branch_info = function ()
local ret = vim.fn.system([[git branch -vv | grep -e '^*' | awk '{ print $2 " -> " $4 }']]):gsub('\n', '')
local ret = vim.fn.systemlist([=[
git branch -vv | grep -e '^*' | awk '{
print $2
while (match($0, /\[[^]]+\]/)) {
print substr($0, RSTART, RLENGTH)
gsub(/\[[^]]+\]/, "", $0)
}
}']=])

local fail_prefix = 'fatal:'

if ret:sub(1, #fail_prefix) == fail_prefix then
if ret[1]:sub(1, #fail_prefix) == fail_prefix then
return nil, ret
end

return ret, 'ok'
return table.concat(ret, ' -> ')
end

return get_git_branch_info

0 comments on commit 10c043d

Please sign in to comment.