Modified project_id logic to require .gitlab.nvim file
This commit is contained in:
23
README.md
23
README.md
@@ -41,7 +41,7 @@ return {
|
||||
config = function()
|
||||
vim.opt.termguicolors = true -- This is required if you aren't already initializing notify
|
||||
require("notify").setup({ background_colour = "#000000" }) -- This is required if you aren't already initializing notify
|
||||
require("gitlab").setup({ project_id = 3 }) -- This can be found under the project details section of your Gitlab repository.
|
||||
require("gitlab").setup()
|
||||
end,
|
||||
}
|
||||
```
|
||||
@@ -58,9 +58,9 @@ use {
|
||||
},
|
||||
run = function() require("gitlab").build() end,
|
||||
config = function()
|
||||
vim.opt.termguicolors = true -- This is required if you aren't already initializing notify
|
||||
require("notify").setup({ background_colour = "#000000" }) -- This is required if you aren't already initializing notify
|
||||
require("gitlab").setup({ project_id = 3 }) -- This can be found under the project details section of your Gitlab repository.
|
||||
vim.opt.termguicolors = true
|
||||
require("notify").setup({ background_colour = "#000000" })
|
||||
require("gitlab").setup() -- This can be found under the project details section of your Gitlab repository.
|
||||
end,
|
||||
}
|
||||
```
|
||||
@@ -70,21 +70,15 @@ use {
|
||||
By default, the tool will look for and interact with MRs against a "main" branch. You can configure this by passing in the `base_branch` option:
|
||||
|
||||
```lua
|
||||
require('gitlab').setup({ project_id = 3, base_branch = 'master' })
|
||||
require('gitlab').setup({ base_branch = 'master' })
|
||||
```
|
||||
|
||||
By default, the plugin will read the `project_id` provided in the setup call. However, if you add a `.gitlab.nvim` file to the root of your directory, the plugin will read that and use it as the project_id instead. The file should only contain the ID of the project:
|
||||
By default, the plugin will not connect to a gitlab repository. You must add a `.gitlab.nvim` file to the root of your directory. The plugin will read that file and use it as the project ID. The file should only contain the ID of the project:
|
||||
|
||||
```
|
||||
112415
|
||||
```
|
||||
|
||||
Which is effectively like calling the setup function like this:
|
||||
|
||||
```lua
|
||||
require('gitlab').setup({ project_id = 112415, base_branch = 'master' })
|
||||
```
|
||||
|
||||
If you are using `main` as your branch and you add a `.gitlab.nvim` configuration file, you can call an empty setup function and the plugin will work:
|
||||
|
||||
```lua
|
||||
@@ -93,9 +87,7 @@ require('gitlab').setup()
|
||||
|
||||
## Usage
|
||||
|
||||
First, check out the branch that you want to review locally. Then open Neovim and the reviewer will be initialized. The `project_id` you specify in your configuration must match the project_id of the Gitlab project your terminal is inside of.
|
||||
|
||||
The `summary` command will pull down the MR description into a buffer so that you can read it:
|
||||
First, check out the branch that you want to review locally. Then open Neovim and the reviewer will be initialized. The `project_id` you specify in your configuration file must match the project_id of the Gitlab project your terminal is inside of. The `summary` command will pull down the MR description into a buffer so that you can read it:
|
||||
|
||||
```lua
|
||||
require("gitlab").summary()
|
||||
@@ -166,7 +158,6 @@ To override the defaults, pass a keymaps table into the setup function with any
|
||||
```lua
|
||||
local gitlab = require("gitlab")
|
||||
gitlab.setup({
|
||||
project_id = 36091024,
|
||||
keymaps = {
|
||||
popup = {
|
||||
exit = "q"
|
||||
|
||||
@@ -39,7 +39,7 @@ M.list_discussions = function()
|
||||
if u.base_invalid() then return end
|
||||
Job:new({
|
||||
command = "curl",
|
||||
args = { "-s", "localhost:8081/" .. "discussions" },
|
||||
args = { "-s", string.format("localhost:%s/discussions", state.PORT) },
|
||||
on_stdout = function(_, output)
|
||||
local data_ok, data = pcall(vim.json.decode, output)
|
||||
if data_ok and data ~= nil then
|
||||
|
||||
@@ -60,13 +60,14 @@ M.setup = function(args, build_only)
|
||||
|
||||
if build_only then return end
|
||||
|
||||
-- Override project_id in setup call if configuration file is present
|
||||
local config_file_path = vim.fn.getcwd() .. "/.gitlab.nvim"
|
||||
local config_file_content = u.read_file(config_file_path)
|
||||
if config_file_content ~= nil then
|
||||
args.project_id = config_file_content
|
||||
if config_file_content == nil then
|
||||
return
|
||||
end
|
||||
|
||||
args.project_id = config_file_content
|
||||
|
||||
if args.project_id == nil then
|
||||
args.project_id = u.read_file(state.BIN_PATH .. "/.gitlab/project_id")
|
||||
error("No project ID provided!")
|
||||
|
||||
Reference in New Issue
Block a user