Skip to content

Commit

Permalink
Release 3.2.1 (#884)
Browse files Browse the repository at this point in the history
* bump version 3.2.1

* MM-47046/MM-47052 Use version of React DOM provided by web app (#868)

* add ReactDOM to webpack externals

* npm install --verbose

* use git insteadOf

* Fix linter issues (#878)

* remove git config change

Co-authored-by: Ben Schumacher <[email protected]>
  • Loading branch information
mickmister and hanzei committed Oct 31, 2022
1 parent f986c15 commit 9479110
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 47 deletions.
13 changes: 7 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,39 @@ linters-settings:
simplify: true
goimports:
local-prefixes: github.com/mattermost/mattermost-plugin-jira
golint:
min-confidence: 0
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
misspell:
locale: US
revive:
rules:
- name: error-strings
disabled: true

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- varcheck
- whitespace

issues:
Expand Down
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gorilla/mux v1.8.0
github.com/jarcoal/httpmock v1.0.8
github.com/mattermost/mattermost-plugin-api v0.0.26-0.20220223141232-cb8b1984774a
github.com/mattermost/mattermost-plugin-api v0.0.27
github.com/mattermost/mattermost-plugin-autolink v1.2.2-0.20210709183311-c8fa30db649f
github.com/mattermost/mattermost-server/v6 v6.3.0
github.com/mattermost/mattermost-server/v6 v6.5.2
github.com/mholt/archiver/v3 v3.5.1
github.com/pkg/errors v0.9.1
github.com/rbriski/atlassian-jwt v0.0.0-20180307182949-7bb4ae273058
github.com/stretchr/testify v1.7.0
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/text v0.3.7
)

// Until github.com/mattermost/mattermost-server/v6 v6.5.0 is releated,
// this replacement is needed to also import github.com/mattermost/mattermost-plugin-api,
// which uses a different server version.
replace github.com/mattermost/mattermost-server/v6 v6.3.0 => github.com/mattermost/mattermost-server/v6 v6.0.0-20220210052000-0d67995eb491
143 changes: 137 additions & 6 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "Atlassian Jira plugin for Mattermost.",
"homepage_url": "https://github.com/mattermost/mattermost-plugin-jira",
"support_url": "https://github.com/mattermost/mattermost-plugin-jira/issues",
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-jira/releases/tag/v3.2.0",
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-jira/releases/tag/v3.2.1",
"icon_path": "assets/icon.svg",
"version": "3.2.0",
"version": "3.2.1",
"min_server_version": "6.5.0",
"server": {
"executables": {
Expand Down
3 changes: 1 addition & 2 deletions server/instance_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ func (ci *cloudInstance) parseHTTPRequestJWT(r *http.Request) (*jwt.Token, strin

token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, errors.New(
fmt.Sprintf("unsupported signing method: %v", token.Header["alg"]))
return nil, errors.Errorf("unsupported signing method: %v", token.Header["alg"])
}
// HMAC secret is a []byte
return []byte(ci.AtlassianSecurityContext.SharedSecret), nil
Expand Down
4 changes: 2 additions & 2 deletions server/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,12 @@ func (p *Plugin) UnassignIssue(instance Instance, mattermostUserID types.ID, iss
// check for valid issue key
_, err = client.GetIssue(issueKey, nil)
if err != nil {
return "", errors.Errorf("We couldn't find the issue key `%s`. Please confirm the issue key and try again.", issueKey)
return "", errors.Errorf("We couldn't find the issue key `%s`. Please confirm the issue key and try again.", issueKey)
}

if err := client.UpdateAssignee(issueKey, &jira.User{}); err != nil {
if StatusCode(err) == http.StatusForbidden {
return "", errors.New("you do not have the appropriate permissions to perform this action. Please contact your Jira administrator")
return "", errors.New("You do not have the appropriate permissions to perform this action. Please contact your Jira administrator.")
}
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions server/jira_test_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func getJiraTestData(filename string) ([]byte, error) {

func withExistingChannelSubscriptions(subscriptions []ChannelSubscription) *Subscriptions {
ret := NewSubscriptions()
for i, sub := range subscriptions {
sub.InstanceID = testInstance1.GetID()
for i := range subscriptions {
subscriptions[i].InstanceID = testInstance1.GetID()
ret.Channel.add(&subscriptions[i])
}
return ret
Expand Down
26 changes: 13 additions & 13 deletions server/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func (store *store) LoadInstanceFullKey(fullkey string) (Instance, error) {
return &si, nil
}

return nil, errors.New(fmt.Sprintf("Jira instance %s has unsupported type: %s", fullkey, si.Type))
return nil, errors.Errorf("Jira instance %s has unsupported type: %s", fullkey, si.Type)
}

func (store *store) StoreInstance(instance Instance) error {
Expand Down Expand Up @@ -568,13 +568,13 @@ func UpdateInstances(store InstanceStore, updatef func(instances *Instances) err

// MigrateV2Instances migrates instance record(s) from the V2 data model.
//
// - v2keyKnownJiraInstances ("known_jira_instances") was stored as a
// map[string]string (InstanceID->Type), needs to be stored as Instances.
// https://github.com/mattermost/mattermost-plugin-jira/blob/885efe8eb70c92bcea64d1ced6e67710eda77b6e/server/kv.go#L375
// - v2keyCurrentJIRAInstance ("current_jira_instance") stored an Instance; will
// be used to set the default instance.
// - The instances themselves should be forward-compatible, including
// CurrentInstance.
// - v2keyKnownJiraInstances ("known_jira_instances") was stored as a
// map[string]string (InstanceID->Type), needs to be stored as Instances.
// https://github.com/mattermost/mattermost-plugin-jira/blob/885efe8eb70c92bcea64d1ced6e67710eda77b6e/server/kv.go#L375
// - v2keyCurrentJIRAInstance ("current_jira_instance") stored an Instance; will
// be used to set the default instance.
// - The instances themselves should be forward-compatible, including
// CurrentInstance.
func MigrateV2Instances(p *Plugin) (*Instances, error) {
// Check if V3 instances exist and return them if found
instances, err := p.instanceStore.LoadInstances()
Expand Down Expand Up @@ -646,7 +646,7 @@ func MigrateV2Instances(p *Plugin) (*Instances, error) {
return instances, nil
}

// MigrateV3ToV2 performs necessary migrations when reverting from V3 to V2
// MigrateV3ToV2 performs necessary migrations when reverting from V3 to V2
func MigrateV3ToV2(p *Plugin) string {
// migrate V3 instances to v2
v2Instances, msg := MigrateV3InstancesToV2(p)
Expand Down Expand Up @@ -675,10 +675,10 @@ func MigrateV3ToV2(p *Plugin) string {

// MigrateV3InstancesToV2 migrates instance record(s) from the V3 data model.
//
// - v3 instances need to be stored as v2keyKnownJiraInstances
// (known_jira_instances) map[string]string (InstanceID->Type),
// - v2keyCurrentJIRAInstance ("current_jira_instance") stored an Instance; will
// be used to set the default instance.
// - v3 instances need to be stored as v2keyKnownJiraInstances
// (known_jira_instances) map[string]string (InstanceID->Type),
// - v2keyCurrentJIRAInstance ("current_jira_instance") stored an Instance; will
// be used to set the default instance.
func MigrateV3InstancesToV2(p *Plugin) (JiraV2Instances, string) {
v3instances, err := p.instanceStore.LoadInstances()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion server/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ var manifest = struct {
Version string
}{
ID: "jira",
Version: "3.2.0",
Version: "3.2.1",
}
4 changes: 2 additions & 2 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (p *Plugin) OnDeactivate() error {
if p.telemetryClient != nil {
err := p.telemetryClient.Close()
if err != nil {
return errors.Wrap(err, "OnDeactivate: Failed to close telemetryClient.")
return errors.Wrap(err, "OnDeactivate: Failed to close telemetryClient")
}
}
return nil
Expand Down Expand Up @@ -427,7 +427,7 @@ func (p *Plugin) errorf(f string, args ...interface{}) {
func (p *Plugin) CheckSiteURL() error {
ustr := p.GetSiteURL()
if ustr == "" {
return errors.Errorf("Mattermost SITEURL must not be empty.")
return errors.New("Mattermost SITEURL must not be empty.")
}
u, err := url.Parse(ustr)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions server/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ func (p *Plugin) httpUserDisconnect(w http.ResponseWriter, r *http.Request) (int
_, err = p.DisconnectUser(disconnectPayload.InstanceID, types.ID(mattermostUserID))
if errors.Cause(err) == kvstore.ErrNotFound {
return respondErr(w, http.StatusNotFound,
errors.Errorf("Could not complete the **disconnection** request. You do not currently have a Jira account at %q linked to your Mattermost account.",
errors.Errorf(
"could not complete the **disconnection** request. You do not currently have a Jira account at %q linked to your Mattermost account",
disconnectPayload.InstanceID))
}
if err != nil {
return respondErr(w, http.StatusNotFound,
errors.Errorf("Could not complete the **disconnection** request. Error: %v", err))
errors.Errorf("could not complete the **disconnection** request. Error: %v", err))
}

_, err = w.Write([]byte(`{"success": true}`))
Expand Down
5 changes: 4 additions & 1 deletion server/webhook_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"time"

"github.com/pkg/errors"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/mattermost/mattermost-server/v6/model"
)
Expand Down Expand Up @@ -439,7 +441,8 @@ func mergeWebhookEvents(events []*webhook) Webhook {
if event.fieldInfo.name == descriptionField || strings.HasPrefix(event.fieldInfo.from, strike) {
strike = ""
}
msg := "**" + strings.Title(event.fieldInfo.name) + ":** " + strike +
// Use the english language for now. Using the server's local might be better.
msg := "**" + cases.Title(language.English, cases.NoLower).String(event.fieldInfo.name) + ":** " + strike +
event.fieldInfo.from + strike + " " + event.fieldInfo.to
merged.fields = append(merged.fields, &model.SlackAttachmentField{
Value: msg,
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is automatically generated. Do not modify it manually.

export const id = 'jira';
export const version = '3.2.0';
export const version = '3.2.1';
1 change: 1 addition & 0 deletions webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const config = {
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
redux: 'Redux',
'react-redux': 'ReactRedux',
'prop-types': 'PropTypes',
Expand Down

0 comments on commit 9479110

Please sign in to comment.