BREAKING CHANGE: This is a breaking change, it deprecates the Delta Reviewer (#81)
BREAKING This is a breaking change which deprecates support for the Delta reviewer. Now, only Diffview is supported.
This commit is contained in:
committed by
GitHub
parent
a032c6434e
commit
ffdaf83784
@@ -38,7 +38,7 @@ M.add_popup = function(type)
|
||||
table.insert(current_ids, choice.id)
|
||||
local body = { ids = current_ids }
|
||||
job.run_job("/mr/" .. type, "PUT", body, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
state.INFO[plural] = data[plural]
|
||||
end)
|
||||
end)
|
||||
@@ -59,7 +59,7 @@ M.delete_popup = function(type)
|
||||
local ids = u.extract(M.filter_eligible(current, { choice }), "id")
|
||||
local body = { ids = ids }
|
||||
job.run_job("/mr/" .. type, "PUT", body, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
state.INFO[plural] = data[plural]
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -46,11 +46,6 @@ M.create_comment_suggestion = function()
|
||||
local backticks = "```"
|
||||
local selected_lines = reviewer.get_lines(start_line, end_line)
|
||||
|
||||
if selected_lines == nil then
|
||||
-- TODO: remove when delta is supported
|
||||
return
|
||||
end
|
||||
|
||||
for line in ipairs(selected_lines) do
|
||||
if string.match(line, "^```$") then
|
||||
backticks = "````"
|
||||
@@ -65,7 +60,7 @@ M.create_comment_suggestion = function()
|
||||
suggestion_start = backticks .. "suggestion:-" .. range .. "+0"
|
||||
else
|
||||
-- This should never happen afaik
|
||||
vim.notify("Unexpected suggestion position", vim.log.levels.ERROR)
|
||||
u.notify("Unexpected suggestion position", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
suggestion_start = suggestion_start
|
||||
@@ -117,14 +112,14 @@ end
|
||||
---@param unlinked boolean | nil if true, the comment is not linked to a line
|
||||
M.confirm_create_comment = function(text, range, unlinked)
|
||||
if text == nil then
|
||||
vim.notify("Reviewer did not provide text of change", vim.log.levels.ERROR)
|
||||
u.notify("Reviewer did not provide text of change", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
if unlinked then
|
||||
local body = { comment = text }
|
||||
job.run_job("/comment", "POST", body, function(data)
|
||||
vim.notify("Note created!", vim.log.levels.INFO)
|
||||
u.notify("Note created!", vim.log.levels.INFO)
|
||||
discussions.add_discussion({ data = data, unlinked = true })
|
||||
end)
|
||||
return
|
||||
@@ -149,7 +144,7 @@ M.confirm_create_comment = function(text, range, unlinked)
|
||||
}
|
||||
|
||||
job.run_job("/comment", "POST", body, function(data)
|
||||
vim.notify("Comment created!", vim.log.levels.INFO)
|
||||
u.notify("Comment created!", vim.log.levels.INFO)
|
||||
discussions.add_discussion({ data = data, unlinked = false })
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
-- and marking discussions as resolved/unresolved.
|
||||
local Split = require("nui.split")
|
||||
local Popup = require("nui.popup")
|
||||
local Menu = require("nui.menu")
|
||||
local NuiTree = require("nui.tree")
|
||||
local Layout = require("nui.layout")
|
||||
local job = require("gitlab.job")
|
||||
@@ -40,7 +39,7 @@ M.toggle = function()
|
||||
|
||||
job.run_job("/discussions", "POST", { blacklist = state.settings.discussion_tree.blacklist }, function(data)
|
||||
if type(data.discussions) ~= "table" and type(data.unlinked_discussions) ~= "table" then
|
||||
vim.notify("No discussions or notes for this MR", vim.log.levels.WARN)
|
||||
u.notify("No discussions or notes for this MR", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -86,7 +85,7 @@ M.send_reply = function(tree, discussion_id)
|
||||
return function(text)
|
||||
local body = { discussion_id = discussion_id, reply = text }
|
||||
job.run_job("/reply", "POST", body, function(data)
|
||||
vim.notify("Sent reply!", vim.log.levels.INFO)
|
||||
u.notify("Sent reply!", vim.log.levels.INFO)
|
||||
M.add_reply_to_tree(tree, data.note, discussion_id)
|
||||
end)
|
||||
end
|
||||
@@ -94,74 +93,48 @@ end
|
||||
|
||||
-- This function (settings.discussion_tree.delete_comment) will trigger a popup prompting you to delete the current comment
|
||||
M.delete_comment = function(tree, unlinked)
|
||||
local menu = Menu({
|
||||
position = "50%",
|
||||
size = {
|
||||
width = 25,
|
||||
},
|
||||
border = {
|
||||
style = "single",
|
||||
text = {
|
||||
top = "Delete Comment?",
|
||||
top_align = "center",
|
||||
},
|
||||
},
|
||||
win_options = {
|
||||
winhighlight = "Normal:Normal,FloatBorder:Normal",
|
||||
},
|
||||
}, {
|
||||
lines = {
|
||||
Menu.item("Confirm"),
|
||||
Menu.item("Cancel"),
|
||||
},
|
||||
max_width = 20,
|
||||
keymap = {
|
||||
focus_next = state.settings.dialogue.focus_next,
|
||||
focus_prev = state.settings.dialogue.focus_prev,
|
||||
close = state.settings.dialogue.close,
|
||||
submit = state.settings.dialogue.submit,
|
||||
},
|
||||
on_submit = function(item)
|
||||
M.send_deletion(tree, item, unlinked)
|
||||
end,
|
||||
})
|
||||
menu:mount()
|
||||
vim.ui.select({ "Confirm", "Cancel" }, {
|
||||
prompt = "Delete comment?",
|
||||
}, function(choice)
|
||||
if choice == "Cancel" then
|
||||
return
|
||||
end
|
||||
M.send_deletion(tree, unlinked)
|
||||
end)
|
||||
end
|
||||
|
||||
-- This function will actually send the deletion to Gitlab
|
||||
-- when you make a selection, and re-render the tree
|
||||
M.send_deletion = function(tree, item, unlinked)
|
||||
if item.text == "Confirm" then
|
||||
local current_node = tree:get_node()
|
||||
M.send_deletion = function(tree, unlinked)
|
||||
local current_node = tree:get_node()
|
||||
|
||||
local note_node = M.get_note_node(tree, current_node)
|
||||
local root_node = M.get_root_node(tree, current_node)
|
||||
local note_id = note_node.is_root and root_node.root_note_id or note_node.id
|
||||
local note_node = M.get_note_node(tree, current_node)
|
||||
local root_node = M.get_root_node(tree, current_node)
|
||||
local note_id = note_node.is_root and root_node.root_note_id or note_node.id
|
||||
|
||||
local body = { discussion_id = root_node.id, note_id = note_id }
|
||||
local body = { discussion_id = root_node.id, note_id = note_id }
|
||||
|
||||
job.run_job("/comment", "DELETE", body, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
if not note_node.is_root then
|
||||
tree:remove_node("-" .. note_id) -- Note is not a discussion root, safe to remove
|
||||
tree:render()
|
||||
job.run_job("/comment", "DELETE", body, function(data)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
if not note_node.is_root then
|
||||
tree:remove_node("-" .. note_id) -- Note is not a discussion root, safe to remove
|
||||
tree:render()
|
||||
else
|
||||
if unlinked then
|
||||
M.unlinked_discussions = u.remove_first_value(M.unlinked_discussions)
|
||||
M.rebuild_unlinked_discussion_tree()
|
||||
else
|
||||
if unlinked then
|
||||
M.unlinked_discussions = u.remove_first_value(M.unlinked_discussions)
|
||||
M.rebuild_unlinked_discussion_tree()
|
||||
else
|
||||
M.discussions = u.remove_first_value(M.discussions)
|
||||
M.rebuild_discussion_tree()
|
||||
end
|
||||
M.discussions = u.remove_first_value(M.discussions)
|
||||
M.rebuild_discussion_tree()
|
||||
end
|
||||
M.switch_can_edit_bufs(true)
|
||||
M.add_empty_titles({
|
||||
{ M.linked_section_bufnr, M.discussions, "No Discussions for this MR" },
|
||||
{ M.unlinked_section_bufnr, M.unlinked_discussions, "No Notes (Unlinked Discussions) for this MR" },
|
||||
})
|
||||
M.switch_can_edit_bufs(false)
|
||||
end)
|
||||
end
|
||||
end
|
||||
M.switch_can_edit_bufs(true)
|
||||
M.add_empty_titles({
|
||||
{ M.linked_section_bufnr, M.discussions, "No Discussions for this MR" },
|
||||
{ M.unlinked_section_bufnr, M.unlinked_discussions, "No Notes (Unlinked Discussions) for this MR" },
|
||||
})
|
||||
M.switch_can_edit_bufs(false)
|
||||
end)
|
||||
end
|
||||
|
||||
-- This function (settings.discussion_tree.edit_comment) will open the edit popup for the current comment in the discussion tree
|
||||
@@ -199,7 +172,7 @@ M.send_edits = function(discussion_id, note_id, unlinked)
|
||||
comment = text,
|
||||
}
|
||||
job.run_job("/comment", "PATCH", body, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
if unlinked then
|
||||
M.unlinked_discussions = M.replace_text(M.unlinked_discussions, discussion_id, note_id, text)
|
||||
M.rebuild_unlinked_discussion_tree()
|
||||
@@ -225,7 +198,7 @@ M.toggle_resolved = function(tree)
|
||||
}
|
||||
|
||||
job.run_job("/comment", "PATCH", body, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
M.redraw_resolved_status(tree, note, not note.resolved)
|
||||
end)
|
||||
end
|
||||
@@ -234,7 +207,7 @@ end
|
||||
M.jump_to_reviewer = function(tree)
|
||||
local file_name, new_line, old_line, error = M.get_note_location(tree)
|
||||
if error ~= nil then
|
||||
vim.notify(error, vim.log.levels.ERROR)
|
||||
u.notify(error, vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
reviewer.jump(file_name, new_line, old_line)
|
||||
@@ -244,7 +217,7 @@ end
|
||||
M.jump_to_file = function(tree)
|
||||
local file_name, new_line, old_line, error = M.get_note_location(tree)
|
||||
if error ~= nil then
|
||||
vim.notify(error, vim.log.levels.ERROR)
|
||||
u.notify(error, vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
vim.cmd.tabnew()
|
||||
|
||||
@@ -6,7 +6,7 @@ local M = {}
|
||||
M.open_in_browser = function()
|
||||
local url = state.INFO.web_url
|
||||
if url == nil then
|
||||
vim.notify("Could not get Gitlab URL", vim.log.levels.ERROR)
|
||||
u.notify("Could not get Gitlab URL", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
if vim.fn.has("mac") == 1 then
|
||||
@@ -14,21 +14,21 @@ M.open_in_browser = function()
|
||||
elseif vim.fn.has("unix") == 1 then
|
||||
vim.fn.jobstart({ "xdg-open", url })
|
||||
else
|
||||
vim.notify("Opening a Gitlab URL is not supported on this OS!", vim.log.levels.ERROR)
|
||||
u.notify("Opening a Gitlab URL is not supported on this OS!", vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
|
||||
M.attach_file = function()
|
||||
local attachment_dir = state.settings.attachment_dir
|
||||
if not attachment_dir or attachment_dir == "" then
|
||||
vim.notify("Must provide valid attachment_dir in plugin setup", vim.log.levels.ERROR)
|
||||
u.notify("Must provide valid attachment_dir in plugin setup", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
local files = u.list_files_in_folder(attachment_dir)
|
||||
|
||||
if files == nil then
|
||||
vim.notify(string.format("Could not list files in %s", attachment_dir), vim.log.levels.ERROR)
|
||||
u.notify(string.format("Could not list files in %s", attachment_dir), vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ local function get_pipeline()
|
||||
local pipeline = state.INFO.head_pipeline or state.INFO.pipeline
|
||||
|
||||
if type(pipeline) ~= "table" or (type(pipeline) == "table" and u.table_size(pipeline) == 0) then
|
||||
vim.notify("Pipeline not found", vim.log.levels.WARN)
|
||||
u.notify("Pipeline not found", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
return pipeline
|
||||
@@ -86,12 +86,12 @@ M.retrigger = function()
|
||||
end
|
||||
local body = { pipeline_id = pipeline.id }
|
||||
if pipeline.status ~= "failed" then
|
||||
vim.notify("Pipeline is not in a failed state!", vim.log.levels.WARN)
|
||||
u.notify("Pipeline is not in a failed state!", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
job.run_job("/pipeline", "POST", body, function()
|
||||
vim.notify("Pipeline re-triggered!", vim.log.levels.INFO)
|
||||
u.notify("Pipeline re-triggered!", vim.log.levels.INFO)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ M.see_logs = function()
|
||||
local text = u.get_line_content(bufnr, linnr)
|
||||
local last_word = u.get_last_chunk(text)
|
||||
if last_word == nil then
|
||||
vim.notify("Cannot find job name", vim.log.levels.ERROR)
|
||||
u.notify("Cannot find job name", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -113,7 +113,7 @@ M.see_logs = function()
|
||||
end
|
||||
|
||||
if j == nil then
|
||||
vim.notify("Cannot find job in state", vim.log.levels.ERROR)
|
||||
u.notify("Cannot find job in state", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -121,7 +121,7 @@ M.see_logs = function()
|
||||
job.run_job("/job", "GET", body, function(data)
|
||||
local file = data.file
|
||||
if file == "" then
|
||||
vim.notify("Log trace is empty", vim.log.levels.WARN)
|
||||
u.notify("Log trace is empty", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -131,7 +131,7 @@ M.see_logs = function()
|
||||
end
|
||||
|
||||
if #lines == 0 then
|
||||
vim.notify("Log trace lines could not be parsed", vim.log.levels.ERROR)
|
||||
u.notify("Log trace lines could not be parsed", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ M.edit_summary = function()
|
||||
local title = u.get_buffer_text(M.title_bufnr):gsub("\n", " ")
|
||||
local body = { title = title, description = description }
|
||||
job.run_job("/mr/summary", "PUT", body, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
state.INFO.description = data.mr.description
|
||||
state.INFO.title = data.mr.title
|
||||
M.layout:unmount()
|
||||
|
||||
Reference in New Issue
Block a user