Release (#490)
Fix: Jumping to renamed files (#484) Fix: Store reviewer data before creating comment popup (#476) Fix: Make publishing drafts more robust (#483) Fix: Swap file_name and old_file_name in reviewer data (#485) --------- Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me>
This commit is contained in:
committed by
GitHub
parent
9f898aa1a8
commit
a260f648fe
@@ -153,9 +153,9 @@ M.create_comment_layout = function(opts)
|
||||
title = "Note"
|
||||
user_settings = popup_settings.note
|
||||
else
|
||||
-- TODO: investigate why `old_file_name` is in fact the new name for renamed files!
|
||||
local file_name = M.location.reviewer_data.old_file_name ~= "" and M.location.reviewer_data.old_file_name
|
||||
or M.location.reviewer_data.file_name
|
||||
local file_name = (M.location.reviewer_data.new_sha_focused or M.location.reviewer_data.old_file_name == "")
|
||||
and M.location.reviewer_data.file_name
|
||||
or M.location.reviewer_data.old_file_name
|
||||
title =
|
||||
popup.create_title("Comment", file_name, M.location.visual_range.start_line, M.location.visual_range.end_line)
|
||||
user_settings = popup_settings.comment
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
-- under lua/gitlab/actions/discussions/init.lua
|
||||
local common = require("gitlab.actions.common")
|
||||
local discussion_tree = require("gitlab.actions.discussions.tree")
|
||||
local git = require("gitlab.git")
|
||||
local job = require("gitlab.job")
|
||||
local NuiTree = require("nui.tree")
|
||||
local List = require("gitlab.utils.list")
|
||||
@@ -85,12 +86,20 @@ end
|
||||
|
||||
---Publishes all draft notes and comments. Re-renders all discussion views.
|
||||
M.confirm_publish_all_drafts = function()
|
||||
if not git.check_current_branch_up_to_date_on_remote(vim.log.levels.ERROR) then
|
||||
return
|
||||
end
|
||||
local body = { publish_all = true }
|
||||
job.run_job("/mr/draft_notes/publish", "POST", body, function(data)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
state.DRAFT_NOTES = {}
|
||||
local discussions = require("gitlab.actions.discussions")
|
||||
discussions.rebuild_view(false, true)
|
||||
require("gitlab.actions.discussions").rebuild_view(false, true)
|
||||
end, function()
|
||||
require("gitlab.actions.discussions").rebuild_view(false, true)
|
||||
u.notify(
|
||||
"Draft(s) may have been published despite the error. Check the discussion tree. Try publishing drafts individually.",
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -99,6 +108,9 @@ end
|
||||
---and re-render it.
|
||||
---@param tree NuiTree
|
||||
M.confirm_publish_draft = function(tree)
|
||||
if not git.check_current_branch_up_to_date_on_remote(vim.log.levels.ERROR) then
|
||||
return
|
||||
end
|
||||
local current_node = tree:get_node()
|
||||
local note_node = common.get_note_node(tree, current_node)
|
||||
local root_node = common.get_root_node(tree, current_node)
|
||||
@@ -111,12 +123,13 @@ M.confirm_publish_draft = function(tree)
|
||||
---@type integer
|
||||
local note_id = note_node.is_root and root_node.id or note_node.id
|
||||
local body = { note = note_id }
|
||||
local unlinked = tree.bufnr == require("gitlab.actions.discussions").unlinked_bufnr
|
||||
job.run_job("/mr/draft_notes/publish", "POST", body, function(data)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
|
||||
local discussions = require("gitlab.actions.discussions")
|
||||
local unlinked = tree.bufnr == discussions.unlinked_bufnr
|
||||
M.rebuild_view(unlinked)
|
||||
end, function()
|
||||
M.rebuild_view(unlinked)
|
||||
u.notify("Draft may have been published despite the error. Check the discussion tree.", vim.log.levels.WARN)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user