Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release bump 1.8.1 #460

Merged
merged 8 commits into from
Feb 20, 2024
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Each user in Mattermost is connected with their own personal GitLab account. Use

### Sidebar buttons

Team members can stay up-to-date with how many reviews, unread messages, assignments, and open merge requests they have by using buttons in the Mattermost sidebar.
Team members can stay up-to-date with how many reviews, todos, assigned issues, and assigned merge requests they have by using buttons in the Mattermost sidebar.

## Admin guide

Expand Down Expand Up @@ -142,7 +142,7 @@ Connect your Mattermost account to your GitLab account using `/gitlab connect` a

### Get "To Do" items

Use `/gitlab todo` to get a list of unread messages and merge requests awaiting your review.
Use `/gitlab todo` to get a list of todos, assigned issues, assigned merge requests and merge requests awaiting your review.

### Update settings

Expand Down
6 changes: 3 additions & 3 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@
"Turn off notifications with `/gitlab settings notifications off`.\n\n"+
"##### Sidebar Buttons\n"+
"Check out the buttons in the left-hand sidebar of Mattermost.\n"+
"* The first button tells you how many merge requests you have submitted.\n"+
"* The first button tells you how many merge requests you are assigned to.\n"+

Check warning on line 395 in server/api.go

View check run for this annotation

Codecov / codecov/patch

server/api.go#L395

Added line #L395 was not covered by tests
"* The second shows the number of merge requests that are awaiting your review.\n"+
"* The third shows the number of merge requests and issues you are assigned to.\n"+
"* The fourth tracks the number of unread messages you have.\n"+
"* The third shows the number of issues you are assigned to.\n"+
"* The fourth tracks the number of todos you have.\n"+

Check warning on line 398 in server/api.go

View check run for this annotation

Codecov / codecov/patch

server/api.go#L397-L398

