Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.23.1'
go-version: '1.25.1'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v7
with:
version: v1.61.0
version: v2.7.2
only-new-issues: true
skip-cache: true
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@2024.1.1
run: go install honnef.co/go/tools/cmd/staticcheck@2025.1.1

- name: Run staticcheck
run: staticcheck ./...
go_test:
Expand All @@ -42,8 +43,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.25.1'
- name: Build
run: make compile
- name: Test
run: make test

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ tests/plugins
!tests/plugins/.placeholder
luacov.*
tags
.claude
cmd/cmd
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: "2"
run:
tests: true
timeout: 30s
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To view these help docs and to get more detailed help information, please run `:

## Requirements

- <a href="https://go.dev/">Go</a> >= v1.19
- <a href="https://go.dev/">Go</a> >= v1.25.1

## Quick Start

Expand Down
4 changes: 2 additions & 2 deletions cmd/app/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"encoding/json"
"net/http"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type MergeRequestApprover interface {
ApproveMergeRequest(pid interface{}, mr int, opt *gitlab.ApproveMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequestApprovals, *gitlab.Response, error)
ApproveMergeRequest(pid interface{}, mr int64, opt *gitlab.ApproveMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequestApprovals, *gitlab.Response, error)
}

type mergeRequestApproverService struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/app/approve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"net/http"
"testing"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type fakeApproverClient struct {
testBase
}

func (f fakeApproverClient) ApproveMergeRequest(pid interface{}, mr int, opt *gitlab.ApproveMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequestApprovals, *gitlab.Response, error) {
func (f fakeApproverClient) ApproveMergeRequest(pid interface{}, mr int64, opt *gitlab.ApproveMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequestApprovals, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
Expand Down
4 changes: 2 additions & 2 deletions cmd/app/assignee.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"errors"
"net/http"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type AssigneeUpdateRequest struct {
Ids []int `json:"ids" validate:"required"`
Ids []int64 `json:"ids" validate:"required"`
}

type AssigneeUpdateResponse struct {
Expand Down
6 changes: 3 additions & 3 deletions cmd/app/assignee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"net/http"
"testing"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type fakeAssigneeClient struct {
testBase
}

func (f fakeAssigneeClient) UpdateMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
func (f fakeAssigneeClient) UpdateMergeRequest(pid interface{}, mergeRequest int64, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
Expand All @@ -20,7 +20,7 @@ func (f fakeAssigneeClient) UpdateMergeRequest(pid interface{}, mergeRequest int
}

func TestAssigneeHandler(t *testing.T) {
var updatePayload = AssigneeUpdateRequest{Ids: []int{1, 2}}
var updatePayload = AssigneeUpdateRequest{Ids: []int64{1, 2}}

t.Run("Updates assignees", func(t *testing.T) {
request := makeRequest(t, http.MethodPut, "/mr/assignee", updatePayload)
Expand Down
6 changes: 3 additions & 3 deletions cmd/app/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"os"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type FileReader interface {
Expand Down Expand Up @@ -48,7 +48,7 @@ func (ar attachmentReader) ReadFile(path string) (io.Reader, error) {
}

type FileUploader interface {
UploadFile(pid interface{}, content io.Reader, filename string, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectFile, *gitlab.Response, error)
UploadProjectMarkdown(pid any, content io.Reader, filename string, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectMarkdownUploadedFile, *gitlab.Response, error)
}

type attachmentService struct {
Expand All @@ -67,7 +67,7 @@ func (a attachmentService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

projectFile, res, err := a.client.UploadFile(a.projectInfo.ProjectId, file, payload.FileName)
projectFile, res, err := a.client.UploadProjectMarkdown(a.projectInfo.ProjectId, file, payload.FileName)
if err != nil {
handleError(w, err, fmt.Sprintf("Could not upload %s to Gitlab", payload.FileName), http.StatusInternalServerError)
return
Expand Down
6 changes: 3 additions & 3 deletions cmd/app/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import (
"net/http"
"testing"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type fakeFileUploaderClient struct {
testBase
}

func (f fakeFileUploaderClient) UploadFile(pid interface{}, content io.Reader, filename string, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectFile, *gitlab.Response, error) {
func (f fakeFileUploaderClient) UploadProjectMarkdown(pid interface{}, content io.Reader, filename string, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectMarkdownUploadedFile, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
}

return &gitlab.ProjectFile{}, resp, nil
return &gitlab.ProjectMarkdownUploadedFile{}, resp, nil
}

type fakeFileReader struct{}
Expand Down
50 changes: 26 additions & 24 deletions cmd/app/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@ import (

"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
"github.com/hashicorp/go-retryablehttp"
"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type ProjectInfo struct {
ProjectId string
MergeId int
MergeId int64
}

/* The Client struct embeds all the methods from Gitlab for the different services */
type Client struct {
*gitlab.MergeRequestsService
*gitlab.MergeRequestApprovalsService
*gitlab.DiscussionsService
*gitlab.ProjectsService
*gitlab.ProjectMembersService
*gitlab.JobsService
*gitlab.PipelinesService
*gitlab.LabelsService
*gitlab.AwardEmojiService
*gitlab.UsersService
*gitlab.DraftNotesService
gitlab.MergeRequestsServiceInterface
gitlab.MergeRequestApprovalsServiceInterface
gitlab.DiscussionsServiceInterface
gitlab.ProjectsServiceInterface
gitlab.ProjectMembersServiceInterface
gitlab.JobsServiceInterface
gitlab.PipelinesServiceInterface
gitlab.LabelsServiceInterface
gitlab.AwardEmojiServiceInterface
gitlab.UsersServiceInterface
gitlab.DraftNotesServiceInterface
gitlab.ProjectMarkdownUploadsServiceInterface
}

/* NewClient parses and validates the project settings and initializes the Gitlab client. */
Expand Down Expand Up @@ -87,17 +88,18 @@ func NewClient() (*Client, error) {
}

return &Client{
MergeRequestsService: client.MergeRequests,
MergeRequestApprovalsService: client.MergeRequestApprovals,
DiscussionsService: client.Discussions,
ProjectsService: client.Projects,
ProjectMembersService: client.ProjectMembers,
JobsService: client.Jobs,
PipelinesService: client.Pipelines,
LabelsService: client.Labels,
AwardEmojiService: client.AwardEmoji,
UsersService: client.Users,
DraftNotesService: client.DraftNotes,
client.MergeRequests,
client.MergeRequestApprovals,
client.Discussions,
client.Projects,
client.ProjectMembers,
client.Jobs,
client.Pipelines,
client.Labels,
client.AwardEmoji,
client.Users,
client.DraftNotes,
client.ProjectMarkdownUploads,
}, nil
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/app/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type CommentResponse struct {
Expand All @@ -14,9 +14,9 @@ type CommentResponse struct {
}

type CommentManager interface {
CreateMergeRequestDiscussion(pid interface{}, mergeRequest int, opt *gitlab.CreateMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error)
UpdateMergeRequestDiscussionNote(pid interface{}, mergeRequest int, discussion string, note int, opt *gitlab.UpdateMergeRequestDiscussionNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)
DeleteMergeRequestDiscussionNote(pid interface{}, mergeRequest int, discussion string, note int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
CreateMergeRequestDiscussion(pid interface{}, mergeRequest int64, opt *gitlab.CreateMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error)
UpdateMergeRequestDiscussionNote(pid interface{}, mergeRequest int64, discussion string, note int64, opt *gitlab.UpdateMergeRequestDiscussionNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)
DeleteMergeRequestDiscussionNote(pid interface{}, mergeRequest int64, discussion string, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
}

type commentService struct {
Expand All @@ -38,7 +38,7 @@ func (a commentService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

type DeleteCommentRequest struct {
NoteId int `json:"note_id" validate:"required"`
NoteId int64 `json:"note_id" validate:"required"`
DiscussionId string `json:"discussion_id" validate:"required"`
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func (a commentService) postComment(w http.ResponseWriter, r *http.Request) {

type EditCommentRequest struct {
Comment string `json:"comment" validate:"required"`
NoteId int `json:"note_id" validate:"required"`
NoteId int64 `json:"note_id" validate:"required"`
DiscussionId string `json:"discussion_id" validate:"required"`
Resolved bool `json:"resolved"`
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/app/comment_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"crypto/sha1"
"fmt"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

/* LinePosition represents a position in a line range. Unlike the Gitlab struct, this does not contain LineCode with a sha1 of the filename */
type LinePosition struct {
Type string `json:"type"`
OldLine int `json:"old_line"`
NewLine int `json:"new_line"`
OldLine int64 `json:"old_line"`
NewLine int64 `json:"new_line"`
}

/* LineRange represents the range of a note. */
Expand All @@ -24,8 +24,8 @@ type LineRange struct {
type PositionData struct {
FileName string `json:"file_name"`
OldFileName string `json:"old_file_name"`
NewLine *int `json:"new_line,omitempty"`
OldLine *int `json:"old_line,omitempty"`
NewLine *int64 `json:"new_line,omitempty"`
OldLine *int64 `json:"old_line,omitempty"`
HeadCommitSHA string `json:"head_commit_sha"`
BaseCommitSHA string `json:"base_commit_sha"`
StartCommitSHA string `json:"start_commit_sha"`
Expand Down
8 changes: 4 additions & 4 deletions cmd/app/comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import (
"net/http"
"testing"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type fakeCommentClient struct {
testBase
}

func (f fakeCommentClient) CreateMergeRequestDiscussion(pid interface{}, mergeRequest int, opt *gitlab.CreateMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error) {
func (f fakeCommentClient) CreateMergeRequestDiscussion(pid interface{}, mergeRequest int64, opt *gitlab.CreateMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
}

return &gitlab.Discussion{Notes: []*gitlab.Note{{}}}, resp, err
}
func (f fakeCommentClient) UpdateMergeRequestDiscussionNote(pid interface{}, mergeRequest int, discussion string, note int, opt *gitlab.UpdateMergeRequestDiscussionNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error) {
func (f fakeCommentClient) UpdateMergeRequestDiscussionNote(pid interface{}, mergeRequest int64, discussion string, note int64, opt *gitlab.UpdateMergeRequestDiscussionNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
Expand All @@ -28,7 +28,7 @@ func (f fakeCommentClient) UpdateMergeRequestDiscussionNote(pid interface{}, mer
return &gitlab.Note{}, resp, err
}

func (f fakeCommentClient) DeleteMergeRequestDiscussionNote(pid interface{}, mergeRequest int, discussion string, note int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
func (f fakeCommentClient) DeleteMergeRequestDiscussionNote(pid interface{}, mergeRequest int64, discussion string, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, err
Expand Down
7 changes: 6 additions & 1 deletion cmd/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type PluginOptions struct {
GitlabRequest bool `json:"gitlab_request"`
GitlabResponse bool `json:"gitlab_response"`
} `json:"debug"`
ChosenMrIID int `json:"chosen_mr_iid"`
ChosenMrIID int64 `json:"chosen_mr_iid"`
ConnectionSettings struct {
Proxy string `json:"proxy"`
Insecure bool `json:"insecure"`
Expand All @@ -20,7 +20,12 @@ type PluginOptions struct {
}

var pluginOptions PluginOptions
var version string

func SetPluginOptions(p PluginOptions) {
pluginOptions = p
}

func SetVersion(v string) {
version = v
}
4 changes: 2 additions & 2 deletions cmd/app/create_mr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"fmt"
"net/http"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type CreateMrRequest struct {
Title string `json:"title" validate:"required"`
TargetBranch string `json:"target_branch" validate:"required"`
Description string `json:"description"`
TargetProjectID int `json:"forked_project_id,omitempty"`
TargetProjectID int64 `json:"forked_project_id,omitempty"`
DeleteBranch bool `json:"delete_branch"`
Squash bool `json:"squash"`
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/app/create_mr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"testing"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type fakeMergeCreatorClient struct {
Expand Down
Loading
Loading