Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions lua/gitlab/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,6 @@ M.time_since = function(date_string, current_date_table)
end
end

---Removes the first value from a list and returns the new, smaller list
---@param tbl table The table
---@return table
M.remove_first_value = function(tbl)
local sliced_list = {}
if M.table_size(tbl) <= 1 then
return sliced_list
end
for i = 2, #tbl do
table.insert(sliced_list, tbl[i])
end

return sliced_list
end

---Spreads all the values from t2 into t1
---@param t1 table The first table (gets the values)
---@param t2 table The second table
Expand Down Expand Up @@ -176,14 +161,6 @@ M.contains = function(list, search_value)
return false
end

---Trims whitespace from a string
---@param s string The string to trim
---@return string
M.trim = function(s)
local res = s:gsub("^%s+", ""):gsub("%s+$", "")
return res
end

---Splits a string by new lines and returns an iterator
---@param s string The string to split
---@return table: An iterator object
Expand Down Expand Up @@ -556,10 +533,6 @@ M.get_lines = function(start_line, end_line)
return vim.api.nvim_buf_get_lines(0, start_line - 1, end_line, false)
end

M.make_comma_separated_readable = function(str)
return string.gsub(str, ",", ", ")
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)
Expand All @@ -576,11 +549,6 @@ M.select_target_branch = function(cb)
end)
end

M.basename = function(str)
local name = string.gsub(str, "(.*/)(.*)", "%2")
return name
end

M.get_web_url = function()
local web_url = require("gitlab.state").INFO.web_url
if web_url ~= nil then
Expand Down
36 changes: 0 additions & 36 deletions tests/spec/util_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,6 @@ describe("utils/init.lua", function()
end)
end)

describe("remove_first_value", function()
it("Removes the first value correctly", function()
local got = u.remove_first_value({ 1, 2 })
local want = { 2 }
assert.are.same(want, got)
end)
it("Handles a one-length list", function()
local got = u.remove_first_value({ 1 })
local want = {}
assert.are.same(want, got)
end)
it("Handles a zero-length list", function()
local got = u.remove_first_value({})
local want = {}
assert.are.same(want, got)
end)
end)

describe("table_size", function()
it("Works for associative tables", function()
local got = u.remove_first_value({ 1, 2 })
local want = { 2 }
assert.are.same(want, got)
end)
it("Handles a one-length list", function()
local got = u.remove_first_value({ 1 })
local want = {}
assert.are.same(want, got)
end)
it("Handles a zero-length list", function()
local got = u.remove_first_value({})
local want = {}
assert.are.same(want, got)
end)
end)

describe("contains", function()
it("Finds a value in a list", function()
local got = u.contains({ 1, 2 }, 1)
Expand Down
Loading