This MR is a #MAJOR breaking change to the plugin. While the plugin will continue to work for users with their existing settings, they will be informed of outdated configuration (diagnostics and signs have been simplified) the next time they open the reviewer.

Fix: Trim trailing slash from custom URLs
Update: .github/CONTRIBUTING.md, .github/ISSUE_TEMPLATE/bug_report.md
Feat: Improve discussion tree toggling (#192)
Fix: Toggle modified notes (#188)
Fix: Toggle discussion nodes correctly
Feat: Show Help keymap in discussion tree winbar
Fix: Enable toggling nodes from the note body
Fix: Enable toggling resolved status from child nodes
Fix: Only try to show emoji popup on note nodes
Feat: Add keymap for toggling tree type
Fix: Disable tree type toggling in Notes
Fix Multi Line Issues (Large Refactor) (#197)
Fix: Multi-line discussions. The calculation of a range for a multiline comment has been consolidated and moved into the location.lua file. This does not attempt to fix diagnostics.
Refactor: It refactors the discussions code to split hunk parsing and management into a separate module
Fix: Don't allow comments on modified buffers #194 by preventing comments on the reviewer when using --imply-local and when the working tree is dirty entirely.
Refactor: It introduces a new List class for data aggregation, filtering, etc.
Fix: It removes redundant API calls and refreshes from the discussion pane
Fix: Location provider (#198)
Fix: add nil check for Diffview performance issue (#199)
Fix: Switch Tabs During Comment Creation (#200)
Fix: Check if file is modified (#201)
Fix: Off-By-One Issue in Old SHA (#202)
Fix: Rebuild Diagnostics + Signs (#203)
Fix: Off-By-One Issue in New SHA (#205)
Fix: Reviewer Jumps to wrong location (#206)

BREAKING CHANGE: Changes configuration of diagnostics and signs in the setup call.
This commit is contained in:
Harrison (Harry) Cramer
2024-03-03 11:52:37 -05:00
committed by GitHub
parent f6a5238d4b
commit b5b475ce8b
31 changed files with 1529 additions and 1298 deletions

View File

@@ -0,0 +1,73 @@
local u = require("gitlab.utils")
local state = require("gitlab.state")
local reviewer = require("gitlab.reviewer")
local List = require("gitlab.utils.list")
local M = {}
---Filter all discussions which are relevant for currently visible signs and diagnostics.
---@return Discussion[]
M.filter_placeable_discussions = function(all_discussions)
if type(all_discussions) ~= "table" then
return {}
end
local file = reviewer.get_current_file()
if not file then
return {}
end
return List.new(all_discussions):filter(function(discussion)
local first_note = discussion.notes[1]
return type(first_note.position) == "table"
--Do not include unlinked notes
and (first_note.position.new_path == file or first_note.position.old_path == file)
--Skip resolved discussions if user wants to
and not (state.settings.discussion_signs.skip_resolved_discussion and first_note.resolvable and first_note.resolved)
--Skip discussions from old revisions
and not (
state.settings.discussion_signs.skip_old_revision_discussion
and u.from_iso_format_date_to_timestamp(first_note.created_at)
<= u.from_iso_format_date_to_timestamp(state.MR_REVISIONS[1].created_at)
)
end)
end
M.parse_line_code = function(line_code)
local line_code_regex = "%w+_(%d+)_(%d+)"
local old_line, new_line = line_code:match(line_code_regex)
return tonumber(old_line), tonumber(new_line)
end
---@param discussion Discussion
---@return boolean
M.is_old_sha = function(discussion)
local first_note = discussion.notes[1]
return first_note.position.old_line ~= nil
end
---@param discussion Discussion
---@return boolean
M.is_new_sha = function(discussion)
return not M.is_old_sha(discussion)
end
---@param discussion Discussion
---@return boolean
M.is_single_line = function(discussion)
local first_note = discussion.notes[1]
local line_range = first_note.position.line_range
return line_range == nil
end
---@param discussion Discussion
---@return boolean
M.is_multi_line = function(discussion)
return not M.is_single_line(discussion)
end
---@param discussion Discussion
---@return Note
M.get_first_note = function(discussion)
return discussion.notes[1]
end
return M