Skip to content

Commit 7d7902d

Browse files
committed
Add path_spec support
1 parent 0c1999f commit 7d7902d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

scripts/gitinfo-lua-cmd.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function api.trim(s)
3838
return (s:gsub("^%s*(.-)%s*$", "%1"))
3939
end
4040

41-
function api:exec(command, do_caching, target_dir, no_recording)
41+
function api:exec(command, do_caching, target_dir, no_recording, path_spec)
4242
local cwd = target_dir or self.cwd
4343
local cmd = self.executable
4444
if cwd then
@@ -48,6 +48,16 @@ function api:exec(command, do_caching, target_dir, no_recording)
4848
if not no_recording then
4949
api.recorder.record_head(cwd)
5050
end
51+
if path_spec then
52+
if type(path_spec) == 'table' then
53+
cmd = cmd .. ' --'
54+
for _,path in ipairs(path_spec) do
55+
cmd = cmd .. ' ' .. path
56+
end
57+
elseif type(path_spec) == 'string' then
58+
cmd = cmd .. ' -- ' .. path_spec
59+
end
60+
end
5161
if do_caching then
5262
local found, result = cache:seek(cmd)
5363
if found then
@@ -145,7 +155,7 @@ function api:parse_response(buffer)
145155
return results
146156
end
147157

148-
function api:log(format_spec, revision, options, target_dir)
158+
function api:log(format_spec, revision, options, target_dir, path_spec)
149159
local format, err = self:parse_format_spec(format_spec)
150160
if err then
151161
return nil, err
@@ -158,7 +168,7 @@ function api:log(format_spec, revision, options, target_dir)
158168
if revision and revision ~= '' then
159169
cmd = cmd .. ' ' .. revision
160170
end
161-
local response, err = self:exec(cmd, true, target_dir)
171+
local response, err = self:exec(cmd, true, target_dir, false, path_spec)
162172
if not response then
163173
return nil, err
164174
end

0 commit comments

Comments
 (0)