diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml
index 5d16155a..58d71f23 100644
--- a/.github/workflows/go.yaml
+++ b/.github/workflows/go.yaml
@@ -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:
@@ -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
+
diff --git a/.gitignore b/.gitignore
index cb0abe54..508fb498 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ tests/plugins
!tests/plugins/.placeholder
luacov.*
tags
+.claude
+cmd/cmd
diff --git a/.golangci.yml b/.golangci.yml
index 2ba75e1f..f5184ab9 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,3 +1,4 @@
+version: "2"
run:
tests: true
timeout: 30s
diff --git a/README.md b/README.md
index b0567b1e..12ca0cb7 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ To view these help docs and to get more detailed help information, please run `:
## Requirements
-- Go >= v1.19
+- Go >= v1.25.1
## Quick Start
diff --git a/cmd/app/approve.go b/cmd/app/approve.go
index 3d7a034d..5b5142d5 100644
--- a/cmd/app/approve.go
+++ b/cmd/app/approve.go
@@ -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 {
diff --git a/cmd/app/approve_test.go b/cmd/app/approve_test.go
index b450169c..07b54095 100644
--- a/cmd/app/approve_test.go
+++ b/cmd/app/approve_test.go
@@ -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
diff --git a/cmd/app/assignee.go b/cmd/app/assignee.go
index 17fb1b66..7218418a 100644
--- a/cmd/app/assignee.go
+++ b/cmd/app/assignee.go
@@ -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 {
diff --git a/cmd/app/assignee_test.go b/cmd/app/assignee_test.go
index dca4f83f..958f16e6 100644
--- a/cmd/app/assignee_test.go
+++ b/cmd/app/assignee_test.go
@@ -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
@@ -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)
diff --git a/cmd/app/attachment.go b/cmd/app/attachment.go
index b34ea23d..d67b1e89 100644
--- a/cmd/app/attachment.go
+++ b/cmd/app/attachment.go
@@ -8,7 +8,7 @@ import (
"net/http"
"os"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type FileReader interface {
@@ -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 {
@@ -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
diff --git a/cmd/app/attachment_test.go b/cmd/app/attachment_test.go
index bb2093ed..10988fda 100644
--- a/cmd/app/attachment_test.go
+++ b/cmd/app/attachment_test.go
@@ -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{}
diff --git a/cmd/app/client.go b/cmd/app/client.go
index c68bedad..30e9c827 100644
--- a/cmd/app/client.go
+++ b/cmd/app/client.go
@@ -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. */
@@ -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
}
diff --git a/cmd/app/comment.go b/cmd/app/comment.go
index ebc4a412..cdd88074 100644
--- a/cmd/app/comment.go
+++ b/cmd/app/comment.go
@@ -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 {
@@ -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 {
@@ -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"`
}
@@ -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"`
}
diff --git a/cmd/app/comment_helpers.go b/cmd/app/comment_helpers.go
index d6548bd5..05881da2 100644
--- a/cmd/app/comment_helpers.go
+++ b/cmd/app/comment_helpers.go
@@ -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. */
@@ -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"`
diff --git a/cmd/app/comment_test.go b/cmd/app/comment_test.go
index 2e933502..a10ef5fc 100644
--- a/cmd/app/comment_test.go
+++ b/cmd/app/comment_test.go
@@ -4,14 +4,14 @@ 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
@@ -19,7 +19,7 @@ func (f fakeCommentClient) CreateMergeRequestDiscussion(pid interface{}, mergeRe
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
@@ -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
diff --git a/cmd/app/config.go b/cmd/app/config.go
index 9d8bd0ac..eb2205f3 100644
--- a/cmd/app/config.go
+++ b/cmd/app/config.go
@@ -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"`
@@ -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
+}
diff --git a/cmd/app/create_mr.go b/cmd/app/create_mr.go
index 76985be9..80c0e135 100644
--- a/cmd/app/create_mr.go
+++ b/cmd/app/create_mr.go
@@ -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"`
}
diff --git a/cmd/app/create_mr_test.go b/cmd/app/create_mr_test.go
index f3c39155..a52db91f 100644
--- a/cmd/app/create_mr_test.go
+++ b/cmd/app/create_mr_test.go
@@ -4,7 +4,7 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeMergeCreatorClient struct {
diff --git a/cmd/app/draft_note_publisher.go b/cmd/app/draft_note_publisher.go
index 548c5ca2..8bf5b7ad 100644
--- a/cmd/app/draft_note_publisher.go
+++ b/cmd/app/draft_note_publisher.go
@@ -4,12 +4,12 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type DraftNotePublisher interface {
- PublishAllDraftNotes(pid interface{}, mergeRequest int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
- PublishDraftNote(pid interface{}, mergeRequest int, note int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
+ PublishAllDraftNotes(pid interface{}, mergeRequest int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
+ PublishDraftNote(pid interface{}, mergeRequest int64, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
}
type draftNotePublisherService struct {
@@ -18,7 +18,7 @@ type draftNotePublisherService struct {
}
type DraftNotePublishRequest struct {
- Note int `json:"note,omitempty"`
+ Note int64 `json:"note,omitempty"`
}
func (a draftNotePublisherService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
diff --git a/cmd/app/draft_note_publisher_test.go b/cmd/app/draft_note_publisher_test.go
index 0ebfa554..592a350a 100644
--- a/cmd/app/draft_note_publisher_test.go
+++ b/cmd/app/draft_note_publisher_test.go
@@ -4,17 +4,17 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeDraftNotePublisher struct {
testBase
}
-func (f fakeDraftNotePublisher) PublishAllDraftNotes(pid interface{}, mergeRequest int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
+func (f fakeDraftNotePublisher) PublishAllDraftNotes(pid interface{}, mergeRequest int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
return f.handleGitlabError()
}
-func (f fakeDraftNotePublisher) PublishDraftNote(pid interface{}, mergeRequest int, note int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
+func (f fakeDraftNotePublisher) PublishDraftNote(pid interface{}, mergeRequest int64, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
return f.handleGitlabError()
}
diff --git a/cmd/app/draft_notes.go b/cmd/app/draft_notes.go
index 4f550537..102dcba7 100644
--- a/cmd/app/draft_notes.go
+++ b/cmd/app/draft_notes.go
@@ -7,7 +7,7 @@ import (
"strconv"
"strings"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
/* The data coming from the client when creating a draft note is the same
@@ -29,10 +29,10 @@ func (draftNote DraftNoteWithPosition) GetPositionData() PositionData {
}
type DraftNoteManager interface {
- ListDraftNotes(pid interface{}, mergeRequest int, opt *gitlab.ListDraftNotesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.DraftNote, *gitlab.Response, error)
- CreateDraftNote(pid interface{}, mergeRequest int, opt *gitlab.CreateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error)
- DeleteDraftNote(pid interface{}, mergeRequest int, note int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
- UpdateDraftNote(pid interface{}, mergeRequest int, note int, opt *gitlab.UpdateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error)
+ ListDraftNotes(pid interface{}, mergeRequest int64, opt *gitlab.ListDraftNotesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.DraftNote, *gitlab.Response, error)
+ CreateDraftNote(pid interface{}, mergeRequest int64, opt *gitlab.CreateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error)
+ DeleteDraftNote(pid interface{}, mergeRequest int64, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
+ UpdateDraftNote(pid interface{}, mergeRequest int64, note int64, opt *gitlab.UpdateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error)
}
type draftNoteService struct {
@@ -139,7 +139,7 @@ func (a draftNoteService) postDraftNote(w http.ResponseWriter, r *http.Request)
/* deleteDraftNote deletes a draft note */
func (a draftNoteService) deleteDraftNote(w http.ResponseWriter, r *http.Request) {
suffix := strings.TrimPrefix(r.URL.Path, "/mr/draft_notes/")
- id, err := strconv.Atoi(suffix)
+ id, err := strconv.ParseInt(suffix, 10, 64)
if err != nil {
handleError(w, err, "Could not parse draft note ID", http.StatusBadRequest)
return
@@ -174,7 +174,7 @@ type UpdateDraftNoteRequest struct {
/* updateDraftNote edits the text of a draft comment */
func (a draftNoteService) updateDraftNote(w http.ResponseWriter, r *http.Request) {
suffix := strings.TrimPrefix(r.URL.Path, "/mr/draft_notes/")
- id, err := strconv.Atoi(suffix)
+ id, err := strconv.ParseInt(suffix, 10, 64)
if err != nil {
handleError(w, err, "Could not parse draft note ID", http.StatusBadRequest)
return
diff --git a/cmd/app/draft_notes_test.go b/cmd/app/draft_notes_test.go
index 8fe38da1..f92f1570 100644
--- a/cmd/app/draft_notes_test.go
+++ b/cmd/app/draft_notes_test.go
@@ -4,14 +4,14 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeDraftNoteManager struct {
testBase
}
-func (f fakeDraftNoteManager) ListDraftNotes(pid interface{}, mergeRequest int, opt *gitlab.ListDraftNotesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.DraftNote, *gitlab.Response, error) {
+func (f fakeDraftNoteManager) ListDraftNotes(pid interface{}, mergeRequest int64, opt *gitlab.ListDraftNotesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.DraftNote, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
@@ -19,7 +19,7 @@ func (f fakeDraftNoteManager) ListDraftNotes(pid interface{}, mergeRequest int,
return []*gitlab.DraftNote{}, resp, err
}
-func (f fakeDraftNoteManager) CreateDraftNote(pid interface{}, mergeRequest int, opt *gitlab.CreateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error) {
+func (f fakeDraftNoteManager) CreateDraftNote(pid interface{}, mergeRequest int64, opt *gitlab.CreateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
@@ -27,11 +27,11 @@ func (f fakeDraftNoteManager) CreateDraftNote(pid interface{}, mergeRequest int,
return &gitlab.DraftNote{}, resp, err
}
-func (f fakeDraftNoteManager) DeleteDraftNote(pid interface{}, mergeRequest int, note int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
+func (f fakeDraftNoteManager) DeleteDraftNote(pid interface{}, mergeRequest int64, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) {
return f.handleGitlabError()
}
-func (f fakeDraftNoteManager) UpdateDraftNote(pid interface{}, mergeRequest int, note int, opt *gitlab.UpdateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error) {
+func (f fakeDraftNoteManager) UpdateDraftNote(pid interface{}, mergeRequest int64, note int64, opt *gitlab.UpdateDraftNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.DraftNote, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/emoji.go b/cmd/app/emoji.go
index 5b2db76e..27e29188 100644
--- a/cmd/app/emoji.go
+++ b/cmd/app/emoji.go
@@ -11,7 +11,7 @@ import (
"strconv"
"strings"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type Emoji struct {
@@ -30,7 +30,7 @@ type EmojiMap map[string]Emoji
type CreateNoteEmojiPost struct {
Emoji string `json:"emoji"`
- NoteId int `json:"note_id"`
+ NoteId int64 `json:"note_id"`
}
type CreateEmojiResponse struct {
@@ -39,8 +39,8 @@ type CreateEmojiResponse struct {
}
type EmojiManager interface {
- DeleteMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int, noteID int, awardID int, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
- CreateMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int, noteID int, opt *gitlab.CreateAwardEmojiOptions, options ...gitlab.RequestOptionFunc) (*gitlab.AwardEmoji, *gitlab.Response, error)
+ DeleteMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int64, noteID int64, awardID int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
+ CreateMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int64, noteID int64, opt *gitlab.CreateAwardEmojiOptions, options ...gitlab.RequestOptionFunc) (*gitlab.AwardEmoji, *gitlab.Response, error)
}
type emojiService struct {
@@ -69,13 +69,13 @@ func (a emojiService) deleteEmojiFromNote(w http.ResponseWriter, r *http.Request
return
}
- noteId, err := strconv.Atoi(ids[0])
+ noteId, err := strconv.ParseInt(ids[0], 10, 64)
if err != nil {
handleError(w, err, "Could not convert note ID to integer", http.StatusBadRequest)
return
}
- awardableId, err := strconv.Atoi(ids[1])
+ awardableId, err := strconv.ParseInt(ids[1], 10, 64)
if err != nil {
handleError(w, err, "Could not convert awardable ID to integer", http.StatusBadRequest)
return
diff --git a/cmd/app/info.go b/cmd/app/info.go
index ea1321ae..b1387031 100644
--- a/cmd/app/info.go
+++ b/cmd/app/info.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type InfoResponse struct {
@@ -13,7 +13,7 @@ type InfoResponse struct {
}
type MergeRequestGetter interface {
- GetMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
+ GetMergeRequest(pid interface{}, mergeRequest int64, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
}
type infoService struct {
diff --git a/cmd/app/info_test.go b/cmd/app/info_test.go
index 66dd90af..82e78859 100644
--- a/cmd/app/info_test.go
+++ b/cmd/app/info_test.go
@@ -4,14 +4,14 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeMergeRequestGetter struct {
testBase
}
-func (f fakeMergeRequestGetter) GetMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
+func (f fakeMergeRequestGetter) GetMergeRequest(pid interface{}, mergeRequest int64, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/job.go b/cmd/app/job.go
index ce7436e8..d3ab63ed 100644
--- a/cmd/app/job.go
+++ b/cmd/app/job.go
@@ -6,11 +6,11 @@ import (
"io"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type JobTraceRequest struct {
- JobId int `json:"job_id" validate:"required"`
+ JobId int64 `json:"job_id" validate:"required"`
}
type JobTraceResponse struct {
@@ -19,7 +19,7 @@ type JobTraceResponse struct {
}
type TraceFileGetter interface {
- GetTraceFile(pid interface{}, jobID int, options ...gitlab.RequestOptionFunc) (*bytes.Reader, *gitlab.Response, error)
+ GetTraceFile(pid interface{}, jobID int64, options ...gitlab.RequestOptionFunc) (*bytes.Reader, *gitlab.Response, error)
}
type traceFileService struct {
diff --git a/cmd/app/job_test.go b/cmd/app/job_test.go
index 34ca0db8..3b30174c 100644
--- a/cmd/app/job_test.go
+++ b/cmd/app/job_test.go
@@ -7,7 +7,7 @@ import (
"net/http/httptest"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeTraceFileGetter struct {
@@ -26,7 +26,7 @@ func getTraceFileData(t *testing.T, svc http.Handler, request *http.Request) Job
return data
}
-func (f fakeTraceFileGetter) GetTraceFile(pid interface{}, jobID int, options ...gitlab.RequestOptionFunc) (*bytes.Reader, *gitlab.Response, error) {
+func (f fakeTraceFileGetter) GetTraceFile(pid interface{}, jobID int64, options ...gitlab.RequestOptionFunc) (*bytes.Reader, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/label.go b/cmd/app/label.go
index ca0ba426..957fbcdb 100644
--- a/cmd/app/label.go
+++ b/cmd/app/label.go
@@ -5,7 +5,7 @@ import (
"io"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type LabelUpdateRequest struct {
@@ -28,7 +28,7 @@ type LabelsRequestResponse struct {
}
type LabelManager interface {
- UpdateMergeRequest(interface{}, int, *gitlab.UpdateMergeRequestOptions, ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
+ UpdateMergeRequest(interface{}, int64, *gitlab.UpdateMergeRequestOptions, ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
ListLabels(interface{}, *gitlab.ListLabelsOptions, ...gitlab.RequestOptionFunc) ([]*gitlab.Label, *gitlab.Response, error)
}
diff --git a/cmd/app/list_discussions.go b/cmd/app/list_discussions.go
index 283c1d70..d0f3fe76 100644
--- a/cmd/app/list_discussions.go
+++ b/cmd/app/list_discussions.go
@@ -8,7 +8,7 @@ import (
"encoding/json"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
func Contains[T comparable](elems []T, v T) bool {
@@ -34,9 +34,9 @@ type DiscussionsRequest struct {
type DiscussionsResponse struct {
SuccessResponse
- Discussions []*gitlab.Discussion `json:"discussions"`
- UnlinkedDiscussions []*gitlab.Discussion `json:"unlinked_discussions"`
- Emojis map[int][]*gitlab.AwardEmoji `json:"emojis"`
+ Discussions []*gitlab.Discussion `json:"discussions"`
+ UnlinkedDiscussions []*gitlab.Discussion `json:"unlinked_discussions"`
+ Emojis map[int64][]*gitlab.AwardEmoji `json:"emojis"`
}
type SortableDiscussions struct {
@@ -66,8 +66,8 @@ func (d SortableDiscussions) Swap(i, j int) {
}
type DiscussionsLister interface {
- ListMergeRequestDiscussions(pid interface{}, mergeRequest int, opt *gitlab.ListMergeRequestDiscussionsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Discussion, *gitlab.Response, error)
- ListMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int, noteID int, opt *gitlab.ListAwardEmojiOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.AwardEmoji, *gitlab.Response, error)
+ ListMergeRequestDiscussions(pid interface{}, mergeRequest int64, opt *gitlab.ListMergeRequestDiscussionsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Discussion, *gitlab.Response, error)
+ ListMergeRequestAwardEmojiOnNote(pid any, mergeRequestIID int64, noteID int64, opt *gitlab.ListAwardEmojiOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.AwardEmoji, *gitlab.Response, error)
}
type discussionsListerService struct {
@@ -84,8 +84,10 @@ func (a discussionsListerService) ServeHTTP(w http.ResponseWriter, r *http.Reque
request := r.Context().Value(payload(payload("payload"))).(*DiscussionsRequest)
mergeRequestDiscussionOptions := gitlab.ListMergeRequestDiscussionsOptions{
- Page: 1,
- PerPage: 250,
+ ListOptions: gitlab.ListOptions{
+ Page: 1,
+ PerPage: 250,
+ },
}
discussions, res, err := a.client.ListMergeRequestDiscussions(a.projectInfo.ProjectId, a.projectInfo.MergeId, &mergeRequestDiscussionOptions)
@@ -121,7 +123,7 @@ func (a discussionsListerService) ServeHTTP(w http.ResponseWriter, r *http.Reque
}
/* Collect IDs in order to fetch emojis */
- var noteIds []int
+ var noteIds []int64
for _, discussion := range discussions {
for _, note := range discussion.Notes {
noteIds = append(noteIds, note.ID)
@@ -164,20 +166,20 @@ func (a discussionsListerService) ServeHTTP(w http.ResponseWriter, r *http.Reque
Fetches emojis for a set of notes and comments in parallel and returns a map of note IDs to their emojis.
Gitlab's API does not allow for fetching notes for an entire discussion thread so we have to do it per-note.
*/
-func (a discussionsListerService) fetchEmojisForNotesAndComments(noteIDs []int) (map[int][]*gitlab.AwardEmoji, error) {
+func (a discussionsListerService) fetchEmojisForNotesAndComments(noteIDs []int64) (map[int64][]*gitlab.AwardEmoji, error) {
var wg sync.WaitGroup
- emojis := make(map[int][]*gitlab.AwardEmoji)
+ emojis := make(map[int64][]*gitlab.AwardEmoji)
mu := &sync.Mutex{}
errs := make(chan error, len(noteIDs))
emojiChan := make(chan struct {
- noteID int
+ noteID int64
emojis []*gitlab.AwardEmoji
}, len(noteIDs))
for _, noteID := range noteIDs {
wg.Add(1)
- go func(noteID int) {
+ go func(noteID int64) {
defer wg.Done()
emojis, _, err := a.client.ListMergeRequestAwardEmojiOnNote(a.projectInfo.ProjectId, a.projectInfo.MergeId, noteID, &gitlab.ListAwardEmojiOptions{})
if err != nil {
@@ -185,7 +187,7 @@ func (a discussionsListerService) fetchEmojisForNotesAndComments(noteIDs []int)
return
}
emojiChan <- struct {
- noteID int
+ noteID int64
emojis []*gitlab.AwardEmoji
}{noteID, emojis}
}(noteID)
diff --git a/cmd/app/list_discussions_test.go b/cmd/app/list_discussions_test.go
index 661aaf77..5d43f1d9 100644
--- a/cmd/app/list_discussions_test.go
+++ b/cmd/app/list_discussions_test.go
@@ -8,7 +8,7 @@ import (
"testing"
"time"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeDiscussionsLister struct {
@@ -16,7 +16,7 @@ type fakeDiscussionsLister struct {
badEmojiResponse bool
}
-func (f fakeDiscussionsLister) ListMergeRequestDiscussions(pid interface{}, mergeRequest int, opt *gitlab.ListMergeRequestDiscussionsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Discussion, *gitlab.Response, error) {
+func (f fakeDiscussionsLister) ListMergeRequestDiscussions(pid interface{}, mergeRequest int64, opt *gitlab.ListMergeRequestDiscussionsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Discussion, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
@@ -30,34 +30,24 @@ func (f fakeDiscussionsLister) ListMergeRequestDiscussions(pid interface{}, merg
*timePointers[i] = timePointers[i-1].Add(time.Second * 100)
}
- type Author struct {
- ID int `json:"id"`
- Username string `json:"username"`
- Email string `json:"email"`
- Name string `json:"name"`
- State string `json:"state"`
- AvatarURL string `json:"avatar_url"`
- WebURL string `json:"web_url"`
- }
-
testListDiscussionsResponse := []*gitlab.Discussion{
{Notes: []*gitlab.Note{
- {CreatedAt: timePointers[0], Type: "DiffNote", Author: Author{Username: "hcramer0"}},
- {CreatedAt: timePointers[4], Type: "DiffNote", Author: Author{Username: "hcramer1"}},
+ {CreatedAt: timePointers[0], Type: "DiffNote", Author: gitlab.NoteAuthor{Username: "hcramer0"}},
+ {CreatedAt: timePointers[4], Type: "DiffNote", Author: gitlab.NoteAuthor{Username: "hcramer1"}},
}},
{Notes: []*gitlab.Note{
- {CreatedAt: timePointers[2], Type: "DiffNote", Author: Author{Username: "hcramer2"}},
- {CreatedAt: timePointers[3], Type: "DiffNote", Author: Author{Username: "hcramer3"}},
+ {CreatedAt: timePointers[2], Type: "DiffNote", Author: gitlab.NoteAuthor{Username: "hcramer2"}},
+ {CreatedAt: timePointers[3], Type: "DiffNote", Author: gitlab.NoteAuthor{Username: "hcramer3"}},
}},
{Notes: []*gitlab.Note{
- {CreatedAt: timePointers[1], Type: "DiffNote", Author: Author{Username: "hcramer4"}},
- {CreatedAt: timePointers[5], Type: "DiffNote", Author: Author{Username: "hcramer5"}},
+ {CreatedAt: timePointers[1], Type: "DiffNote", Author: gitlab.NoteAuthor{Username: "hcramer4"}},
+ {CreatedAt: timePointers[5], Type: "DiffNote", Author: gitlab.NoteAuthor{Username: "hcramer5"}},
}},
}
return testListDiscussionsResponse, resp, err
}
-func (f fakeDiscussionsLister) ListMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int, noteID int, opt *gitlab.ListAwardEmojiOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.AwardEmoji, *gitlab.Response, error) {
+func (f fakeDiscussionsLister) ListMergeRequestAwardEmojiOnNote(pid interface{}, mergeRequestIID int64, noteID int64, opt *gitlab.ListAwardEmojiOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.AwardEmoji, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/members.go b/cmd/app/members.go
index d8293a4a..44bc8313 100644
--- a/cmd/app/members.go
+++ b/cmd/app/members.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type ProjectMembersResponse struct {
diff --git a/cmd/app/members_test.go b/cmd/app/members_test.go
index e641b1ce..f1d6944e 100644
--- a/cmd/app/members_test.go
+++ b/cmd/app/members_test.go
@@ -4,7 +4,7 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeMemberLister struct {
diff --git a/cmd/app/merge_mr.go b/cmd/app/merge_mr.go
index 872ac548..f4f2e878 100644
--- a/cmd/app/merge_mr.go
+++ b/cmd/app/merge_mr.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type AcceptMergeRequestRequest struct {
@@ -14,7 +14,7 @@ type AcceptMergeRequestRequest struct {
}
type MergeRequestAccepter interface {
- AcceptMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.AcceptMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
+ AcceptMergeRequest(pid interface{}, mergeRequest int64, opt *gitlab.AcceptMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
}
type mergeRequestAccepterService struct {
diff --git a/cmd/app/merge_mr_test.go b/cmd/app/merge_mr_test.go
index 332f94db..08f4d640 100644
--- a/cmd/app/merge_mr_test.go
+++ b/cmd/app/merge_mr_test.go
@@ -4,14 +4,14 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeMergeRequestAccepter struct {
testBase
}
-func (f fakeMergeRequestAccepter) AcceptMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.AcceptMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
+func (f fakeMergeRequestAccepter) AcceptMergeRequest(pid interface{}, mergeRequest int64, opt *gitlab.AcceptMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/merge_requests.go b/cmd/app/merge_requests.go
index 7f1510e7..86f697cd 100644
--- a/cmd/app/merge_requests.go
+++ b/cmd/app/merge_requests.go
@@ -5,16 +5,16 @@ import (
"errors"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type ListMergeRequestResponse struct {
SuccessResponse
- MergeRequests []*gitlab.MergeRequest `json:"merge_requests"`
+ MergeRequests []*gitlab.BasicMergeRequest `json:"merge_requests"`
}
type MergeRequestLister interface {
- ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequest, *gitlab.Response, error)
+ ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.BasicMergeRequest, *gitlab.Response, error)
}
type mergeRequestListerService struct {
diff --git a/cmd/app/merge_requests_by_username.go b/cmd/app/merge_requests_by_username.go
index 4a097566..8a9c85e2 100644
--- a/cmd/app/merge_requests_by_username.go
+++ b/cmd/app/merge_requests_by_username.go
@@ -7,11 +7,11 @@ import (
"net/http"
"sync"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type MergeRequestListerByUsername interface {
- ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequest, *gitlab.Response, error)
+ ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.BasicMergeRequest, *gitlab.Response, error)
}
type mergeRequestListerByUsernameService struct {
@@ -53,7 +53,7 @@ func (a mergeRequestListerByUsernameService) ServeHTTP(w http.ResponseWriter, r
}
type apiResponse struct {
- mrs []*gitlab.MergeRequest
+ mrs []*gitlab.BasicMergeRequest
err error
}
@@ -73,8 +73,8 @@ func (a mergeRequestListerByUsernameService) ServeHTTP(w http.ResponseWriter, r
}(payload)
}
- var mergeRequests []*gitlab.MergeRequest
- existingIds := make(map[int]bool)
+ var mergeRequests []*gitlab.BasicMergeRequest
+ existingIds := make(map[int64]bool)
var errs []error
for res := range mrChan {
if res.err != nil {
@@ -115,14 +115,14 @@ func (a mergeRequestListerByUsernameService) ServeHTTP(w http.ResponseWriter, r
}
}
-func (a mergeRequestListerByUsernameService) getMrs(payload *gitlab.ListProjectMergeRequestsOptions) ([]*gitlab.MergeRequest, error) {
+func (a mergeRequestListerByUsernameService) getMrs(payload *gitlab.ListProjectMergeRequestsOptions) ([]*gitlab.BasicMergeRequest, error) {
mrs, res, err := a.client.ListProjectMergeRequests(a.projectInfo.ProjectId, payload)
if err != nil {
- return []*gitlab.MergeRequest{}, err
+ return []*gitlab.BasicMergeRequest{}, err
}
if res.StatusCode >= 300 {
- return []*gitlab.MergeRequest{}, GenericError{endpoint: "/merge_requests_by_username"}
+ return []*gitlab.BasicMergeRequest{}, GenericError{endpoint: "/merge_requests_by_username"}
}
defer res.Body.Close()
diff --git a/cmd/app/merge_requests_by_username_test.go b/cmd/app/merge_requests_by_username_test.go
index fb3aa847..b324d92c 100644
--- a/cmd/app/merge_requests_by_username_test.go
+++ b/cmd/app/merge_requests_by_username_test.go
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeMergeRequestListerByUsername struct {
@@ -13,17 +13,17 @@ type fakeMergeRequestListerByUsername struct {
emptyResponse bool
}
-func (f fakeMergeRequestListerByUsername) ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequest, *gitlab.Response, error) {
+func (f fakeMergeRequestListerByUsername) ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.BasicMergeRequest, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
}
if f.emptyResponse {
- return []*gitlab.MergeRequest{}, resp, err
+ return []*gitlab.BasicMergeRequest{}, resp, err
}
- return []*gitlab.MergeRequest{{IID: 10}}, resp, err
+ return []*gitlab.BasicMergeRequest{{IID: 10}}, resp, err
}
func TestListMergeRequestByUsername(t *testing.T) {
diff --git a/cmd/app/merge_requests_test.go b/cmd/app/merge_requests_test.go
index 29762cf4..1170c6d0 100644
--- a/cmd/app/merge_requests_test.go
+++ b/cmd/app/merge_requests_test.go
@@ -4,7 +4,7 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeMergeRequestLister struct {
@@ -13,21 +13,21 @@ type fakeMergeRequestLister struct {
multipleMrs bool
}
-func (f fakeMergeRequestLister) ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequest, *gitlab.Response, error) {
+func (f fakeMergeRequestLister) ListProjectMergeRequests(pid interface{}, opt *gitlab.ListProjectMergeRequestsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.BasicMergeRequest, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
}
if f.emptyResponse {
- return []*gitlab.MergeRequest{}, resp, err
+ return []*gitlab.BasicMergeRequest{}, resp, err
}
if f.multipleMrs {
- return []*gitlab.MergeRequest{{IID: 10}, {IID: 11}}, resp, err
+ return []*gitlab.BasicMergeRequest{{IID: 10}, {IID: 11}}, resp, err
}
- return []*gitlab.MergeRequest{{IID: 10}}, resp, err
+ return []*gitlab.BasicMergeRequest{{IID: 10}}, resp, err
}
func TestMergeRequestHandler(t *testing.T) {
diff --git a/cmd/app/middleware.go b/cmd/app/middleware.go
index ec5c534a..1ea4b0c8 100644
--- a/cmd/app/middleware.go
+++ b/cmd/app/middleware.go
@@ -10,7 +10,7 @@ import (
"strings"
"github.com/go-playground/validator/v10"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type mw func(http.Handler) http.Handler
@@ -108,7 +108,7 @@ func (m withMrMiddleware) handle(next http.Handler) http.Handler {
}
if pluginOptions.ChosenMrIID != 0 {
- options.IIDs = gitlab.Ptr([]int{pluginOptions.ChosenMrIID})
+ options.IIDs = gitlab.Ptr([]int64{pluginOptions.ChosenMrIID})
}
mergeRequests, _, err := m.client.ListProjectMergeRequests(m.data.projectInfo.ProjectId, &options)
diff --git a/cmd/app/pipeline.go b/cmd/app/pipeline.go
index 9cf90c61..24fb6935 100644
--- a/cmd/app/pipeline.go
+++ b/cmd/app/pipeline.go
@@ -9,7 +9,7 @@ import (
"strings"
"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type RetriggerPipelineResponse struct {
@@ -30,9 +30,9 @@ type GetPipelineAndJobsResponse struct {
type PipelineManager interface {
ListProjectPipelines(pid interface{}, opt *gitlab.ListProjectPipelinesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.PipelineInfo, *gitlab.Response, error)
- ListPipelineJobs(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Job, *gitlab.Response, error)
- ListPipelineBridges(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Bridge, *gitlab.Response, error)
- RetryPipelineBuild(pid interface{}, pipeline int, options ...gitlab.RequestOptionFunc) (*gitlab.Pipeline, *gitlab.Response, error)
+ ListPipelineJobs(pid interface{}, pipelineID int64, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Job, *gitlab.Response, error)
+ ListPipelineBridges(pid interface{}, pipelineID int64, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Bridge, *gitlab.Response, error)
+ RetryPipelineBuild(pid interface{}, pipeline int64, options ...gitlab.RequestOptionFunc) (*gitlab.Pipeline, *gitlab.Response, error)
}
type pipelineService struct {
@@ -171,7 +171,7 @@ func (a pipelineService) RetriggerPipeline(w http.ResponseWriter, r *http.Reques
id := strings.TrimPrefix(r.URL.Path, "/pipeline/trigger/")
- idInt, err := strconv.Atoi(id)
+ idInt, err := strconv.ParseInt(id, 10, 64)
if err != nil {
handleError(w, err, "Could not convert pipeline ID to integer", http.StatusBadRequest)
return
diff --git a/cmd/app/pipeline_test.go b/cmd/app/pipeline_test.go
index ba090423..d1cdb651 100644
--- a/cmd/app/pipeline_test.go
+++ b/cmd/app/pipeline_test.go
@@ -4,7 +4,7 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakePipelineManager struct {
@@ -19,7 +19,7 @@ func (f fakePipelineManager) ListProjectPipelines(pid interface{}, opt *gitlab.L
return []*gitlab.PipelineInfo{{ID: 1234}}, resp, err
}
-func (f fakePipelineManager) ListPipelineJobs(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Job, *gitlab.Response, error) {
+func (f fakePipelineManager) ListPipelineJobs(pid interface{}, pipelineID int64, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Job, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
@@ -27,7 +27,7 @@ func (f fakePipelineManager) ListPipelineJobs(pid interface{}, pipelineID int, o
return []*gitlab.Job{}, resp, err
}
-func (f fakePipelineManager) ListPipelineBridges(pid interface{}, pipelineID int, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Bridge, *gitlab.Response, error) {
+func (f fakePipelineManager) ListPipelineBridges(pid interface{}, pipelineID int64, opts *gitlab.ListJobsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Bridge, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
@@ -35,7 +35,7 @@ func (f fakePipelineManager) ListPipelineBridges(pid interface{}, pipelineID int
return []*gitlab.Bridge{}, resp, err
}
-func (f fakePipelineManager) RetryPipelineBuild(pid interface{}, pipeline int, options ...gitlab.RequestOptionFunc) (*gitlab.Pipeline, *gitlab.Response, error) {
+func (f fakePipelineManager) RetryPipelineBuild(pid interface{}, pipeline int64, options ...gitlab.RequestOptionFunc) (*gitlab.Pipeline, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/reply.go b/cmd/app/reply.go
index 38deed86..26fa288d 100644
--- a/cmd/app/reply.go
+++ b/cmd/app/reply.go
@@ -5,7 +5,7 @@ import (
"net/http"
"time"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type ReplyRequest struct {
@@ -20,7 +20,7 @@ type ReplyResponse struct {
}
type ReplyManager interface {
- AddMergeRequestDiscussionNote(interface{}, int, string, *gitlab.AddMergeRequestDiscussionNoteOptions, ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)
+ AddMergeRequestDiscussionNote(interface{}, int64, string, *gitlab.AddMergeRequestDiscussionNoteOptions, ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)
}
type replyService struct {
diff --git a/cmd/app/reply_test.go b/cmd/app/reply_test.go
index 4234711c..23901fdb 100644
--- a/cmd/app/reply_test.go
+++ b/cmd/app/reply_test.go
@@ -4,14 +4,14 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeReplyManager struct {
testBase
}
-func (f fakeReplyManager) AddMergeRequestDiscussionNote(interface{}, int, string, *gitlab.AddMergeRequestDiscussionNoteOptions, ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error) {
+func (f fakeReplyManager) AddMergeRequestDiscussionNote(interface{}, int64, string, *gitlab.AddMergeRequestDiscussionNoteOptions, ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/resolve_discussion.go b/cmd/app/resolve_discussion.go
index 2b55acc0..152140f8 100644
--- a/cmd/app/resolve_discussion.go
+++ b/cmd/app/resolve_discussion.go
@@ -5,11 +5,11 @@ import (
"fmt"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type DiscussionResolver interface {
- ResolveMergeRequestDiscussion(pid interface{}, mergeRequest int, discussion string, opt *gitlab.ResolveMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error)
+ ResolveMergeRequestDiscussion(pid interface{}, mergeRequest int64, discussion string, opt *gitlab.ResolveMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error)
}
type discussionsResolutionService struct {
diff --git a/cmd/app/resolve_discussion_test.go b/cmd/app/resolve_discussion_test.go
index 24b04ddd..e4912fac 100644
--- a/cmd/app/resolve_discussion_test.go
+++ b/cmd/app/resolve_discussion_test.go
@@ -4,14 +4,14 @@ import (
"net/http"
"testing"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type fakeDiscussionResolver struct {
testBase
}
-func (f fakeDiscussionResolver) ResolveMergeRequestDiscussion(pid interface{}, mergeRequest int, discussion string, opt *gitlab.ResolveMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error) {
+func (f fakeDiscussionResolver) ResolveMergeRequestDiscussion(pid interface{}, mergeRequest int64, discussion string, opt *gitlab.ResolveMergeRequestDiscussionOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Discussion, *gitlab.Response, error) {
resp, err := f.handleGitlabError()
if err != nil {
return nil, nil, err
diff --git a/cmd/app/reviewer.go b/cmd/app/reviewer.go
index 7b98bdee..169b3f50 100644
--- a/cmd/app/reviewer.go
+++ b/cmd/app/reviewer.go
@@ -4,11 +4,11 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type ReviewerUpdateRequest struct {
- Ids []int `json:"ids" validate:"required"`
+ Ids []int64 `json:"ids" validate:"required"`
}
type ReviewerUpdateResponse struct {
@@ -22,7 +22,7 @@ type ReviewersRequestResponse struct {
}
type MergeRequestUpdater interface {
- UpdateMergeRequest(pid interface{}, mergeRequest int, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
+ UpdateMergeRequest(pid interface{}, mergeRequest int64, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
}
type reviewerService struct {
diff --git a/cmd/app/revisions.go b/cmd/app/revisions.go
index 16e68226..956e87d1 100644
--- a/cmd/app/revisions.go
+++ b/cmd/app/revisions.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type RevisionsResponse struct {
@@ -13,7 +13,7 @@ type RevisionsResponse struct {
}
type RevisionsGetter interface {
- GetMergeRequestDiffVersions(pid interface{}, mergeRequest int, opt *gitlab.GetMergeRequestDiffVersionsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequestDiffVersion, *gitlab.Response, error)
+ GetMergeRequestDiffVersions(pid interface{}, mergeRequest int64, opt *gitlab.GetMergeRequestDiffVersionsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequestDiffVersion, *gitlab.Response, error)
}
type revisionsService struct {
diff --git a/cmd/app/revoke.go b/cmd/app/revoke.go
index ae45f805..1e4f037a 100644
--- a/cmd/app/revoke.go
+++ b/cmd/app/revoke.go
@@ -4,11 +4,11 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type MergeRequestRevoker interface {
- UnapproveMergeRequest(interface{}, int, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
+ UnapproveMergeRequest(interface{}, int64, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)
}
type mergeRequestRevokerService struct {
diff --git a/cmd/app/server.go b/cmd/app/server.go
index c0b1af63..5fff24ed 100644
--- a/cmd/app/server.go
+++ b/cmd/app/server.go
@@ -9,7 +9,7 @@ import (
"time"
"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
/*
@@ -89,7 +89,7 @@ func CreateRouter(gitlabClient *Client, projectInfo *ProjectInfo, s *shutdownSer
if os.Getenv("DEBUG") != "" {
// TODO: We have some JSON files (emojis.json) we import relative to the binary in production and
// expect to break during debugging, do not throw when that occurs.
- fmt.Fprintf(os.Stdout, "Issue occured setting up router: %s\n", err)
+ _, _ = fmt.Fprintf(os.Stdout, "Issue occured setting up router: %s\n", err)
} else {
panic(err)
}
@@ -241,7 +241,22 @@ func CreateRouter(gitlabClient *Client, projectInfo *ProjectInfo, s *shutdownSer
m.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
- fmt.Fprintln(w, "pong")
+ _, _ = fmt.Fprintln(w, "pong")
+ })
+
+ m.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ _, _ = fmt.Fprintf(w, `{"version":"%s"}`, version)
+ })
+
+ // Default 404 handler
+ m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/" {
+ handleError(w, fmt.Errorf("endpoint %s does not exist", r.URL.Path), "Not found", http.StatusNotFound)
+ return
+ }
+ w.WriteHeader(http.StatusOK)
})
return LoggingServer{handler: m}
diff --git a/cmd/app/summary.go b/cmd/app/summary.go
index a345135c..8d7640a6 100644
--- a/cmd/app/summary.go
+++ b/cmd/app/summary.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type SummaryUpdateRequest struct {
diff --git a/cmd/app/test_helpers.go b/cmd/app/test_helpers.go
index 2c3e1bf8..2839f77b 100644
--- a/cmd/app/test_helpers.go
+++ b/cmd/app/test_helpers.go
@@ -11,7 +11,7 @@ import (
"testing"
"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
var errorFromGitlab = errors.New("some error from Gitlab")
diff --git a/cmd/app/user.go b/cmd/app/user.go
index da31a9ac..f627a533 100644
--- a/cmd/app/user.go
+++ b/cmd/app/user.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
- "github.com/xanzy/go-gitlab"
+ gitlab "gitlab.com/gitlab-org/api/client-go"
)
type UserResponse struct {
diff --git a/cmd/main.go b/cmd/main.go
index 0bfb652d..3aae8dbe 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -10,6 +10,7 @@ import (
)
var pluginOptions app.PluginOptions
+var Version = "unknown" // Set via ldflags
func main() {
log.SetFlags(0)
@@ -20,6 +21,7 @@ func main() {
err := json.Unmarshal([]byte(os.Args[1]), &pluginOptions)
app.SetPluginOptions(pluginOptions)
+ app.SetVersion(Version)
if err != nil {
log.Fatalf("Failure parsing plugin settings: %v", err)
diff --git a/go.mod b/go.mod
index e16b85bd..7f3baea8 100644
--- a/go.mod
+++ b/go.mod
@@ -1,27 +1,25 @@
module github.com/harrisoncramer/gitlab.nvim
-go 1.19
+go 1.25.1
require (
github.com/go-playground/validator/v10 v10.22.1
- github.com/hashicorp/go-retryablehttp v0.7.7
- github.com/xanzy/go-gitlab v0.108.0
+ github.com/hashicorp/go-retryablehttp v0.7.8
+ gitlab.com/gitlab-org/api/client-go v1.17.0
)
require (
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
- github.com/golang/protobuf v1.5.3 // indirect
- github.com/google/go-querystring v1.1.0 // indirect
+ github.com/google/go-cmp v0.7.0 // indirect
+ github.com/google/go-querystring v1.2.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
- golang.org/x/oauth2 v0.6.0 // indirect
- golang.org/x/sys v0.20.0 // indirect
- golang.org/x/text v0.14.0 // indirect
- golang.org/x/time v0.3.0 // indirect
- google.golang.org/appengine v1.6.7 // indirect
- google.golang.org/protobuf v1.29.1 // indirect
+ golang.org/x/oauth2 v0.34.0 // indirect
+ golang.org/x/sys v0.39.0 // indirect
+ golang.org/x/text v0.32.0 // indirect
+ golang.org/x/time v0.14.0 // indirect
)
diff --git a/go.sum b/go.sum
index 5df86b54..78350d05 100644
--- a/go.sum
+++ b/go.sum
@@ -1,59 +1,51 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
+github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
+github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
-github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
-github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
-github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
-github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
-github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
+github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
+github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0=
+github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
-github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
-github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
+github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
+github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48=
+github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
-github.com/xanzy/go-gitlab v0.108.0 h1:IEvEUWFR5G1seslRhJ8gC//INiIUqYXuSUoBd7/gFKE=
-github.com/xanzy/go-gitlab v0.108.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
+github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+gitlab.com/gitlab-org/api/client-go v1.17.0 h1:4aVMqYyJONZXWHoH78wzhIMzWkzwqJ8cEPhJRQnUPFI=
+gitlab.com/gitlab-org/api/client-go v1.17.0/go.mod h1:ctGKgv9bErQHO0NOrfhoyFtKMAkBhUE7y53F2xHFAkE=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
-golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
-golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw=
-golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
-golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
-golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
-golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
-golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
-google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
-google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM=
-google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
+golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
+golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
+golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
+golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
+golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
+golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
+golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/lua/gitlab/async.lua b/lua/gitlab/async.lua
index f3acbe26..36905f62 100644
--- a/lua/gitlab/async.lua
+++ b/lua/gitlab/async.lua
@@ -63,8 +63,7 @@ M.sequence = function(dependencies, cb)
end
-- Otherwise, start the go server and start fetching the values
- server.start(function()
- state.go_server_running = true
+ server.build_and_start(function()
handler:fetch(dependencies, 1, argTable)
end)
end
diff --git a/lua/gitlab/health.lua b/lua/gitlab/health.lua
index eca1bf58..fe884aee 100644
--- a/lua/gitlab/health.lua
+++ b/lua/gitlab/health.lua
@@ -6,14 +6,14 @@ local M = {}
local function check_go_version()
local go_version = io.popen("go version"):read("*a")
if go_version then
- local major, minor, _ = go_version:match("(%d+)%.(%d+)%.(%d+)")
- if major and tonumber(major) >= 1 and tonumber(minor) >= 19 then
+ local major, minor, _ = go_version:match("(%d+)%.(%d+)%.?(%d*)")
+ if major and tonumber(major) >= 1 and tonumber(minor) >= 25 then
return
else
- return "Go is installed, but version is older than 1.19."
+ return "Go is installed, but version is older than 1.25.1. Please upgrade Go: https://go.dev/dl/"
end
else
- return "Go is not installed."
+ return "Go is not installed. Please install Go >= 1.25.1: https://go.dev/dl/"
end
end
diff --git a/lua/gitlab/init.lua b/lua/gitlab/init.lua
index f17c6320..5f07738f 100644
--- a/lua/gitlab/init.lua
+++ b/lua/gitlab/init.lua
@@ -36,6 +36,23 @@ local function setup(args)
if args == nil then
args = {}
end
+
+ local go_version = io.popen("go version"):read("*a")
+ if go_version then
+ local version = go_version:match("%d+%.%d+%.?%d*")
+ local major, minor, _ = go_version:match("(%d+)%.(%d+)%.?(%d*)")
+ if not (major and tonumber(major) >= 1 and tonumber(minor) >= 25) then
+ u.notify(string.format("Needs Go >= 1.25.1, you are on %s", version), vim.log.levels.ERROR)
+ return
+ end
+ else
+ u.notify(
+ "gitlab.nvim requires Go >= 1.25.1, but Go is not installed. Please install Go: https://go.dev/dl/",
+ vim.log.levels.ERROR
+ )
+ return
+ end
+
server.build() -- Builds the Go binary if it doesn't exist
state.merge_settings(args) -- Merges user settings with default settings
state.set_global_keymaps() -- Sets keymaps that are not bound to a specific buffer
diff --git a/lua/gitlab/job.lua b/lua/gitlab/job.lua
index bccd8062..128591be 100644
--- a/lua/gitlab/job.lua
+++ b/lua/gitlab/job.lua
@@ -4,7 +4,7 @@ local Job = require("plenary.job")
local u = require("gitlab.utils")
local M = {}
-M.run_job = function(endpoint, method, body, callback, on_error_callback)
+M.run_job = function(endpoint, method, body, callback)
local state = require("gitlab.state")
local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s", state.settings.port) .. endpoint }
@@ -16,10 +16,8 @@ M.run_job = function(endpoint, method, body, callback, on_error_callback)
-- This handler will handle all responses from the Go server. Anything with a successful
-- status will call the callback (if it is supplied for the job). Otherwise, it will print out the
- -- success message or error message and details from the Go server and run the on_error_callback
- -- (if supplied for the job).
+ -- success message or error message and details from the Go server.
local stderr = {}
-
Job:new({
command = "curl",
args = args,
@@ -55,9 +53,6 @@ M.run_job = function(endpoint, method, body, callback, on_error_callback)
-- Handle error case
local message = string.format("%s: %s", data.message, data.details)
u.notify(message, vim.log.levels.ERROR)
- if on_error_callback then
- on_error_callback(data)
- end
end
end, 0)
end,
diff --git a/lua/gitlab/server.lua b/lua/gitlab/server.lua
index 094100a1..d9ff6305 100644
--- a/lua/gitlab/server.lua
+++ b/lua/gitlab/server.lua
@@ -5,8 +5,29 @@ local List = require("gitlab.utils.list")
local state = require("gitlab.state")
local u = require("gitlab.utils")
local job = require("gitlab.job")
+local Job = require("plenary.job")
local M = {}
+-- Builds the binary if it doesn't exist, and starts the server. If the pre-existing binary has an older
+-- tag than the Lua code (exposed via the /version endpoint) then shuts down the server, rebuilds it, and
+-- restarts the server again.
+M.build_and_start = function(callback)
+ M.build(false)
+ M.start(function()
+ M.get_version(function(version)
+ if version.plugin_version ~= version.binary_version then
+ M.shutdown(function()
+ if M.build(true) then
+ M.start(callback)
+ end
+ end)
+ else
+ callback()
+ end
+ end)
+ end)
+end
+
-- Starts the Go server and call the callback provided
M.start = function(callback)
local port = tonumber(state.settings.port) or 0
@@ -50,6 +71,7 @@ M.start = function(callback)
-- Make sure that this actually check if port was correctly parsed based on server output
-- because server outputs port only if it started successfully.
if parsed_port ~= nil and not callback_called then
+ state.go_server_running = true
callback()
callback_called = true
end
@@ -80,7 +102,7 @@ M.start = function(callback)
end
end
--- Builds the Go binary
+-- Builds the Go binary with the current Git tag.
M.build = function(override)
local file_path = u.current_file_path()
local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
@@ -96,8 +118,15 @@ M.build = function(override)
end
end
+ local version_output = vim.system({ "git", "describe", "--tags", "--always" }, { cwd = parent_dir }):wait()
+ local version = version_output.code == 0 and vim.trim(version_output.stdout) or "unknown"
+
+ local ldflags = string.format("-X main.Version=%s", version)
local res = vim
- .system({ "go", "build", "-o", bin_name }, { cwd = state.settings.root_path .. u.path_separator .. "cmd" })
+ .system(
+ { "go", "build", "-ldflags", ldflags, "-o", bin_name },
+ { cwd = state.settings.root_path .. u.path_separator .. "cmd" }
+ )
:wait()
if res.code ~= 0 then
@@ -134,7 +163,6 @@ M.restart = function(cb)
job.run_job("/shutdown", "POST", { restart = true }, function(data)
state.go_server_running = false
M.start(function()
- state.go_server_running = true
state.clear_data()
if cb then
cb()
@@ -145,4 +173,44 @@ M.restart = function(cb)
end)
end
+-- Returns the version (git tag) that was baked into the binary when it was last built
+M.get_version = function(callback)
+ if not state.go_server_running then
+ u.notify("Gitlab server not running", vim.log.levels.ERROR)
+ return nil
+ end
+ local file_path = u.current_file_path()
+ local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
+
+ local version_output = vim.system({ "git", "describe", "--tags", "--always" }, { cwd = parent_dir }):wait()
+ local plugin_version = version_output.code == 0 and vim.trim(version_output.stdout) or "unknown"
+
+ local args = { "-s", "-X", "GET", string.format("localhost:%s/version", state.settings.port) }
+
+ -- We call the "/version" endpoint here instead of through the regular jobs pattern because earlier versions of the plugin
+ -- may not have it. We handle a 404 as an "unknown" version error.
+ Job:new({
+ command = "curl",
+ args = args,
+ on_stdout = function(_, output)
+ vim.defer_fn(function()
+ if output == nil then
+ callback({ plugin_version = plugin_version, binary_version = "unknown" })
+ return
+ end
+
+ local data_ok, data = pcall(vim.json.decode, output)
+ if not data_ok or data == nil or data.version == nil then
+ callback({ plugin_version = plugin_version, binary_version = "unknown" })
+ return
+ end
+
+ callback({ plugin_version = plugin_version, binary_version = data.version })
+ end, 0)
+ end,
+ on_stderr = function() end,
+ on_exit = function() end,
+ }):start()
+end
+
return M