committed by
GitHub
parent
ce5dd1aaa2
commit
27c54b4739
@@ -35,7 +35,22 @@ M.confirm_create_comment = function(text)
|
||||
end
|
||||
end
|
||||
|
||||
local jsonTable = { line_number = current_line_number, file_name = relative_file_path, comment = text }
|
||||
-- TODO: How can we know whether to specify that the comment is on a line that has been modified,
|
||||
-- added, or deleted? Additionally, how will we know which line number to send?
|
||||
-- We need an intelligent way of getting this information so that we can send it to the comment
|
||||
-- creation endpoint, relates to Issue #25: https://github.com/harrisoncramer/gitlab.nvim/issues/25
|
||||
|
||||
local revision = state.MR_REVISIONS[1]
|
||||
local jsonTable = {
|
||||
comment = text,
|
||||
file_name = relative_file_path,
|
||||
line_number = current_line_number,
|
||||
base_commit_sha = revision.base_commit_sha,
|
||||
start_commit_sha = revision.start_commit_sha,
|
||||
head_commit_sha = revision.head_commit_sha,
|
||||
type = "modification"
|
||||
}
|
||||
|
||||
local json = vim.json.encode(jsonTable)
|
||||
|
||||
job.run_job("comment", "POST", json, function(data)
|
||||
|
||||
@@ -103,6 +103,19 @@ M.ensureProjectMembers = function(callback)
|
||||
end
|
||||
end
|
||||
|
||||
M.ensureRevisions = function(callback)
|
||||
return function()
|
||||
if type(state.MR_REVISIONS) ~= "table" then
|
||||
job.run_job("mr/revisions", "GET", nil, function(data)
|
||||
state.MR_REVISIONS = data.Revisions
|
||||
callback()
|
||||
end)
|
||||
else
|
||||
callback()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Builds the Go binary
|
||||
M.build = function()
|
||||
local command = string.format("cd %s && make", state.BIN_PATH)
|
||||
@@ -173,7 +186,7 @@ M.summary = M.ensureState(summary.summary)
|
||||
M.approve = M.ensureState(function() job.run_job("approve", "POST") end)
|
||||
M.revoke = M.ensureState(function() job.run_job("revoke", "POST") end)
|
||||
M.list_discussions = M.ensureState(discussions.list_discussions)
|
||||
M.create_comment = M.ensureState(comment.create_comment)
|
||||
M.create_comment = M.ensureState(M.ensureRevisions(comment.create_comment))
|
||||
M.edit_comment = M.ensureState(comment.edit_comment)
|
||||
M.delete_comment = M.ensureState(comment.delete_comment)
|
||||
M.toggle_resolved = M.ensureState(comment.toggle_resolved)
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
-- This is the global state that can be set from
|
||||
-- various places in the plugin. It all begins as
|
||||
-- uninitialized and is set by the setup/ensure function calls
|
||||
|
||||
M.BIN_PATH = nil -- Directory of the Go binary
|
||||
M.BIN = nil -- Full path to the Go binary
|
||||
M.PROJECT_ID = nil -- Gitlab Project ID, set in .gitlab.nvim file
|
||||
M.INFO = nil -- The basic information about the MR, set from "/info" endpoint
|
||||
local M = {}
|
||||
|
||||
-- These are the default keymaps for the plugin
|
||||
M.keymaps = {
|
||||
M.keymaps = {
|
||||
popup = {
|
||||
exit = "<Esc>",
|
||||
perform_action = "<leader>s",
|
||||
|
||||
Reference in New Issue
Block a user