Skip to content

Commit 4378034

Browse files
committed
Merge branch 'master' of github.com:mattermost/mattermost-plugin-github into MM-618
2 parents cbb804e + 90e790c commit 4378034

File tree

13 files changed

+69
-103
lines changed

13 files changed

+69
-103
lines changed

.circleci/config.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.github/workflows/cd.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: cd
2+
on:
3+
workflow_run:
4+
workflows: ["ci"]
5+
types:
6+
- completed
7+
push:
8+
tags:
9+
- "v[0-9]+.[0-9]+.[0-9]+"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
plugin-cd:
16+
uses: mattermost/actions-workflows/.github/workflows/plugin-cd.yml@1a3d181953ab3e64bc12d7e3709cb619ab0ddb80
17+
secrets: inherit

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- "v[0-9]+.[0-9]+.[0-9]+"
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
plugin-ci:
15+
uses: mattermost/actions-workflows/.github/workflows/plugin-ci.yml@1a3d181953ab3e64bc12d7e3709cb619ab0ddb80
16+
secrets: inherit

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14.21.1

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"key": "UsePreregisteredApplication",
2828
"display_name": "Use Preregistered OAuth Application:",
2929
"type": "bool",
30-
"help_text": "When true, instructs the plugin to use the preregistered GitHub OAuth application - application registration steps can be skipped. Requires [Chimera Proxy](https://github.com/mattermost/chimera) URL to be configured for the server. Cannot be used with GitHub enterprise. **This setting is intended to be used with Mattermost Cloud instances only.**",
30+
"help_text": "Set to false if using GitHub Enterprise. When true, instructs the plugin to use the preregistered GitHub OAuth application - application registration steps can be skipped. Requires [Chimera Proxy](https://github.com/mattermost/chimera) URL to be configured for the server. Cannot be used with GitHub enterprise. **This setting is intended to be used with Mattermost Cloud instances only.**",
3131
"default": false
3232
},
3333
{

server/plugin/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (p *Plugin) withRecovery(next http.Handler) http.Handler {
118118
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
119119
defer func() {
120120
if x := recover(); x != nil {
121-
p.API.LogError("Recovered from a panic",
121+
p.API.LogWarn("Recovered from a panic",
122122
"url", r.URL.String(),
123123
"error", x,
124124
"stack", string(debug.Stack()))
@@ -152,7 +152,7 @@ func (p *Plugin) checkAuth(handler http.HandlerFunc, responseType ResponseType)
152152
case ResponseTypePlain:
153153
http.Error(w, "Not authorized", http.StatusUnauthorized)
154154
default:
155-
p.API.LogError("Unknown ResponseType detected")
155+
p.API.LogDebug("Unknown ResponseType detected")
156156
}
157157
return
158158
}

server/plugin/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestWithRecovery(t *testing.T) {
3232

3333
p := NewPlugin()
3434
api := &plugintest.API{}
35-
api.On("LogError",
35+
api.On("LogWarn",
3636
"Recovered from a panic",
3737
"url", "http://random",
3838
"error", "bad handler",

server/plugin/cluster.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ func (p *Plugin) sendMessageToCluster(id string, v interface{}) {
4444
}
4545

4646
func (p *Plugin) HandleClusterEvent(ev model.PluginClusterEvent) {
47-
p.API.LogError("received cluster event", "id", ev.Id)
48-
4947
switch ev.Id {
5048
case webHookPingEventID:
5149
var event github.PingEvent

server/plugin/mm_34646_token_refresh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ func (p *Plugin) forceResetAllMM34646() error {
6666

6767
info, errResp := p.getGitHubUserInfo(tryInfo.UserID)
6868
if errResp != nil {
69-
p.API.LogError("failed to retrieve serializer.GitHubUserInfo", "key", key, "user_id", tryInfo.UserID,
69+
p.API.LogWarn("failed to retrieve GitHubUserInfo", "key", key, "user_id", tryInfo.UserID,
7070
"error", errResp.Error())
7171
continue
7272
}
7373

7474
_, err = p.forceResetUserTokenMM34646(ctx, config, info)
7575
if err != nil {
76-
p.API.LogError("failed to reset GitHub user token", "key", key, "user_id", tryInfo.UserID,
76+
p.API.LogWarn("failed to reset GitHub user token", "key", key, "user_id", tryInfo.UserID,
7777
"error", err.Error())
7878
continue
7979
}

server/plugin/permalinks.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (p *Plugin) makeReplacements(msg string, replacements []replacement, ghClie
9595
r := replacements[i]
9696
// quick bailout if the commit hash is not proper.
9797
if _, err := hex.DecodeString(r.permalinkInfo.commit); err != nil {
98-
p.API.LogError("Bad git commit hash in permalink", "error", err.Error(), "hash", r.permalinkInfo.commit)
98+
p.API.LogWarn("Bad git commit hash in permalink", "error", err.Error(), "hash", r.permalinkInfo.commit)
9999
continue
100100
}
101101

@@ -106,7 +106,7 @@ func (p *Plugin) makeReplacements(msg string, replacements []replacement, ghClie
106106
if config.EnableCodePreview != "privateAndPublic" {
107107
repo, _, err := ghClient.Repositories.Get(ctx, r.permalinkInfo.user, r.permalinkInfo.repo)
108108
if err != nil {
109-
p.API.LogError("Error while fetching repository information",
109+
p.API.LogWarn("Error while fetching repository information",
110110
"error", err.Error(),
111111
"repo", r.permalinkInfo.repo,
112112
"user", r.permalinkInfo.user)
@@ -126,7 +126,7 @@ func (p *Plugin) makeReplacements(msg string, replacements []replacement, ghClie
126126
fileContent, _, _, err := ghClient.Repositories.GetContents(ctx,
127127
r.permalinkInfo.user, r.permalinkInfo.repo, r.permalinkInfo.path, &opts)
128128
if err != nil {
129-
p.API.LogError("Error while fetching file contents", "error", err.Error(), "path", r.permalinkInfo.path)
129+
p.API.LogWarn("Error while fetching file contents", "error", err.Error(), "path", r.permalinkInfo.path)
130130
continue
131131
}
132132
// this is not a file, ignore.
@@ -136,7 +136,7 @@ func (p *Plugin) makeReplacements(msg string, replacements []replacement, ghClie
136136
}
137137
decoded, err := fileContent.GetContent()
138138
if err != nil {
139-
p.API.LogError("Error while decoding file contents", "error", err.Error(), "path", r.permalinkInfo.path)
139+
p.API.LogWarn("Error while decoding file contents", "error", err.Error(), "path", r.permalinkInfo.path)
140140
continue
141141
}
142142

@@ -153,10 +153,10 @@ func (p *Plugin) makeReplacements(msg string, replacements []replacement, ghClie
153153
}
154154
lines, err := filterLines(decoded, start, end)
155155
if err != nil {
156-
p.API.LogError("Error while filtering lines", "error", err.Error(), "path", r.permalinkInfo.path)
156+
p.API.LogWarn("Error while filtering lines", "error", err.Error(), "path", r.permalinkInfo.path)
157157
}
158158
if lines == "" {
159-
p.API.LogError("Line numbers out of range. Skipping.", "file", r.permalinkInfo.path, "start", start, "end", end)
159+
p.API.LogWarn("Line numbers out of range. Skipping.", "file", r.permalinkInfo.path, "start", start, "end", end)
160160
continue
161161
}
162162
final := getCodeMarkdown(r.permalinkInfo.user, r.permalinkInfo.repo, r.permalinkInfo.path, r.word, lines, isTruncated)

0 commit comments

Comments
 (0)