feat(object): render author/committer/tagger dates in human form
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user