Feat: Adds open_in_browser() command to open MR in browser

This commit is contained in:
Harrison Cramer
2023-09-07 20:40:11 -04:00
parent 57b842cad5
commit f05b6f128b
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
local state = require("gitlab.state")
local M = {}
M.open_in_browser = function()
local url = state.INFO.web_url
if url == nil then
vim.notify("Could not get Gitlab URL", vim.log.levels.ERROR)
return
end
if vim.fn.has("mac") == 1 then
vim.fn.jobstart({ "open", url })
elseif vim.fn.has("unix") == 1 then
vim.fn.jobstart({ "xdg-open", url })
else
vim.notify("Opening a Gitlab URL is not supported on this OS!", vim.log.levels.ERROR)
end
end
return M

View File

@@ -9,6 +9,7 @@ local assignees_and_reviewers = require("gitlab.actions.assignees_and_reviewers"
local comment = require("gitlab.actions.comment")
local pipeline = require("gitlab.actions.pipeline")
local approvals = require("gitlab.actions.approvals")
local miscellaneous = require("gitlab.actions.miscellaneous")
local info = state.dependencies.info
local project_members = state.dependencies.project_members
@@ -44,4 +45,5 @@ return {
-- Other functions 🤷
state = state,
print_settings = state.print_settings,
open_in_browser = async.sequence({ info }, miscellaneous.open_in_browser),
}