Simplify Go Endpoints + Add Tests (#120)
This MR represents a major refactor of the Go codebase, as well as introducing tests for the handlers. The MR also introduces an endpoint to shutdown or restart the Go server, which may be useful for clients who want to refresh the state of the plugin after checking out branches. Finally, this MR adds a contributing document for users who want to make feature changes.
This commit is contained in:
committed by
GitHub
parent
10b0b596ae
commit
93fe3e8bd6
@@ -101,7 +101,7 @@ local M = {
|
||||
---callback with data
|
||||
---@param callback fun(data: DiscussionData): nil
|
||||
M.load_discussions = function(callback)
|
||||
job.run_job("/discussions", "POST", { blacklist = state.settings.discussion_tree.blacklist }, function(data)
|
||||
job.run_job("/discussions/list", "POST", { blacklist = state.settings.discussion_tree.blacklist }, function(data)
|
||||
M.discussions = data.discussions
|
||||
M.unlinked_discussions = data.unlinked_discussions
|
||||
callback(data)
|
||||
@@ -645,7 +645,7 @@ M.toggle_discussion_resolved = function(tree)
|
||||
resolved = not note.resolved,
|
||||
}
|
||||
|
||||
job.run_job("/discussion/resolve", "PUT", body, function(data)
|
||||
job.run_job("/discussions/resolve", "PUT", body, function(data)
|
||||
u.notify(data.message, vim.log.levels.INFO)
|
||||
M.redraw_resolved_status(tree, note, not note.resolved)
|
||||
end)
|
||||
|
||||
@@ -34,8 +34,8 @@ M.open = function()
|
||||
if not pipeline then
|
||||
return
|
||||
end
|
||||
local body = { pipeline_id = pipeline.id }
|
||||
job.run_job("/pipeline", "GET", body, function(data)
|
||||
|
||||
job.run_job("/pipeline/" .. pipeline.id, "GET", nil, function(data)
|
||||
local pipeline_jobs = u.reverse(type(data.Jobs) == "table" and data.Jobs or {})
|
||||
M.pipeline_jobs = pipeline_jobs
|
||||
|
||||
@@ -92,13 +92,12 @@ M.retrigger = function()
|
||||
if not pipeline then
|
||||
return
|
||||
end
|
||||
local body = { pipeline_id = pipeline.id }
|
||||
if pipeline.status ~= "failed" then
|
||||
u.notify("Pipeline is not in a failed state!", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
job.run_job("/pipeline", "POST", body, function()
|
||||
job.run_job("/pipeline/" .. pipeline.id, "POST", nil, function()
|
||||
u.notify("Pipeline re-triggered!", vim.log.levels.INFO)
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user