BREAKING CHANGE: Setup refactor and code cleanup
This MR makes several major tweaks to the codebase. Primarily it adjusts the setup steps for the application so that rather than providing just the project ID in the `.gitlab.nvim` file, users can also provide a vareity of other settings, such as auth_token, base_branch, and so forth. This is to make the project more extensible in the future. This MR also fixes a variety of issues with error handling in the code, primarily in the request/response model between the Lua jobs and the Golang server. BREAKING CHANGE: Modifies `.gitlab.nvim` and setup steps
This commit is contained in:
committed by
Harrison Cramer
parent
ade9f81426
commit
4f0d4b49ef
@@ -55,8 +55,9 @@ M.confirm_create_comment = function(text)
|
||||
end
|
||||
end
|
||||
|
||||
local json = string.format('{ "line_number": %d, "file_name": "%s", "comment": "%s" }', current_line_number,
|
||||
relative_file_path, text)
|
||||
local jsonTable = { line_number = current_line_number, file_name = relative_file_path, comment = text }
|
||||
local json = vim.json.encode(jsonTable)
|
||||
|
||||
job.run_job("comment", "POST", json)
|
||||
end
|
||||
|
||||
@@ -105,10 +106,11 @@ M.delete_comment = function()
|
||||
end
|
||||
local discussion_id = node:get_id()
|
||||
discussion_id = string.sub(discussion_id, 2) -- Remove the "-" at the start
|
||||
note_id = string.sub(note_id, 2) -- Remove the "-" at the start
|
||||
note_id = tonumber(string.sub(note_id, 2)) -- Remove the "-" at the start
|
||||
|
||||
local jsonTable = { discussion_id = discussion_id, note_id = note_id }
|
||||
local json = vim.json.encode(jsonTable)
|
||||
|
||||
local json = string.format('{"discussion_id": "%s", "note_id": %d}', discussion_id, note_id)
|
||||
job.run_job("comment", "DELETE", json, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
state.tree:remove_node("-" .. note_id)
|
||||
@@ -136,9 +138,9 @@ M.edit_comment = function()
|
||||
|
||||
editPopup:mount()
|
||||
|
||||
local note_id = string.sub(node:get_id(), 2) -- Remove the "-" at the start
|
||||
local note_id = tonumber(string.sub(node:get_id(), 2)) -- Remove the "-" at the start
|
||||
local discussion_id = node:get_parent_id()
|
||||
discussion_id = string.sub(discussion_id, 2) -- Remove the "-" at the start
|
||||
discussion_id = string.sub(discussion_id, 2) -- Remove the "-" at the start
|
||||
|
||||
state.ACTIVE_DISCUSSION = discussion_id
|
||||
state.ACTIVE_NOTE = note_id
|
||||
@@ -157,8 +159,9 @@ end
|
||||
|
||||
M.send_edits = function(text)
|
||||
local escapedText = string.gsub(text, "\n", "\\n")
|
||||
local json = string.format('{"discussion_id": "%s", "note_id": %s, "comment": "%s"}', state.ACTIVE_DISCUSSION,
|
||||
state.ACTIVE_NOTE, escapedText)
|
||||
|
||||
local jsonTable = { discussion_id = state.ACTIVE_DISCUSSION, note_id = state.ACTIVE_NOTE, comment = escapedText }
|
||||
local json = vim.json.encode(jsonTable)
|
||||
|
||||
job.run_job("comment", "PATCH", json, function()
|
||||
vim.schedule(function()
|
||||
|
||||
Reference in New Issue
Block a user