diff --git a/lua/git/cmd.lua b/lua/git/cmd.lua index 9dee8ac..e803b0b 100644 --- a/lua/git/cmd.lua +++ b/lua/git/cmd.lua @@ -1,5 +1,4 @@ local commit = require("git.commit") -local history = require("git.history") local object = require("git.object") local repo = require("git.repo") local util = require("git.util") @@ -386,13 +385,11 @@ local function run_streaming(r, args) last_progress ~= "" and last_progress or "done", "success" ) - history.append(args, accum) else emit_progress(("exit %d"):format(code), "failed") local body = #accum > 0 and table.concat(accum, "\n") or ("%s failed: exit %d"):format(title, code) vim.api.nvim_echo({ { body, "ErrorMsg" } }, true, {}) - history.append(args, accum) end end diff --git a/lua/git/history.lua b/lua/git/history.lua deleted file mode 100644 index 4eb9968..0000000 --- a/lua/git/history.lua +++ /dev/null @@ -1,58 +0,0 @@ -local util = require("git.util") - -local M = {} - -local BUF_NAME = "githistory://log" - ----@type integer? -local cached_buf - ----@return integer -local function get_buf() - if cached_buf and vim.api.nvim_buf_is_valid(cached_buf) then - return cached_buf - end - local buf = vim.api.nvim_create_buf(false, true) - pcall(vim.api.nvim_buf_set_name, buf, BUF_NAME) - util.setup_scratch(buf, { bufhidden = "hide" }) - cached_buf = buf - return buf -end - ----@param args string[] ----@param lines string[] -function M.append(args, lines) - if #lines == 0 then - return - end - local buf = get_buf() - local count = vim.api.nvim_buf_line_count(buf) - local first = vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1] or "" - local empty = count == 1 and first == "" - local payload = { "$ git " .. table.concat(args, " ") } - vim.list_extend(payload, lines) - vim.bo[buf].modifiable = true - if empty then - vim.api.nvim_buf_set_lines(buf, 0, -1, false, payload) - else - table.insert(payload, 1, "") - vim.api.nvim_buf_set_lines(buf, count, count, false, payload) - end - vim.bo[buf].modifiable = false - vim.bo[buf].modified = false -end - -function M.open() - local buf = get_buf() - local win = vim.fn.bufwinid(buf) - if win ~= -1 then - vim.api.nvim_set_current_win(win) - else - util.place_buf(buf, nil) - win = vim.api.nvim_get_current_win() - end - local last = vim.api.nvim_buf_line_count(buf) - vim.api.nvim_win_set_cursor(win, { last, 0 }) -end - -return M diff --git a/lua/git/init.lua b/lua/git/init.lua index e0ff458..49a6a07 100644 --- a/lua/git/init.lua +++ b/lua/git/init.lua @@ -151,10 +151,6 @@ function M.init() require("git.repo").refresh_all() end, { desc = "Refresh git status for all repos" }) - vim.api.nvim_create_user_command("Ghistory", function() - require("git.history").open() - end, { desc = "Open the git streaming output history" }) - vim.api.nvim_create_user_command("Gstatus", function(opts) require("git.status_view").open({ placement = opts.fargs[1] --[[@as ow.Git.StatusView.Placement]] or "split", diff --git a/test/git/cmd_test.lua b/test/git/cmd_test.lua index 10ca765..b83c8d0 100644 --- a/test/git/cmd_test.lua +++ b/test/git/cmd_test.lua @@ -610,30 +610,6 @@ t.test( end ) -t.test("streaming output buffer collects runs (failure path)", function() - make_repo({ a = "x" }) - with_echo_stub(function(calls) - cmd.run({ "fetch", "nonexistent" }) - t.wait_for(function() - return has_status(calls, "failed") - end, "failed progress notification", 5000) - end) - require("git.history").open() - local buf = vim.api.nvim_get_current_buf() - local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) - local found_header, found_fatal = false, false - for _, l in ipairs(lines) do - if l:match("^%$ git fetch nonexistent$") then - found_header = true - end - if l:match("fatal:") then - found_fatal = true - end - end - t.truthy(found_header, "expected '$ git fetch nonexistent' header") - t.truthy(found_fatal, "expected fatal: line in output buffer") -end) - t.test( "streaming :G! fetch (bang) opens preview window with terminal buffer", function()