From 832a9b11b9e3dd46547abc6f9719b47d8ed9f490 Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Tue, 9 Sep 2025 20:01:01 +0200 Subject: [PATCH] feat: lineBlame output parsing done --- README.md | 1 + lua/line-blame.lua | 25 ++++++++++++++++++------- lua/monkey-alert.lua | 5 +++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a169ee8..b695da8 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ ## WIP + diff --git a/lua/line-blame.lua b/lua/line-blame.lua index 96806e1..8790570 100644 --- a/lua/line-blame.lua +++ b/lua/line-blame.lua @@ -1,12 +1,23 @@ -local lineBlame = function() - // TODO: everything - local mail_blame = os.execute("git blame -e .githooks/pre-commit") - local mail_blame_awk = os.execute("git blame -e .githooks/pre-commit | awk '{ print $2 $6}'"); - local test_str = "24a332e7 ( 2025-09-08 19:42:51 +0200 39) email=$(git config user.email)" - local results = test_str:match(".*<(.*)>.* ([0-9]+)\)") - local results = test_str:match(".*<(.*)>.* ([0-9]+)\)") +local lineBlame = function(input_file_path, comma_separated_mails) + local handler = io.popen("git blame -e " .. input_file_path .. " | awk '{ print $2$6}'") + + if handler == nil then + return nil + end + + local result = handler:read("L") + while result do + for k, v in string.gmatch(result, "%(<(.+)>(%d+)%)") do + print(k) + print(v) + end + result = handler:read("L") + end + handler:close() end +-- lineBlame("./README.md") + return { lineBlame = lineBlame, } diff --git a/lua/monkey-alert.lua b/lua/monkey-alert.lua index 10dd1c9..39e1c25 100644 --- a/lua/monkey-alert.lua +++ b/lua/monkey-alert.lua @@ -2,11 +2,11 @@ local blame = require("./line-blame.lua") local defaultList = "one;two" vim.g.monkeyMailList = defaultList -vim.g.monkeyUserList = defaultList +-- vim.g.monkeyUserList = defaultList local function setup(opts) vim.g.monkeyMailList = opts.monkeyMailList - vim.g.monkeyUserList = opts.monkeyUserList + -- vim.g.monkeyUserList = opts.monkeyUserList end local function observe() @@ -16,6 +16,7 @@ end return { setup = setup, observe = observe, + blame = blame.lineBlame } -- NOTE: