Skip to content

Commit

Permalink
Fix: Allows you to open up gitlab.nvim even in nested directories (#107)
Browse files Browse the repository at this point in the history
This MR is a #patch fix that ensures you can provide a `.gitlab.nvim`
file at the root of the git project and open up the reviewer at any
level of the project.
  • Loading branch information
harrisoncramer authored Nov 18, 2023
1 parent 2319726 commit 8a9f8df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/gitlab/actions/pipeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ M.see_logs = function()
bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)

-- TODO: Fix for Windows
local job_file_path = string.format("/tmp/gitlab.nvim.job-%d", j.id)
vim.cmd("w! " .. job_file_path)
vim.cmd.bd()
Expand Down
12 changes: 11 additions & 1 deletion lua/gitlab/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ M.merge_settings = function(args)
)
end

M.settings.file_separator = (u.is_windows() and "\\" or "/")

return true
end

Expand All @@ -130,7 +132,15 @@ M.setPluginConfiguration = function()
if M.initialized then
return true
end
local config_file_path = vim.fn.getcwd() .. "/.gitlab.nvim"

local base_path = vim.fn.trim(vim.fn.system({ "git", "rev-parse", "--show-toplevel" }))
if vim.v.shell_error ~= 0 then
u.notify(string.format("Could not get base directory: %s", base_path), vim.log.levels.ERROR)
return false
end

local config_file_path = base_path .. M.settings.file_separator .. ".gitlab.nvim"

local config_file_content = u.read_file(config_file_path)

local file_properties = {}
Expand Down

0 comments on commit 8a9f8df

Please sign in to comment.