Match git commit properly

This commit is contained in:
Krzosa Karol
2024-08-08 08:14:08 +02:00
parent bfff188726
commit 58db05fcb3
2 changed files with 14 additions and 5 deletions

View File

@@ -313,8 +313,13 @@ function MatchAgainstIncludes(s)
end
function MatchGitCommit(s)
local command = "git --no-pager show "..s
return {kind = "exec", cmd = command, working_dir = GetCurrentBufferDir()}
local i, j = string.find(s, "^commit ([a-zA-Z0-9]+)")
if i then
s = s:sub(8)
local command = "git --no-pager show "..s
return {kind = "exec", cmd = command, working_dir = GetCurrentBufferDir()}
end
return nil
end
Rules = {
@@ -323,7 +328,6 @@ Rules = {
MatchGitCommit,
}
function ApplyRules(s)
for i = #Rules,1,-1 do
rule = Rules[i]

View File

@@ -205,8 +205,13 @@ function MatchAgainstIncludes(s)
end
function MatchGitCommit(s)
local command = "git --no-pager show "..s
return {kind = "exec", cmd = command, working_dir = GetCurrentBufferDir()}
local i, j = string.find(s, "^commit ")
print(tostring(i))
if i then
local command = "git --no-pager show "..s
return {kind = "exec", cmd = command, working_dir = GetCurrentBufferDir()}
end
return nil
end
Rules = {