Added lines #L397 - L398 were not covered by tests
"* The fifth will refresh the numbers.\n\n"+
"Click on them!\n\n"+
"##### Slash Commands\n"+
Expand Down
6 changes: 3 additions & 3 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const commandHelp = `* |/gitlab connect| - Connect your Mattermost account to your GitLab account
* |/gitlab disconnect| - Disconnect your Mattermost account from your GitLab account
* |/gitlab todo| - Get a list of unread messages and merge requests awaiting your review
* |/gitlab todo| - Get a list of todos, assigned issues, assigned merge requests and merge requests awaiting your review
* |/gitlab subscriptions list| - Will list the current channel subscriptions
* |/gitlab subscriptions add owner[/repo] [features]| - Subscribe the current channel to receive notifications about opened merge requests and issues for a group or repository
* |features| is a comma-delimited list of one or more the following:
Expand Down Expand Up @@ -248,7 +248,7 @@
_, text, err := p.GetToDo(ctx, info)
if err != nil {
p.client.Log.Warn("can't get todo in command", "err", err.Error())
return p.getCommandResponse(args, "Encountered an error getting your to do items."), nil
return p.getCommandResponse(args, "Encountered an error getting your todo items."), nil

Check warning on line 251 in server/command.go

View check run for this annotation

Codecov / codecov/patch

server/command.go#L251

Added line #L251 was not covered by tests
}
return p.getCommandResponse(args, text), nil
case "me":
Expand Down Expand Up @@ -773,7 +773,7 @@
disconnect := model.NewAutocompleteData("disconnect", "", "disconnect your GitLab account")
gitlab.AddCommand(disconnect)

todo := model.NewAutocompleteData("todo", "", "Get a list of unread messages and merge requests awaiting your review")
todo := model.NewAutocompleteData("todo", "", "Get a list of todos, assigned issues, assigned merge requests and merge requests awaiting your review")

Check warning on line 776 in server/command.go

View check run for this annotation

Codecov / codecov/patch

server/command.go#L776

Added line #L776 was not covered by tests
gitlab.AddCommand(todo)

subscriptions := model.NewAutocompleteData("subscriptions", "[command]", "Available commands: Add, List, Delete")
Expand Down
2 changes: 1 addition & 1 deletion server/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func TestAddWebhookCommand(t *testing.T) {
p.GitlabClient = mockedClient

conf := &model.Config{}
conf.ServiceSettings.SiteURL = &test.siteURL
conf.ServiceSettings.SiteURL = model.NewString(test.siteURL)

encryptedToken, _ := encrypt([]byte(testEncryptionKey), testGitlabToken)

Expand Down
18 changes: 9 additions & 9 deletions server/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ func TestSetDefaults(t *testing.T) {
for _, testCase := range []struct {
description string
isCloud bool
config configuration
config *configuration

shouldChange bool
outputCheck func(*testing.T, *configuration)
errMsg string
}{
{
description: "noop",
config: configuration{
config: &configuration{
EncryptionKey: "abcd",
WebhookSecret: "efgh",
},
Expand All @@ -85,7 +85,7 @@ func TestSetDefaults(t *testing.T) {
},
}, {
description: "set encryption key",
config: configuration{
config: &configuration{
EncryptionKey: "",
},
shouldChange: true,
Expand All @@ -94,7 +94,7 @@ func TestSetDefaults(t *testing.T) {
},
}, {
description: "set webhook key",
config: configuration{
config: &configuration{
WebhookSecret: "",
},
shouldChange: true,
Expand All @@ -103,7 +103,7 @@ func TestSetDefaults(t *testing.T) {
},
}, {
description: "set webhook and encryption key",
config: configuration{
config: &configuration{
EncryptionKey: "",
WebhookSecret: "",
},
Expand All @@ -115,7 +115,7 @@ func TestSetDefaults(t *testing.T) {
}, {
description: "Should not set UsePreregisteredApplication in on-prem",
isCloud: false,
config: configuration{
config: &configuration{
EncryptionKey: "abcd",
WebhookSecret: "efgh",
UsePreregisteredApplication: false,
Expand All @@ -128,7 +128,7 @@ func TestSetDefaults(t *testing.T) {
}, {
description: "Should set UsePreregisteredApplication in cloud if no OAuth secret is configured",
isCloud: true,
config: configuration{
config: &configuration{
EncryptionKey: "abcd",
WebhookSecret: "efgh",
UsePreregisteredApplication: false,
Expand All @@ -143,7 +143,7 @@ func TestSetDefaults(t *testing.T) {
}, {
description: "Should set not UsePreregisteredApplication in cloud if OAuth secret is configured",
isCloud: true,
config: configuration{
config: &configuration{
EncryptionKey: "abcd",
WebhookSecret: "efgh",
UsePreregisteredApplication: false,
Expand All @@ -163,7 +163,7 @@ func TestSetDefaults(t *testing.T) {
changed, err := testCase.config.setDefaults(testCase.isCloud)

assert.Equal(t, testCase.shouldChange, changed)
testCase.outputCheck(t, &testCase.config)
testCase.outputCheck(t, testCase.config)

if testCase.errMsg != "" {
require.Error(t, err)
Expand Down
8 changes: 4 additions & 4 deletions server/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@

clientID = strings.TrimSpace(clientID)

if len(clientID) != 64 {
errorList["client_id"] = "Client ID should be 64 characters long"
if len(clientID) < 64 {
errorList["client_id"] = "Client ID should be at least 64 characters long"

Check warning on line 513 in server/flow.go

View check run for this annotation

Codecov / codecov/patch

server/flow.go#L512-L513

Added lines #L512 - L513 were not covered by tests
}

clientSecretRaw, ok := submitted["client_secret"]
Expand All @@ -524,8 +524,8 @@

clientSecret = strings.TrimSpace(clientSecret)

if len(clientSecret) != 64 {
errorList["client_secret"] = "Client Secret should be 64 characters long"
if len(clientSecret) < 64 {
errorList["client_secret"] = "Client Secret should be at least 64 characters long"

Check warning on line 528 in server/flow.go

View check run for this annotation

Codecov / codecov/patch

server/flow.go#L527-L528

Added lines #L527 - L528 were not covered by tests
}

if len(errorList) != 0 {
Expand Down
36 changes: 18 additions & 18 deletions server/gitlab/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type Issue struct {
}

type LHSContent struct {
PRs []*MergeRequest `json:"prs"`
Reviews []*MergeRequest `json:"reviews"`
Assignments []*Issue `json:"assignments"`
Unreads []*internGitlab.Todo `json:"unreads"`
AssignedPRs []*MergeRequest `json:"yourAssignedPrs"`
Reviews []*MergeRequest `json:"reviews"`
AssignedIssues []*Issue `json:"yourAssignedIssues"`
Todos []*internGitlab.Todo `json:"todos"`
}

// NewGroupHook creates a webhook associated with a GitLab group
Expand Down Expand Up @@ -303,21 +303,21 @@ func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.T
return err
})

var assignments []*Issue
var issues []*Issue
grp.Go(func() error {
assignments, err = g.GetYourAssignments(ctx, user, client)
issues, err = g.GetYourAssignedIssues(ctx, user, client)
return err
})

var mergeRequests []*MergeRequest
grp.Go(func() error {
mergeRequests, err = g.GetYourPrs(ctx, user, client)
mergeRequests, err = g.GetYourAssignedPrs(ctx, user, client)
return err
})

var unreads []*internGitlab.Todo
var todos []*internGitlab.Todo
grp.Go(func() error {
unreads, err = g.GetUnreads(ctx, user, client)
todos, err = g.GetToDoList(ctx, user, client)
return err
})

Expand All @@ -326,10 +326,10 @@ func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.T
}

return &LHSContent{
Reviews: reviews,
PRs: mergeRequests,
Assignments: assignments,
Unreads: unreads,
Reviews: reviews,
AssignedPRs: mergeRequests,
AssignedIssues: issues,
Todos: todos,
}, nil
}

Expand Down Expand Up @@ -394,13 +394,13 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internG
return mergeRequests, nil
}

func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) {
func (g *gitlab) GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) {
opened := stateOpened
scope := scopeAll
var mrs []*internGitlab.MergeRequest
if g.gitlabGroup == "" {
opt := &internGitlab.ListMergeRequestsOptions{
AuthorID: &user.GitlabUserID,
AssigneeID: internGitlab.AssigneeID(user.GitlabUserID),
State: &opened,
Scope: &scope,
ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage},
Expand All @@ -418,7 +418,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, client *internG
}
} else {
opt := &internGitlab.ListGroupMergeRequestsOptions{
AuthorID: &user.GitlabUserID,
AssigneeID: internGitlab.AssigneeID(user.GitlabUserID),
State: &opened,
Scope: &scope,
ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage},
Expand Down Expand Up @@ -547,7 +547,7 @@ func (g *gitlab) fetchYourPrDetails(c context.Context, log logger.Logger, client
return nil
}

func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) {
func (g *gitlab) GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) {
opened := stateOpened
scope := scopeAll
var issues []*internGitlab.Issue
Expand Down Expand Up @@ -607,7 +607,7 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, client
return result, nil
}

func (g *gitlab) GetUnreads(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) {
func (g *gitlab) GetToDoList(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) {
var todos []*internGitlab.Todo

opt := &internGitlab.ListTodosOptions{
Expand Down
6 changes: 3 additions & 3 deletions server/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type Gitlab interface {
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)
GetYourPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.Token) (*LHSContent, error)
GetYourAssignments(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error)
GetUnreads(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error)
GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*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)
NewProjectHook(ctx context.Context, user *UserInfo, token *oauth2.Token, projectID interface{}, projectHookOptions *AddWebhookOptions) (*WebhookInfo, error)
Expand Down
52 changes: 26 additions & 26 deletions server/gitlab/mocks/mock_gitlab.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading