diff --git a/Makefile b/Makefile index 6339f9f2..0752a405 100644 --- a/Makefile +++ b/Makefile @@ -158,7 +158,7 @@ apply: ## Install go tools install-go-tools: @echo Installing go tools - $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1 + $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0 $(GO) install gotest.tools/gotestsum@v1.7.0 ## Runs eslint and golangci-lint diff --git a/build/custom.mk b/build/custom.mk index 0f21ad28..eb42a39d 100644 --- a/build/custom.mk +++ b/build/custom.mk @@ -12,7 +12,7 @@ GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost/server/public/p .PHONY: mock mock: ifneq ($(HAS_SERVER),) - go install github.com/golang/mock/mockgen@v1.6.0 + go get go.uber.org/mock/mockgen mockgen -destination server/mocks/mock_gitlab.go github.com/mattermost/mattermost-plugin-gitlab/server/gitlab Gitlab mockgen -destination server/gitlab/mocks/mock_gitlab.go github.com/mattermost/mattermost-plugin-gitlab/server/gitlab Gitlab endif diff --git a/go.mod b/go.mod index ceda4b0d..309a51f6 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.22 toolchain go1.22.8 require ( - github.com/golang/mock v1.6.0 github.com/gorilla/mux v1.8.1 github.com/hashicorp/go-multierror v1.1.1 github.com/mattermost/mattermost/server/public v0.1.8 @@ -13,6 +12,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 github.com/xanzy/go-gitlab v0.97.0 + go.uber.org/mock v0.4.0 golang.org/x/oauth2 v0.21.0 golang.org/x/sync v0.7.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 26e8445a..ebafc54a 100644 --- a/go.sum +++ b/go.sum @@ -225,21 +225,20 @@ github.com/xanzy/go-gitlab v0.97.0 h1:StMqJ1Kvt00X43pYIBBjj52dFlghwSeBhRDRfzaZ7x github.com/xanzy/go-gitlab v0.97.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI= github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g= github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -248,9 +247,6 @@ golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= @@ -265,8 +261,6 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -274,12 +268,8 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -290,11 +280,9 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= @@ -307,12 +295,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= diff --git a/server/command_test.go b/server/command_test.go index 97ea30f1..41ebb208 100644 --- a/server/command_test.go +++ b/server/command_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "testing" - "github.com/golang/mock/gomock" "github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/plugin/plugintest" "github.com/mattermost/mattermost/server/public/pluginapi" @@ -14,6 +13,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" gitLabAPI "github.com/xanzy/go-gitlab" + "go.uber.org/mock/gomock" "github.com/mattermost/mattermost-plugin-gitlab/server/gitlab" mocks "github.com/mattermost/mattermost-plugin-gitlab/server/gitlab/mocks" diff --git a/server/gitlab/api.go b/server/gitlab/api.go index e18eadc8..ee06e6a2 100644 --- a/server/gitlab/api.go +++ b/server/gitlab/api.go @@ -17,8 +17,9 @@ import ( ) const ( - stateOpened = "opened" - scopeAll = "all" + stateOpened = "opened" + scopeAll = "all" + getLabelsTrue = true perPage = 20 ) @@ -48,19 +49,19 @@ type PRDetails struct { type MergeRequest struct { *internGitlab.MergeRequest - LabelsWithDetails []*internGitlab.Label `json:"labels_with_details,omitempty"` + LabelsWithDetails []*internGitlab.Label `json:"label_details,omitempty"` } type Issue struct { *internGitlab.Issue - LabelsWithDetails []*internGitlab.Label `json:"labels_with_details,omitempty"` + LabelsWithDetails []*internGitlab.Label `json:"label_details,omitempty"` } type LHSContent struct { - AssignedPRs []*MergeRequest `json:"yourAssignedPrs"` - Reviews []*MergeRequest `json:"reviews"` - AssignedIssues []*Issue `json:"yourAssignedIssues"` - Todos []*internGitlab.Todo `json:"todos"` + AssignedPRs []*internGitlab.MergeRequest `json:"yourAssignedPrs"` + Reviews []*internGitlab.MergeRequest `json:"reviews"` + AssignedIssues []*internGitlab.Issue `json:"yourAssignedIssues"` + Todos []*internGitlab.Todo `json:"todos"` } // NewGroupHook creates a webhook associated with a GitLab group @@ -313,19 +314,19 @@ func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.T grp, ctx := errgroup.WithContext(ctx) - var reviews []*MergeRequest + var reviews []*internGitlab.MergeRequest grp.Go(func() error { reviews, err = g.GetReviews(ctx, user, client) return err }) - var issues []*Issue + var issues []*internGitlab.Issue grp.Go(func() error { issues, err = g.GetYourAssignedIssues(ctx, user, client) return err }) - var mergeRequests []*MergeRequest + var mergeRequests []*internGitlab.MergeRequest grp.Go(func() error { mergeRequests, err = g.GetYourAssignedPrs(ctx, user, client) return err @@ -349,17 +350,18 @@ func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.T }, nil } -func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) { +func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.MergeRequest, error) { opened := stateOpened scope := scopeAll - + getLabelDetails := getLabelsTrue var mrs []*internGitlab.MergeRequest if g.gitlabGroup == "" { opt := &internGitlab.ListMergeRequestsOptions{ - ReviewerID: internGitlab.ReviewerID(user.GitlabUserID), - State: &opened, - Scope: &scope, - ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, + ReviewerID: internGitlab.ReviewerID(user.GitlabUserID), + State: &opened, + Scope: &scope, + WithLabelsDetails: &getLabelDetails, + ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { current, resp, err := client.MergeRequests.ListMergeRequests(opt) @@ -374,10 +376,11 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internG } } else { opt := &internGitlab.ListGroupMergeRequestsOptions{ - ReviewerID: internGitlab.ReviewerID(user.GitlabUserID), - State: &opened, - Scope: &scope, - ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, + ReviewerID: internGitlab.ReviewerID(user.GitlabUserID), + State: &opened, + Scope: &scope, + WithLabelsDetails: &getLabelDetails, + ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { current, resp, err := client.MergeRequests.ListGroupMergeRequests(g.gitlabGroup, opt) @@ -392,34 +395,21 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internG } } - mergeRequests := []*MergeRequest{} - for _, mr := range mrs { - if mr.Labels != nil { - labelsWithDetails, err := g.GetLabelDetails(client, mr.ProjectID, mr.Labels) - if err != nil { - return nil, err - } - mergeRequest := &MergeRequest{ - MergeRequest: mr, - LabelsWithDetails: labelsWithDetails, - } - mergeRequests = append(mergeRequests, mergeRequest) - } - } - - return mergeRequests, nil + return mrs, nil } -func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) { +func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.MergeRequest, error) { opened := stateOpened scope := scopeAll + getLabelDetails := getLabelsTrue var mrs []*internGitlab.MergeRequest if g.gitlabGroup == "" { opt := &internGitlab.ListMergeRequestsOptions{ - AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), - State: &opened, - Scope: &scope, - ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, + AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), + State: &opened, + Scope: &scope, + WithLabelsDetails: &getLabelDetails, + ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { current, resp, err := client.MergeRequests.ListMergeRequests(opt) @@ -434,10 +424,11 @@ func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, client } } else { opt := &internGitlab.ListGroupMergeRequestsOptions{ - AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), - State: &opened, - Scope: &scope, - ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, + AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), + State: &opened, + Scope: &scope, + WithLabelsDetails: &getLabelDetails, + ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { current, resp, err := client.MergeRequests.ListGroupMergeRequests(g.gitlabGroup, opt) @@ -452,21 +443,7 @@ func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, client } } - mergeRequests := []*MergeRequest{} - for _, mr := range mrs { - if mr.Labels != nil { - labelsWithDetails, err := g.GetLabelDetails(client, mr.ProjectID, mr.Labels) - if err != nil { - return nil, err - } - mergeRequest := &MergeRequest{ - MergeRequest: mr, - LabelsWithDetails: labelsWithDetails, - } - mergeRequests = append(mergeRequests, mergeRequest) - } - } - return mergeRequests, nil + return mrs, nil } func (g *gitlab) GetLabelDetails(client *internGitlab.Client, pid int, labels internGitlab.Labels) ([]*internGitlab.Label, error) { @@ -563,17 +540,18 @@ func (g *gitlab) fetchYourPrDetails(c context.Context, log logger.Logger, client return nil } -func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) { +func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Issue, error) { opened := stateOpened scope := scopeAll var issues []*internGitlab.Issue - + getLabelDetails := getLabelsTrue if g.gitlabGroup == "" { opt := &internGitlab.ListIssuesOptions{ - AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), - State: &opened, - Scope: &scope, - ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, + AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), + State: &opened, + Scope: &scope, + WithLabelDetails: &getLabelDetails, + ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { current, resp, err := client.Issues.ListIssues(opt) @@ -588,10 +566,11 @@ func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, clie } } else { opt := &internGitlab.ListGroupIssuesOptions{ - AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), - State: &opened, - Scope: &scope, - ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, + AssigneeID: internGitlab.AssigneeID(user.GitlabUserID), + State: &opened, + Scope: &scope, + WithLabelDetails: &getLabelDetails, + ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { current, resp, err := client.Issues.ListGroupIssues(g.gitlabGroup, opt) @@ -605,22 +584,7 @@ func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, clie opt.Page = resp.NextPage } } - - var result []*Issue - for _, issue := range issues { - if issue.Labels != nil { - labelsWithDetails, err := g.GetLabelDetails(client, issue.ProjectID, issue.Labels) - if err != nil { - return nil, err - } - issue := &Issue{ - Issue: issue, - LabelsWithDetails: labelsWithDetails, - } - result = append(result, issue) - } - } - return result, nil + return issues, nil } func (g *gitlab) GetToDoList(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) { @@ -962,7 +926,7 @@ func (g *gitlab) GetIssueByID(ctx context.Context, user *UserInfo, owner, repo s gitlabIssue := &Issue{ Issue: issue, } - if issue.Labels != nil { + if len(issue.Labels) > 0 { labelsWithDetails, err := g.GetLabelDetails(client, issue.ProjectID, issue.Labels) if err != nil { return nil, err @@ -990,7 +954,7 @@ func (g *gitlab) GetMergeRequestByID(ctx context.Context, user *UserInfo, owner, gitlabMergeRequest := &MergeRequest{ MergeRequest: mergeRequest, } - if mergeRequest.Labels != nil { + if len(mergeRequest.Labels) > 0 { labelsWithDetails, err := g.GetLabelDetails(client, mergeRequest.ProjectID, mergeRequest.Labels) if err != nil { return nil, err diff --git a/server/gitlab/gitlab.go b/server/gitlab/gitlab.go index c0dbafc0..0b15c5c0 100644 --- a/server/gitlab/gitlab.go +++ b/server/gitlab/gitlab.go @@ -37,10 +37,10 @@ type Gitlab interface { GetUserDetails(ctx context.Context, user *UserInfo, token *oauth2.Token) (*internGitlab.User, error) GetProject(ctx context.Context, user *UserInfo, token *oauth2.Token, owner, repo string) (*internGitlab.Project, error) GetYourPrDetails(ctx context.Context, log logger.Logger, user *UserInfo, token *oauth2.Token, prList []*PRDetails) ([]*PRDetails, error) - GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) - GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) + GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.MergeRequest, error) + GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.MergeRequest, error) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.Token) (*LHSContent, error) - GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) + GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Issue, error) GetToDoList(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) GetProjectHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string, repo string) ([]*WebhookInfo, error) GetGroupHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string) ([]*WebhookInfo, error) diff --git a/server/gitlab/mocks/mock_gitlab.go b/server/gitlab/mocks/mock_gitlab.go index 35c2e704..dd1f3949 100644 --- a/server/gitlab/mocks/mock_gitlab.go +++ b/server/gitlab/mocks/mock_gitlab.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/mattermost/mattermost-plugin-gitlab/server/gitlab (interfaces: Gitlab) +// +// Generated by this command: +// +// mockgen -destination server/gitlab/mocks/mock_gitlab.go github.com/mattermost/mattermost-plugin-gitlab/server/gitlab Gitlab +// // Package mock_gitlab is a generated GoMock package. package mock_gitlab @@ -8,10 +13,10 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" gitlab "github.com/mattermost/mattermost-plugin-gitlab/server/gitlab" logger "github.com/mattermost/mattermost/server/public/pluginapi/experimental/bot/logger" gitlab0 "github.com/xanzy/go-gitlab" + gomock "go.uber.org/mock/gomock" oauth2 "golang.org/x/oauth2" ) @@ -78,7 +83,7 @@ func (m *MockGitlab) GetCurrentUser(arg0 context.Context, arg1 string, arg2 oaut } // GetCurrentUser indicates an expected call of GetCurrentUser. -func (mr *MockGitlabMockRecorder) GetCurrentUser(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetCurrentUser(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentUser", reflect.TypeOf((*MockGitlab)(nil).GetCurrentUser), arg0, arg1, arg2) } @@ -93,7 +98,7 @@ func (m *MockGitlab) GetGroupHooks(arg0 context.Context, arg1 *gitlab.UserInfo, } // GetGroupHooks indicates an expected call of GetGroupHooks. -func (mr *MockGitlabMockRecorder) GetGroupHooks(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetGroupHooks(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupHooks", reflect.TypeOf((*MockGitlab)(nil).GetGroupHooks), arg0, arg1, arg2, arg3) } @@ -108,7 +113,7 @@ func (m *MockGitlab) GetIssueByID(arg0 context.Context, arg1 *gitlab.UserInfo, a } // GetIssueByID indicates an expected call of GetIssueByID. -func (mr *MockGitlabMockRecorder) GetIssueByID(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetIssueByID(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIssueByID", reflect.TypeOf((*MockGitlab)(nil).GetIssueByID), arg0, arg1, arg2, arg3, arg4, arg5) } @@ -123,7 +128,7 @@ func (m *MockGitlab) GetLHSData(arg0 context.Context, arg1 *gitlab.UserInfo, arg } // GetLHSData indicates an expected call of GetLHSData. -func (mr *MockGitlabMockRecorder) GetLHSData(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetLHSData(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLHSData", reflect.TypeOf((*MockGitlab)(nil).GetLHSData), arg0, arg1, arg2) } @@ -153,7 +158,7 @@ func (m *MockGitlab) GetMergeRequestByID(arg0 context.Context, arg1 *gitlab.User } // GetMergeRequestByID indicates an expected call of GetMergeRequestByID. -func (mr *MockGitlabMockRecorder) GetMergeRequestByID(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetMergeRequestByID(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMergeRequestByID", reflect.TypeOf((*MockGitlab)(nil).GetMergeRequestByID), arg0, arg1, arg2, arg3, arg4, arg5) } @@ -183,7 +188,7 @@ func (m *MockGitlab) GetProject(arg0 context.Context, arg1 *gitlab.UserInfo, arg } // GetProject indicates an expected call of GetProject. -func (mr *MockGitlabMockRecorder) GetProject(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetProject(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProject", reflect.TypeOf((*MockGitlab)(nil).GetProject), arg0, arg1, arg2, arg3, arg4) } @@ -198,7 +203,7 @@ func (m *MockGitlab) GetProjectHooks(arg0 context.Context, arg1 *gitlab.UserInfo } // GetProjectHooks indicates an expected call of GetProjectHooks. -func (mr *MockGitlabMockRecorder) GetProjectHooks(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetProjectHooks(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectHooks", reflect.TypeOf((*MockGitlab)(nil).GetProjectHooks), arg0, arg1, arg2, arg3, arg4) } @@ -219,16 +224,16 @@ func (mr *MockGitlabMockRecorder) GetProjectMembers(arg0, arg1, arg2, arg3 inter } // GetReviews mocks base method. -func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetReviews", arg0, arg1, arg2) - ret0, _ := ret[0].([]*gitlab.MergeRequest) + ret0, _ := ret[0].([]*gitlab0.MergeRequest) ret1, _ := ret[1].(error) return ret0, ret1 } // GetReviews indicates an expected call of GetReviews. -func (mr *MockGitlabMockRecorder) GetReviews(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetReviews(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetReviews", reflect.TypeOf((*MockGitlab)(nil).GetReviews), arg0, arg1, arg2) } @@ -243,7 +248,7 @@ func (m *MockGitlab) GetToDoList(arg0 context.Context, arg1 *gitlab.UserInfo, ar } // GetToDoList indicates an expected call of GetToDoList. -func (mr *MockGitlabMockRecorder) GetToDoList(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetToDoList(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetToDoList", reflect.TypeOf((*MockGitlab)(nil).GetToDoList), arg0, arg1, arg2) } @@ -258,37 +263,37 @@ func (m *MockGitlab) GetUserDetails(arg0 context.Context, arg1 *gitlab.UserInfo, } // GetUserDetails indicates an expected call of GetUserDetails. -func (mr *MockGitlabMockRecorder) GetUserDetails(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetUserDetails(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserDetails", reflect.TypeOf((*MockGitlab)(nil).GetUserDetails), arg0, arg1, arg2) } // GetYourAssignedIssues mocks base method. -func (m *MockGitlab) GetYourAssignedIssues(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.Issue, error) { +func (m *MockGitlab) GetYourAssignedIssues(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.Issue, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourAssignedIssues", arg0, arg1, arg2) - ret0, _ := ret[0].([]*gitlab.Issue) + ret0, _ := ret[0].([]*gitlab0.Issue) ret1, _ := ret[1].(error) return ret0, ret1 } // GetYourAssignedIssues indicates an expected call of GetYourAssignedIssues. -func (mr *MockGitlabMockRecorder) GetYourAssignedIssues(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetYourAssignedIssues(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetYourAssignedIssues", reflect.TypeOf((*MockGitlab)(nil).GetYourAssignedIssues), arg0, arg1, arg2) } // GetYourAssignedPrs mocks base method. -func (m *MockGitlab) GetYourAssignedPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetYourAssignedPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourAssignedPrs", arg0, arg1, arg2) - ret0, _ := ret[0].([]*gitlab.MergeRequest) + ret0, _ := ret[0].([]*gitlab0.MergeRequest) ret1, _ := ret[1].(error) return ret0, ret1 } // GetYourAssignedPrs indicates an expected call of GetYourAssignedPrs. -func (mr *MockGitlabMockRecorder) GetYourAssignedPrs(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetYourAssignedPrs(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetYourAssignedPrs", reflect.TypeOf((*MockGitlab)(nil).GetYourAssignedPrs), arg0, arg1, arg2) } @@ -303,7 +308,7 @@ func (m *MockGitlab) GetYourPrDetails(arg0 context.Context, arg1 logger.Logger, } // GetYourPrDetails indicates an expected call of GetYourPrDetails. -func (mr *MockGitlabMockRecorder) GetYourPrDetails(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetYourPrDetails(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetYourPrDetails", reflect.TypeOf((*MockGitlab)(nil).GetYourPrDetails), arg0, arg1, arg2, arg3, arg4) } @@ -333,7 +338,7 @@ func (m *MockGitlab) GitlabConnect(arg0 oauth2.Token) (*gitlab0.Client, error) { } // GitlabConnect indicates an expected call of GitlabConnect. -func (mr *MockGitlabMockRecorder) GitlabConnect(arg0 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GitlabConnect(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GitlabConnect", reflect.TypeOf((*MockGitlab)(nil).GitlabConnect), arg0) } @@ -348,13 +353,13 @@ func (m *MockGitlab) NewGroupHook(arg0 context.Context, arg1 *gitlab.UserInfo, a } // NewGroupHook indicates an expected call of NewGroupHook. -func (mr *MockGitlabMockRecorder) NewGroupHook(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) NewGroupHook(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewGroupHook", reflect.TypeOf((*MockGitlab)(nil).NewGroupHook), arg0, arg1, arg2, arg3, arg4) } // NewProjectHook mocks base method. -func (m *MockGitlab) NewProjectHook(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token, arg3 interface{}, arg4 *gitlab.AddWebhookOptions) (*gitlab.WebhookInfo, error) { +func (m *MockGitlab) NewProjectHook(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token, arg3 any, arg4 *gitlab.AddWebhookOptions) (*gitlab.WebhookInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewProjectHook", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(*gitlab.WebhookInfo) @@ -363,7 +368,7 @@ func (m *MockGitlab) NewProjectHook(arg0 context.Context, arg1 *gitlab.UserInfo, } // NewProjectHook indicates an expected call of NewProjectHook. -func (mr *MockGitlabMockRecorder) NewProjectHook(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) NewProjectHook(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewProjectHook", reflect.TypeOf((*MockGitlab)(nil).NewProjectHook), arg0, arg1, arg2, arg3, arg4) } @@ -379,7 +384,7 @@ func (m *MockGitlab) ResolveNamespaceAndProject(arg0 context.Context, arg1 *gitl } // ResolveNamespaceAndProject indicates an expected call of ResolveNamespaceAndProject. -func (mr *MockGitlabMockRecorder) ResolveNamespaceAndProject(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) ResolveNamespaceAndProject(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveNamespaceAndProject", reflect.TypeOf((*MockGitlab)(nil).ResolveNamespaceAndProject), arg0, arg1, arg2, arg3, arg4) } @@ -409,7 +414,7 @@ func (m *MockGitlab) TriggerProjectPipeline(arg0 *gitlab.UserInfo, arg1 *oauth2. } // TriggerProjectPipeline indicates an expected call of TriggerProjectPipeline. -func (mr *MockGitlabMockRecorder) TriggerProjectPipeline(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) TriggerProjectPipeline(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TriggerProjectPipeline", reflect.TypeOf((*MockGitlab)(nil).TriggerProjectPipeline), arg0, arg1, arg2, arg3) } diff --git a/server/mocks/mock_gitlab.go b/server/mocks/mock_gitlab.go index 35c2e704..7f6ceeca 100644 --- a/server/mocks/mock_gitlab.go +++ b/server/mocks/mock_gitlab.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/mattermost/mattermost-plugin-gitlab/server/gitlab (interfaces: Gitlab) +// +// Generated by this command: +// +// mockgen -destination server/mocks/mock_gitlab.go github.com/mattermost/mattermost-plugin-gitlab/server/gitlab Gitlab +// // Package mock_gitlab is a generated GoMock package. package mock_gitlab @@ -8,10 +13,10 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" gitlab "github.com/mattermost/mattermost-plugin-gitlab/server/gitlab" logger "github.com/mattermost/mattermost/server/public/pluginapi/experimental/bot/logger" gitlab0 "github.com/xanzy/go-gitlab" + gomock "go.uber.org/mock/gomock" oauth2 "golang.org/x/oauth2" ) @@ -78,7 +83,7 @@ func (m *MockGitlab) GetCurrentUser(arg0 context.Context, arg1 string, arg2 oaut } // GetCurrentUser indicates an expected call of GetCurrentUser. -func (mr *MockGitlabMockRecorder) GetCurrentUser(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetCurrentUser(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentUser", reflect.TypeOf((*MockGitlab)(nil).GetCurrentUser), arg0, arg1, arg2) } @@ -93,7 +98,7 @@ func (m *MockGitlab) GetGroupHooks(arg0 context.Context, arg1 *gitlab.UserInfo, } // GetGroupHooks indicates an expected call of GetGroupHooks. -func (mr *MockGitlabMockRecorder) GetGroupHooks(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetGroupHooks(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupHooks", reflect.TypeOf((*MockGitlab)(nil).GetGroupHooks), arg0, arg1, arg2, arg3) } @@ -108,7 +113,7 @@ func (m *MockGitlab) GetIssueByID(arg0 context.Context, arg1 *gitlab.UserInfo, a } // GetIssueByID indicates an expected call of GetIssueByID. -func (mr *MockGitlabMockRecorder) GetIssueByID(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetIssueByID(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIssueByID", reflect.TypeOf((*MockGitlab)(nil).GetIssueByID), arg0, arg1, arg2, arg3, arg4, arg5) } @@ -123,7 +128,7 @@ func (m *MockGitlab) GetLHSData(arg0 context.Context, arg1 *gitlab.UserInfo, arg } // GetLHSData indicates an expected call of GetLHSData. -func (mr *MockGitlabMockRecorder) GetLHSData(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetLHSData(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLHSData", reflect.TypeOf((*MockGitlab)(nil).GetLHSData), arg0, arg1, arg2) } @@ -153,7 +158,7 @@ func (m *MockGitlab) GetMergeRequestByID(arg0 context.Context, arg1 *gitlab.User } // GetMergeRequestByID indicates an expected call of GetMergeRequestByID. -func (mr *MockGitlabMockRecorder) GetMergeRequestByID(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetMergeRequestByID(arg0, arg1, arg2, arg3, arg4, arg5 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMergeRequestByID", reflect.TypeOf((*MockGitlab)(nil).GetMergeRequestByID), arg0, arg1, arg2, arg3, arg4, arg5) } @@ -183,7 +188,7 @@ func (m *MockGitlab) GetProject(arg0 context.Context, arg1 *gitlab.UserInfo, arg } // GetProject indicates an expected call of GetProject. -func (mr *MockGitlabMockRecorder) GetProject(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetProject(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProject", reflect.TypeOf((*MockGitlab)(nil).GetProject), arg0, arg1, arg2, arg3, arg4) } @@ -198,7 +203,7 @@ func (m *MockGitlab) GetProjectHooks(arg0 context.Context, arg1 *gitlab.UserInfo } // GetProjectHooks indicates an expected call of GetProjectHooks. -func (mr *MockGitlabMockRecorder) GetProjectHooks(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetProjectHooks(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectHooks", reflect.TypeOf((*MockGitlab)(nil).GetProjectHooks), arg0, arg1, arg2, arg3, arg4) } @@ -219,16 +224,16 @@ func (mr *MockGitlabMockRecorder) GetProjectMembers(arg0, arg1, arg2, arg3 inter } // GetReviews mocks base method. -func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetReviews", arg0, arg1, arg2) - ret0, _ := ret[0].([]*gitlab.MergeRequest) + ret0, _ := ret[0].([]*gitlab0.MergeRequest) ret1, _ := ret[1].(error) return ret0, ret1 } // GetReviews indicates an expected call of GetReviews. -func (mr *MockGitlabMockRecorder) GetReviews(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetReviews(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetReviews", reflect.TypeOf((*MockGitlab)(nil).GetReviews), arg0, arg1, arg2) } @@ -243,7 +248,7 @@ func (m *MockGitlab) GetToDoList(arg0 context.Context, arg1 *gitlab.UserInfo, ar } // GetToDoList indicates an expected call of GetToDoList. -func (mr *MockGitlabMockRecorder) GetToDoList(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetToDoList(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetToDoList", reflect.TypeOf((*MockGitlab)(nil).GetToDoList), arg0, arg1, arg2) } @@ -258,37 +263,37 @@ func (m *MockGitlab) GetUserDetails(arg0 context.Context, arg1 *gitlab.UserInfo, } // GetUserDetails indicates an expected call of GetUserDetails. -func (mr *MockGitlabMockRecorder) GetUserDetails(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetUserDetails(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserDetails", reflect.TypeOf((*MockGitlab)(nil).GetUserDetails), arg0, arg1, arg2) } // GetYourAssignedIssues mocks base method. -func (m *MockGitlab) GetYourAssignedIssues(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.Issue, error) { +func (m *MockGitlab) GetYourAssignedIssues(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.Issue, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourAssignedIssues", arg0, arg1, arg2) - ret0, _ := ret[0].([]*gitlab.Issue) + ret0, _ := ret[0].([]*gitlab0.Issue) ret1, _ := ret[1].(error) return ret0, ret1 } // GetYourAssignedIssues indicates an expected call of GetYourAssignedIssues. -func (mr *MockGitlabMockRecorder) GetYourAssignedIssues(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetYourAssignedIssues(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetYourAssignedIssues", reflect.TypeOf((*MockGitlab)(nil).GetYourAssignedIssues), arg0, arg1, arg2) } // GetYourAssignedPrs mocks base method. -func (m *MockGitlab) GetYourAssignedPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetYourAssignedPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourAssignedPrs", arg0, arg1, arg2) - ret0, _ := ret[0].([]*gitlab.MergeRequest) + ret0, _ := ret[0].([]*gitlab0.MergeRequest) ret1, _ := ret[1].(error) return ret0, ret1 } // GetYourAssignedPrs indicates an expected call of GetYourAssignedPrs. -func (mr *MockGitlabMockRecorder) GetYourAssignedPrs(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetYourAssignedPrs(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetYourAssignedPrs", reflect.TypeOf((*MockGitlab)(nil).GetYourAssignedPrs), arg0, arg1, arg2) } @@ -303,7 +308,7 @@ func (m *MockGitlab) GetYourPrDetails(arg0 context.Context, arg1 logger.Logger, } // GetYourPrDetails indicates an expected call of GetYourPrDetails. -func (mr *MockGitlabMockRecorder) GetYourPrDetails(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GetYourPrDetails(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetYourPrDetails", reflect.TypeOf((*MockGitlab)(nil).GetYourPrDetails), arg0, arg1, arg2, arg3, arg4) } @@ -333,7 +338,7 @@ func (m *MockGitlab) GitlabConnect(arg0 oauth2.Token) (*gitlab0.Client, error) { } // GitlabConnect indicates an expected call of GitlabConnect. -func (mr *MockGitlabMockRecorder) GitlabConnect(arg0 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) GitlabConnect(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GitlabConnect", reflect.TypeOf((*MockGitlab)(nil).GitlabConnect), arg0) } @@ -348,13 +353,13 @@ func (m *MockGitlab) NewGroupHook(arg0 context.Context, arg1 *gitlab.UserInfo, a } // NewGroupHook indicates an expected call of NewGroupHook. -func (mr *MockGitlabMockRecorder) NewGroupHook(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) NewGroupHook(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewGroupHook", reflect.TypeOf((*MockGitlab)(nil).NewGroupHook), arg0, arg1, arg2, arg3, arg4) } // NewProjectHook mocks base method. -func (m *MockGitlab) NewProjectHook(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token, arg3 interface{}, arg4 *gitlab.AddWebhookOptions) (*gitlab.WebhookInfo, error) { +func (m *MockGitlab) NewProjectHook(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token, arg3 any, arg4 *gitlab.AddWebhookOptions) (*gitlab.WebhookInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewProjectHook", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(*gitlab.WebhookInfo) @@ -363,7 +368,7 @@ func (m *MockGitlab) NewProjectHook(arg0 context.Context, arg1 *gitlab.UserInfo, } // NewProjectHook indicates an expected call of NewProjectHook. -func (mr *MockGitlabMockRecorder) NewProjectHook(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) NewProjectHook(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewProjectHook", reflect.TypeOf((*MockGitlab)(nil).NewProjectHook), arg0, arg1, arg2, arg3, arg4) } @@ -379,7 +384,7 @@ func (m *MockGitlab) ResolveNamespaceAndProject(arg0 context.Context, arg1 *gitl } // ResolveNamespaceAndProject indicates an expected call of ResolveNamespaceAndProject. -func (mr *MockGitlabMockRecorder) ResolveNamespaceAndProject(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) ResolveNamespaceAndProject(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveNamespaceAndProject", reflect.TypeOf((*MockGitlab)(nil).ResolveNamespaceAndProject), arg0, arg1, arg2, arg3, arg4) } @@ -409,7 +414,7 @@ func (m *MockGitlab) TriggerProjectPipeline(arg0 *gitlab.UserInfo, arg1 *oauth2. } // TriggerProjectPipeline indicates an expected call of TriggerProjectPipeline. -func (mr *MockGitlabMockRecorder) TriggerProjectPipeline(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockGitlabMockRecorder) TriggerProjectPipeline(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TriggerProjectPipeline", reflect.TypeOf((*MockGitlab)(nil).TriggerProjectPipeline), arg0, arg1, arg2, arg3) } diff --git a/webapp/src/components/link_tooltip/index.tsx b/webapp/src/components/link_tooltip/index.tsx index 8d707da5..0d263d6f 100644 --- a/webapp/src/components/link_tooltip/index.tsx +++ b/webapp/src/components/link_tooltip/index.tsx @@ -7,7 +7,7 @@ import {GitLabIssueOpenIcon, GitLabMergeRequestIcon, GitLabMergeRequestClosedIco import Client from '../../client'; import {getTruncatedText, validateGitlabUrl, isValidUrl, getInfoAboutLink} from '../../utils/tooltip_utils'; -import {TooltipData} from 'src/types/gitlab_items'; +import {Item} from 'src/types/gitlab_items'; import {getConnected, getConnectedGitlabUrl} from 'src/selectors'; import './tooltip.css'; @@ -39,7 +39,7 @@ type Props = { } const LinkTooltip = ({href, show}: Props) => { - const [data, setData] = useState(null); + const [data, setData] = useState(null); const connected = useSelector(getConnected); const connectedGitlabUrl = useSelector(getConnectedGitlabUrl); @@ -171,7 +171,7 @@ const LinkTooltip = ({href, show}: Props) => { {/* Labels */}
- {data.labels && data.labels_with_details?.length && data.labels_with_details.map((label) => { + {data.labels && data.label_details?.length && data.label_details.map((label) => { return ( ); - const labels: JSX.Element[] | undefined = item.labels_with_details && getGitlabLabels(item.labels_with_details); + const labels: JSX.Element[] | undefined = item.label_details && getGitlabLabels(item.label_details); let hasConflict: React.ReactNode | undefined; if (item.has_conflicts) { diff --git a/webapp/src/types/gitlab_items.ts b/webapp/src/types/gitlab_items.ts index 0de7971d..bebc9162 100644 --- a/webapp/src/types/gitlab_items.ts +++ b/webapp/src/types/gitlab_items.ts @@ -54,7 +54,7 @@ export interface Item { repository?: { full_name: string; }; - labels_with_details?: Label[]; + label_details?: Label[]; target: Target; num_approvers: number; total_reviewers: number; @@ -64,23 +64,12 @@ export interface Item { type: string; repo: string; description: string; + target_branch: string; + source_branch: string; + labels: string[]; } export interface GitlabItemsProps { item: Item; theme: Theme; } - -export interface TooltipData { - state: string; - type: string; - repo: string; - description: string; - created_at: string; - iid: number; - title: string; - target_branch: string; - source_branch: string; - labels: string[]; - labels_with_details: Label[]; -}