feat(object): render author/committer/tagger dates in human form
This commit is contained in:
+26
-1
@@ -159,6 +159,29 @@ function M.buf_for(r, rev)
|
||||
return buf
|
||||
end
|
||||
|
||||
---@param lines string[]
|
||||
local function format_header_dates(lines)
|
||||
for i, line in ipairs(lines) do
|
||||
if line == "" then
|
||||
return
|
||||
end
|
||||
local prefix, ts, tz = line:match("^(author .-) (%d+) ([+-]%d%d%d%d)$")
|
||||
if not prefix then
|
||||
prefix, ts, tz = line:match("^(committer .-) (%d+) ([+-]%d%d%d%d)$")
|
||||
end
|
||||
if not prefix then
|
||||
prefix, ts, tz = line:match("^(tagger .-) (%d+) ([+-]%d%d%d%d)$")
|
||||
end
|
||||
if prefix then
|
||||
local n = math.floor(assert(tonumber(ts)))
|
||||
lines[i] = ("%s %s"):format(
|
||||
prefix,
|
||||
util.format_git_time(n, tz --[[@as string]])
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param buf integer
|
||||
---@param r ow.Git.Repo
|
||||
---@param rev ow.Git.Revision
|
||||
@@ -189,7 +212,9 @@ local function populate(buf, r, rev, state, rev_sha)
|
||||
end
|
||||
end
|
||||
|
||||
util.set_buf_lines(buf, 0, -1, util.split_lines(stdout))
|
||||
local lines = util.split_lines(stdout)
|
||||
format_header_dates(lines)
|
||||
util.set_buf_lines(buf, 0, -1, lines)
|
||||
state.sha = rev_sha
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user