Release 2.5.1 (#271)

* feat: Support for custom authentication provider functions (#270)
* feat: Support for adding "draft" notes to the review, and publishing them, either individually or all at once. Addresses feature request #223.
* feat: Lets users select + checkout a merge request directly within Neovim, without exiting to the terminal
* fix: Checks that the remote feature branch exists and is up-to-date before creating a MR, starting a review, or opening the MR summary (#278)
* docs: We require some state from Diffview, this shows how to load that state prior to installing w/ Packer. Fixes #94.

This is a #MINOR release.

---------

Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me>
Co-authored-by: sunfuze <sunfuze.1989@gmail.com>
Co-authored-by: Patrick Pichler <mail@patrickpichler.dev>
This commit is contained in:
Harrison (Harry) Cramer
2024-04-22 16:56:27 -04:00
committed by GitHub
parent f10c4ebb8f
commit cf6ccddce3
42 changed files with 2830 additions and 1149 deletions

View File

@@ -1,3 +1,4 @@
local git = require("gitlab.git")
local List = require("gitlab.utils.list")
local has_devicons, devicons = pcall(require, "nvim-web-devicons")
local M = {}
@@ -202,6 +203,17 @@ M.split_by_new_lines = function(s)
return s:gmatch("(.-)\n") -- Match 0 or more (as few as possible) characters followed by a new line.
end
---Takes a string of lines and returns a table of lines
---@param s string The string to parse
---@return table
M.lines_into_table = function(s)
local lines = {}
for line in M.split_by_new_lines(s) do
table.insert(lines, line)
end
return lines
end
-- Reverses the order of elements in a list
---@param list table The list to reverse
---@return table
@@ -493,7 +505,7 @@ M.create_popup_state = function(title, settings, width, height, zindex)
end
---Create view_opts for Box popups used inside popup Layouts
---@param title string The string to appear on top of the popup
---@param title string|nil The string to appear on top of the popup
---@param enter boolean Whether the pop should be focused after creation
---@return table
M.create_box_popup_state = function(title, enter)
@@ -656,52 +668,10 @@ M.make_comma_separated_readable = function(str)
return string.gsub(str, ",", ", ")
end
---Return the name of the current branch
---@return string|nil
M.get_current_branch = function()
local handle = io.popen("git branch --show-current 2>&1")
if handle then
return handle:read()
else
M.notify("Error running 'git branch' command.", vim.log.levels.ERROR)
end
end
---Return the list of names of all remote-tracking branches
M.get_all_merge_targets = function()
local handle = io.popen("git branch -r 2>&1")
if not handle then
M.notify("Error running 'git branch' command.", vim.log.levels.ERROR)
return
end
local current_branch = M.get_current_branch()
if not current_branch then
return
end
local lines = {}
for line in handle:lines() do
table.insert(lines, line)
end
handle:close()
-- Trim "origin/" and don't include the HEAD pointer
local branches = List.new(lines)
:map(function(line)
return line:match("origin/(%S+)")
end)
:filter(function(branch)
return not branch:match("^HEAD$") and branch ~= current_branch
end)
return branches
end
---Select a git branch and perform callback with the branch as an argument
---@param cb function The callback to perform with the selected branch
M.select_target_branch = function(cb)
local all_branch_names = M.get_all_merge_targets()
local all_branch_names = git.get_all_merge_targets()
if not all_branch_names then
return
end
@@ -738,6 +708,20 @@ M.open_in_browser = function(url)
end
end
---Combines two tables
---@param t1 table
---@param t2 table
---@return table
M.join = function(t1, t2)
local res = {}
for _, val in ipairs(t1) do
table.insert(res, val)
end
for _, val in ipairs(t2) do
table.insert(res, val)
end
return res
end
---Trims the trailing slash from a URL
---@param s string
---@return string
@@ -745,4 +729,11 @@ M.trim_slash = function(s)
return (s:gsub("/+$", ""))
end
M.ensure_table = function(data)
if data == vim.NIL or data == nil then
return {}
end
return data
end
return M

View File

@@ -21,12 +21,12 @@ end
---Filters a given list
---@generic T
---@param func fun(v: T):boolean
---@param func fun(v: T, i: integer):boolean
---@return List<T> @Returns a new list of elements for which func returns true
function List:filter(func)
local result = List.new()
for _, v in ipairs(self) do
if func(v) == true then
for i, v in ipairs(self) do
if func(v, i) == true then
table.insert(result, v)
end
end
@@ -63,6 +63,19 @@ function List:slice(first, last, step)
return sliced
end
---Returns true if any of the elements can satisfy the callback
---@generic T
---@param func fun(v: T, i: integer):boolean
---@return List<T> @Returns a boolean
function List:includes(func)
for i, v in ipairs(self) do
if func(v, i) == true then
return true
end
end
return false
end
function List:values()
local result = {}
for _, v in ipairs(self) do