BREAKING CHANGE: Setup refactor and code cleanup

This MR makes several major tweaks to the codebase. Primarily it adjusts
the setup steps for the application so that rather than providing just
the project ID in the `.gitlab.nvim` file, users can also provide a
vareity of other settings, such as auth_token, base_branch, and so
forth. This is to make the project more extensible in the future.

This MR also fixes a variety of issues with error handling in the code,
primarily in the request/response model between the Lua jobs and the
Golang server.

BREAKING CHANGE: Modifies `.gitlab.nvim` and setup steps
This commit is contained in:
Harrison (Harry) Cramer
2023-08-06 11:21:39 -04:00
committed by Harrison Cramer
parent ade9f81426
commit 4f0d4b49ef
16 changed files with 281 additions and 293 deletions

View File

@@ -87,7 +87,9 @@ local base_invalid = function()
local base = state.BASE_BRANCH
local hasBaseBranch = feature_branch_exists(base)
if not hasBaseBranch then
vim.notify('No base branch. If this is a Gitlab repository, please check your setup function!', vim.log.levels.ERROR)
vim.notify(
'Could not fetch feature branch. Please check that you have the correct base_branch value set in your .gitlab.nvim configuration file',
vim.log.levels.ERROR)
return true
end
end
@@ -107,29 +109,6 @@ local add_comment_sign = function(line_number)
vim.fn.sign_place(0, "piet", "piet", bufnr, { lnum = line_number })
end
local function is_gitlab_repo()
local current_dir = vim.fn.getcwd()
-- check if it contains a .git folder
local git_dir = current_dir .. "/.git"
if vim.fn.isdirectory(git_dir) == 0 then
return false
end
local git_cmd = 'git remote get-url origin'
local handle = io.popen(git_cmd)
local result = handle:read("*a")
handle:close()
-- check if the remote URL is a Gitlab URL
if string.match(result, "gitlab%.com") then
return true
else
return false
end
end
local function jump_to_file(filename, line_number)
if line_number == nil then line_number = 1 end
vim.api.nvim_command("wincmd l")
@@ -255,7 +234,6 @@ M.format_date = format_date
M.add_comment_sign = add_comment_sign
M.jump_to_file = jump_to_file
M.find_value_by_id = find_value_by_id
M.is_gitlab_repo = is_gitlab_repo
M.darken_metadata = darken_metadata
M.print_success = print_success
M.print_error = print_error