From 38bde8a0e4a982329ab4dc4f214f3f06dfc4e4fd Mon Sep 17 00:00:00 2001 From: "Harrison (Harry) Cramer" <32515581+harrisoncramer@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:11:48 -0400 Subject: [PATCH] Bug Fixes (#382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: error messages and run all tests (#381) * feat: Automatically open fold under cursor (#380) * fix: discussion ID is not required (#383) This is a #PATCH release. --------- Co-authored-by: George Kontridze Co-authored-by: Jakub F. BortlĂ­k --- cmd/app/draft_notes.go | 2 +- cmd/app/git/git_test.go | 4 ++-- lua/gitlab/reviewer/init.lua | 2 ++ lua/gitlab/utils/init.lua | 6 ++++++ makefile | 4 ++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/app/draft_notes.go b/cmd/app/draft_notes.go index 42daaa3..4f55053 100644 --- a/cmd/app/draft_notes.go +++ b/cmd/app/draft_notes.go @@ -90,7 +90,7 @@ func (a draftNoteService) listDraftNotes(w http.ResponseWriter, r *http.Request) type PostDraftNoteRequest struct { Comment string `json:"comment" validate:"required"` - DiscussionId string `json:"discussion_id,omitempty" validate:"required"` + DiscussionId string `json:"discussion_id,omitempty"` PositionData // TODO: How to add validations to data from external package??? } diff --git a/cmd/app/git/git_test.go b/cmd/app/git/git_test.go index e8864fb..c2f8804 100644 --- a/cmd/app/git/git_test.go +++ b/cmd/app/git/git_test.go @@ -198,7 +198,7 @@ func TestExtractGitInfo_FailToGetProjectRemoteUrl(t *testing.T) { tC := FailTestCase{ desc: "Error returned by function to get the project remote url", errMsg: "Some error", - expectedErr: "Could not get project Url: Some error", + expectedErr: "could not get project Url: Some error", } t.Run(tC.desc, func(t *testing.T) { g := failingUrlManager{ @@ -227,7 +227,7 @@ func TestExtractGitInfo_FailToGetCurrentBranchName(t *testing.T) { tC := FailTestCase{ desc: "Error returned by function to get the project remote url", errMsg: "Some error", - expectedErr: "Failed to get current branch: Some error", + expectedErr: "failed to get current branch: Some error", } t.Run(tC.desc, func(t *testing.T) { g := failingBranchManager{ diff --git a/lua/gitlab/reviewer/init.lua b/lua/gitlab/reviewer/init.lua index 9ef37ea..185c01b 100644 --- a/lua/gitlab/reviewer/init.lua +++ b/lua/gitlab/reviewer/init.lua @@ -145,6 +145,8 @@ M.jump = function(file_name, line_number, new_buffer) line_number = number_of_lines end vim.api.nvim_win_set_cursor(0, { line_number, 0 }) + u.open_fold_under_cursor() + vim.cmd("normal! zz") end ---Get the data from diffview, such as line information and file name. May be used by diff --git a/lua/gitlab/utils/init.lua b/lua/gitlab/utils/init.lua index 3018fd4..2729da1 100644 --- a/lua/gitlab/utils/init.lua +++ b/lua/gitlab/utils/init.lua @@ -752,4 +752,10 @@ M.get_nested_field = function(table, field) end end +M.open_fold_under_cursor = function() + if vim.fn.foldclosed(vim.fn.line(".")) > -1 then + vim.cmd("normal! zo") + end +end + return M diff --git a/makefile b/makefile index 83e9c65..151ce82 100644 --- a/makefile +++ b/makefile @@ -4,10 +4,10 @@ PROJECTNAME=$(shell basename "$(PWD)") ## compile: build golang project compile: - @cd cmd && go build -o bin && mv bin ../bin + @go build -o bin ./cmd ## test: run golang project tests test: - @cd cmd/app && go test + @go test -v ./... .PHONY: help all: help