feat(object): render author/committer/tagger dates in human form

This commit is contained in:
2026-05-26 23:47:13 +02:00
parent 22309fe8fd
commit 182e507dc7
5 changed files with 85 additions and 19 deletions
+2 -2
View File
@@ -86,9 +86,9 @@ t.test("line popup formats the datetime in the author timezone", function()
)
t.truthy(
(lines[1] or ""):match(
"%d%d%d%d%-%d%d%-%d%d %d%d:%d%d:%d%d [+%-]%d%d%d%d$"
"%u%l%l %u%l%l +%d+ %d%d:%d%d:%d%d %d%d%d%d [+%-]%d%d%d%d$"
),
"the head line ends with an ISO datetime and numeric timezone"
"the head line ends with a human datetime and numeric timezone"
)
end)
+39
View File
@@ -134,6 +134,45 @@ t.test("read_uri opens stage-0 entry as a writable index buffer", function()
t.eq(vim.api.nvim_buf_get_lines(buf, 0, -1, false), { "first" })
end)
t.test("M.open renders author/committer dates, not unix timestamps", function()
local dir = h.make_repo({ a = "first\n" })
local r = assert(require("git.core.repo").resolve(dir))
object.open(r, "HEAD", { split = false })
local author = assert(find_line(0, "author "), "expected an author line")
local committer =
assert(find_line(0, "committer "), "expected a committer line")
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
for _, lnum in ipairs({ author, committer }) do
local line = assert(lines[lnum])
t.truthy(
line:match(
" %u%l%l %u%l%l +%d+ %d%d:%d%d:%d%d %d%d%d%d [+-]%d%d%d%d$"
),
"expected formatted date on: " .. line
)
t.falsy(
line:match(" %d%d%d%d%d%d%d%d%d%d? [+-]%d%d%d%d$"),
"expected no unix timestamp on: " .. line
)
end
end)
t.test("M.open renders tagger dates on annotated tags", function()
local dir = h.make_repo({ a = "first\n" })
h.git(dir, "tag", "-m", "rel", "v1")
local r = assert(require("git.core.repo").resolve(dir))
object.open(r, "v1", { split = false })
local tagger = assert(find_line(0, "tagger "), "expected a tagger line")
local line =
assert(vim.api.nvim_buf_get_lines(0, tagger - 1, tagger, false)[1])
t.truthy(
line:match(" %u%l%l %u%l%l +%d+ %d%d:%d%d:%d%d %d%d%d%d [+-]%d%d%d%d$"),
"expected formatted date on: " .. line
)
end)
t.test("open_under_cursor on a 'tree <sha>' line opens the tree", function()
local dir = h.make_repo({ a = "first\n" })
local r = assert(require("git.core.repo").resolve(dir))