fix(git): rename log_win to log
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
local git = require("git")
|
||||
local log = require("log")
|
||||
local repo = require("git.repo")
|
||||
local util = require("util")
|
||||
|
||||
local M = {}
|
||||
|
||||
local LOG_FORMAT = "%h %ad {%an}%d %s"
|
||||
|
||||
function M.show()
|
||||
local _, worktree = repo.resolve_cwd()
|
||||
if not worktree then
|
||||
log.warning("not in a git repository")
|
||||
return
|
||||
end
|
||||
|
||||
local buf = git.new_scratch()
|
||||
vim.b[buf].git_worktree = worktree
|
||||
|
||||
vim.system(
|
||||
{
|
||||
"git",
|
||||
"log",
|
||||
"--graph",
|
||||
"--all",
|
||||
"--decorate",
|
||||
"--date=short",
|
||||
"--format=format:" .. LOG_FORMAT,
|
||||
},
|
||||
{ cwd = worktree, text = true },
|
||||
vim.schedule_wrap(function(result)
|
||||
if not vim.api.nvim_buf_is_valid(buf) then
|
||||
return
|
||||
end
|
||||
if result.code ~= 0 then
|
||||
log.error("git log failed: %s", vim.trim(result.stderr or ""))
|
||||
return
|
||||
end
|
||||
local lines = util.split_lines(result.stdout or "")
|
||||
vim.bo[buf].modifiable = true
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
|
||||
vim.bo[buf].modifiable = false
|
||||
vim.bo[buf].modified = false
|
||||
vim.bo[buf].filetype = "gitlog"
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user