Skip to content

Commit

Permalink
Fixes #71 (#75)
Browse files Browse the repository at this point in the history
This MR fixes the check for The `diffview` reviewer. Rather than checking for the presence of the command, we check for the module itself.
  • Loading branch information
harrisoncramer authored Oct 31, 2023
1 parent 2323243 commit 6b7e67b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ The upper part of the popup contains the title, which can also be edited and sen

### Reviewing Diffs

The `review` action will open a diff of the changes. You can leave comments using the `create_comment` action or for multiline comments use `create_multiline_comment` in visual mode.
The `review` action will open a diff of the changes. You can leave comments using the `create_comment` action. In visual mode, add multiline comments with the `create_multiline_comment` command, and add suggested changes with the `create_comment_suggestion` command.

```lua
require("gitlab").review()
require("gitlab").create_comment()
require("gitlab").create_multiline_comment()
require("gitlab").create_multiline_comment() -- Only supported for diffview reviewer
require("gitlab").create_comment_suggestion() -- Only supported for diffview reviewer
```

For suggesting changes you can use `create_comment_suggestion` in visual mode which works similar to `create_multiline_comment` but prefills the comment window with gitlab [suggest changes](https://docs.gitlab.com/ee/user/project/merge_requests/reviews/suggestions.html) code block with prefilled code from visual selection.
Expand Down Expand Up @@ -267,7 +268,7 @@ vim.keymap.set("n", "<leader>glo", gitlab.open_in_browser)

This plugin uses a Golang server to reach out to Gitlab. It's possible that something is going wrong when starting that server or connecting with Gitlab. The Golang server runs outside of Neovim, and can be interacted with directly in order to troubleshoot. To start the server, check out your feature branch and run these commands:

```
```lua
:lua require("gitlab.server").build(true)
:lua require("gitlab.server").start(function() print("Server started") end)
```
Expand Down
17 changes: 8 additions & 9 deletions lua/gitlab/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ M.get_current_line_number = function()
end

M.has_reviewer = function(reviewer)
local has_reviewer
if reviewer == "diffview" then
has_reviewer = vim.fn.exists(":DiffviewOpen") ~= 0
local diffview_ok, _ = pcall(require, "diffview")
if not diffview_ok then
error("Please install diffview or change your reviewer")
end
else
has_reviewer = vim.fn.executable("delta") == 1
end

if not has_reviewer then
error(string.format("Please install %s or change your reviewer", reviewer))
local has_reviewer = vim.fn.executable("delta") == 1
if not has_reviewer then
error(string.format("Please install delta or change your reviewer", reviewer))
end
end

return has_reviewer
end

M.is_windows = function()
Expand Down

0 comments on commit 6b7e67b

Please sign in to comment.