committed by
GitHub
parent
899e04082e
commit
08463c0b84
20
README.md
20
README.md
@@ -65,12 +65,32 @@ use {
|
||||
}
|
||||
```
|
||||
|
||||
## Multiple Gitlab Repositories
|
||||
|
||||
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' })
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
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
|
||||
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.
|
||||
|
||||
@@ -41,6 +41,7 @@ M.setup = function(args, build_only)
|
||||
state.BIN_PATH = parent_dir
|
||||
state.BIN = parent_dir .. "/bin"
|
||||
|
||||
if args == nil then args = {} end
|
||||
if args.dev == true then
|
||||
M.build(args)
|
||||
end
|
||||
@@ -62,7 +63,15 @@ 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 = read_file(config_file_path)
|
||||
if config_file_content ~= nil then
|
||||
args.project_id = config_file_content
|
||||
end
|
||||
|
||||
if args.project_id == nil then
|
||||
args.project_id = u.read_file(state.BIN_PATH .. "/.gitlab/project_id")
|
||||
error("No project ID provided!")
|
||||
end
|
||||
|
||||
|
||||
@@ -204,7 +204,16 @@ M.merge_tables = function(defaults, overrides)
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
function read_file(file_path)
|
||||
local file = io.open(file_path, "r")
|
||||
if file == nil then
|
||||
return nil
|
||||
end
|
||||
local file_contents = file:read("*all")
|
||||
file:close()
|
||||
file_contents = string.gsub(file_contents, "\n", "")
|
||||
return file_contents
|
||||
end
|
||||
|
||||
M.get_relative_file_path = get_relative_file_path
|
||||
M.get_current_line_number = get_current_line_number
|
||||
|
||||
Reference in New Issue
Block a user