From 8322882265c249daf9d8ff950ce2ece34296da9b Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Wed, 17 Jul 2024 19:19:36 +0200 Subject: [PATCH 1/4] style: reenable switch check --- .golangci.yml | 1 - models/db/convert.go | 3 ++- models/repo/repo_unit.go | 3 +-- modules/actions/workflows.go | 6 ++---- modules/forgefed/forgefed.go | 9 ++++++--- modules/markup/markdown/callout/github.go | 4 +--- modules/markup/markdown/callout/github_legacy.go | 3 +-- modules/repository/license.go | 3 +-- modules/session/redis.go | 3 +-- modules/structs/task.go | 3 ++- services/actions/workflows.go | 9 +++------ services/mailer/incoming/incoming_handler.go | 4 ++-- services/webhook/dingtalk.go | 3 +-- services/webhook/discord.go | 3 +-- services/webhook/matrix.go | 3 +-- services/webhook/msteams.go | 3 +-- services/webhook/slack.go | 3 +-- services/webhook/telegram.go | 3 +-- services/webhook/wechatwork.go | 3 +-- 19 files changed, 29 insertions(+), 43 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 640fbb938..4a20269b0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -43,7 +43,6 @@ linters-settings: gocritic: disabled-checks: - ifElseChain - - singleCaseSwitch # Every time this occurred in the code, there was no other way. revive: severity: error rules: diff --git a/models/db/convert.go b/models/db/convert.go index 5ebafcf87..956e17d41 100644 --- a/models/db/convert.go +++ b/models/db/convert.go @@ -58,6 +58,7 @@ func Cell2Int64(val xorm.Cell) int64 { v, _ := strconv.ParseInt(string((*val).([]uint8)), 10, 64) return v + default: + return (*val).(int64) } - return (*val).(int64) } diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index ca82d54cb..ed553844f 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -235,8 +235,7 @@ func (cfg *ActionsConfig) ToDB() ([]byte, error) { // BeforeSet is invoked from XORM before setting the value of a field of this object. func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { - switch colName { - case "type": + if colName == "type" { switch unit.Type(db.Cell2Int64(val)) { case unit.TypeExternalWiki: r.Config = new(ExternalWikiConfig) diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go index 9319c0511..94c221ee7 100644 --- a/modules/actions/workflows.go +++ b/modules/actions/workflows.go @@ -649,8 +649,7 @@ func matchReleaseEvent(payload *api.ReleasePayload, evt *jobparser.Event) bool { // unpublished, created, deleted, prereleased, released action := payload.Action - switch action { - case api.HookReleaseUpdated: + if action == api.HookReleaseUpdated { action = "edited" } for _, val := range vals { @@ -686,8 +685,7 @@ func matchPackageEvent(payload *api.PackagePayload, evt *jobparser.Event) bool { // updated action := payload.Action - switch action { - case api.HookPackageCreated: + if action == api.HookPackageCreated { action = "published" } for _, val := range vals { diff --git a/modules/forgefed/forgefed.go b/modules/forgefed/forgefed.go index 234aecf3a..2344dc7a8 100644 --- a/modules/forgefed/forgefed.go +++ b/modules/forgefed/forgefed.go @@ -16,8 +16,9 @@ func GetItemByType(typ ap.ActivityVocabularyType) (ap.Item, error) { switch typ { case RepositoryType: return RepositoryNew(""), nil + default: + return ap.GetItemByType(typ) } - return ap.GetItemByType(typ) } // JSONUnmarshalerFn is the function that will load the data from a fastjson.Value into an Item @@ -28,8 +29,9 @@ func JSONUnmarshalerFn(typ ap.ActivityVocabularyType, val *fastjson.Value, i ap. return OnRepository(i, func(r *Repository) error { return JSONLoadRepository(val, r) }) + default: + return nil } - return nil } // NotEmpty is the function that checks if an object is empty @@ -44,6 +46,7 @@ func NotEmpty(i ap.Item) bool { return false } return ap.NotEmpty(r.Actor) + default: + return ap.NotEmpty(i) } - return ap.NotEmpty(i) } diff --git a/modules/markup/markdown/callout/github.go b/modules/markup/markdown/callout/github.go index debad42b8..c6da30f7f 100644 --- a/modules/markup/markdown/callout/github.go +++ b/modules/markup/markdown/callout/github.go @@ -34,8 +34,7 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea return ast.WalkContinue, nil } - switch v := n.(type) { - case *ast.Blockquote: + if v, ok := n.(*ast.Blockquote); ok { if v.ChildCount() == 0 { return ast.WalkContinue, nil } @@ -91,7 +90,6 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea firstParagraph.Parent().InsertBefore(firstParagraph.Parent(), firstParagraph, attentionParagraph) firstParagraph.RemoveChild(firstParagraph, firstTextNode) firstParagraph.RemoveChild(firstParagraph, secondTextNode) - firstParagraph.RemoveChild(firstParagraph, thirdTextNode) } return ast.WalkContinue, nil }) diff --git a/modules/markup/markdown/callout/github_legacy.go b/modules/markup/markdown/callout/github_legacy.go index eb15e1e64..32a278bc8 100644 --- a/modules/markup/markdown/callout/github_legacy.go +++ b/modules/markup/markdown/callout/github_legacy.go @@ -23,8 +23,7 @@ func (g *GitHubLegacyCalloutTransformer) Transform(node *ast.Document, reader te return ast.WalkContinue, nil } - switch v := n.(type) { - case *ast.Blockquote: + if v, ok := n.(*ast.Blockquote); ok { if v.ChildCount() == 0 { return ast.WalkContinue, nil } diff --git a/modules/repository/license.go b/modules/repository/license.go index 6ac3547e7..07ae92ca7 100644 --- a/modules/repository/license.go +++ b/modules/repository/license.go @@ -98,8 +98,7 @@ func getLicensePlaceholder(name string) *licensePlaceholder { // Some special placeholders for specific licenses. // It's unsafe to apply them to all licenses. - switch name { - case "0BSD": + if name == "0BSD" { return &licensePlaceholder{ Owner: []string{"AUTHOR"}, Email: []string{"EMAIL"}, diff --git a/modules/session/redis.go b/modules/session/redis.go index d89d8bc6e..d4cca3f43 100644 --- a/modules/session/redis.go +++ b/modules/session/redis.go @@ -122,8 +122,7 @@ func (p *RedisProvider) Init(maxlifetime int64, configs string) (err error) { uri := nosql.ToRedisURI(configs) for k, v := range uri.Query() { - switch k { - case "prefix": + if k == "prefix" { p.prefix = v[0] } } diff --git a/modules/structs/task.go b/modules/structs/task.go index ed11a33e2..84b618119 100644 --- a/modules/structs/task.go +++ b/modules/structs/task.go @@ -13,8 +13,9 @@ func (taskType TaskType) Name() string { switch taskType { case TaskTypeMigrateRepo: return "Migrate Repository" + default: + return "" } - return "" } // TaskStatus defines task status diff --git a/services/actions/workflows.go b/services/actions/workflows.go index 726b56f46..e2fb31622 100644 --- a/services/actions/workflows.go +++ b/services/actions/workflows.go @@ -83,12 +83,9 @@ func (entry *Workflow) Dispatch(ctx context.Context, inputGetter InputValueGette } continue } - } else { - switch input.Type { - case "boolean": - // Since "boolean" inputs are rendered as a checkbox in html, the value inside the form is "on" - val = strconv.FormatBool(val == "on") - } + } else if input.Type == "boolean" { + // Since "boolean" inputs are rendered as a checkbox in html, the value inside the form is "on" + val = strconv.FormatBool(val == "on") } inputs[key] = val } diff --git a/services/mailer/incoming/incoming_handler.go b/services/mailer/incoming/incoming_handler.go index c7e2193fc..dc3c4ec69 100644 --- a/services/mailer/incoming/incoming_handler.go +++ b/services/mailer/incoming/incoming_handler.go @@ -181,7 +181,7 @@ func (h *UnsubscribeHandler) Handle(ctx context.Context, _ *MailContent, doer *u } return issues_model.CreateOrUpdateIssueWatch(ctx, doer.ID, issue.ID, false) + default: + return fmt.Errorf("unsupported unsubscribe reference: %v", ref) } - - return fmt.Errorf("unsupported unsubscribe reference: %v", ref) } diff --git a/services/webhook/dingtalk.go b/services/webhook/dingtalk.go index ea3544243..899c5b2d9 100644 --- a/services/webhook/dingtalk.go +++ b/services/webhook/dingtalk.go @@ -160,8 +160,7 @@ func (dc dingtalkConvertor) PullRequest(p *api.PullRequestPayload) (DingtalkPayl // Review implements PayloadConvertor Review method func (dc dingtalkConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (DingtalkPayload, error) { var text, title string - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return DingtalkPayload{}, err diff --git a/services/webhook/discord.go b/services/webhook/discord.go index 80f6cfb79..b342b4569 100644 --- a/services/webhook/discord.go +++ b/services/webhook/discord.go @@ -215,8 +215,7 @@ func (d discordConvertor) PullRequest(p *api.PullRequestPayload) (DiscordPayload func (d discordConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (DiscordPayload, error) { var text, title string var color int - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return DiscordPayload{}, err diff --git a/services/webhook/matrix.go b/services/webhook/matrix.go index 06176e8dd..e70e7a2f8 100644 --- a/services/webhook/matrix.go +++ b/services/webhook/matrix.go @@ -237,8 +237,7 @@ func (m matrixConvertor) Review(p *api.PullRequestPayload, event webhook_module. repoLink := htmlLinkFormatter(p.Repository.HTMLURL, p.Repository.FullName) var text string - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return MatrixPayload{}, err diff --git a/services/webhook/msteams.go b/services/webhook/msteams.go index 3e9959146..736d084a8 100644 --- a/services/webhook/msteams.go +++ b/services/webhook/msteams.go @@ -225,8 +225,7 @@ func (m msteamsConvertor) PullRequest(p *api.PullRequestPayload) (MSTeamsPayload func (m msteamsConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (MSTeamsPayload, error) { var text, title string var color int - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return MSTeamsPayload{}, err diff --git a/services/webhook/slack.go b/services/webhook/slack.go index 3af483a90..af93976bd 100644 --- a/services/webhook/slack.go +++ b/services/webhook/slack.go @@ -289,8 +289,7 @@ func (s slackConvertor) Review(p *api.PullRequestPayload, event webhook_module.H repoLink := SlackLinkFormatter(p.Repository.HTMLURL, p.Repository.FullName) var text string - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return SlackPayload{}, err diff --git a/services/webhook/telegram.go b/services/webhook/telegram.go index 74eb13392..bacfa64db 100644 --- a/services/webhook/telegram.go +++ b/services/webhook/telegram.go @@ -164,8 +164,7 @@ func (t telegramConvertor) PullRequest(p *api.PullRequestPayload) (TelegramPaylo // Review implements PayloadConvertor Review method func (t telegramConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (TelegramPayload, error) { var text, attachmentText string - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return TelegramPayload{}, err diff --git a/services/webhook/wechatwork.go b/services/webhook/wechatwork.go index 0329cff12..87f8bb8b1 100644 --- a/services/webhook/wechatwork.go +++ b/services/webhook/wechatwork.go @@ -154,8 +154,7 @@ func (wc wechatworkConvertor) PullRequest(p *api.PullRequestPayload) (Wechatwork // Review implements PayloadConvertor Review method func (wc wechatworkConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (WechatworkPayload, error) { var text, title string - switch p.Action { - case api.HookIssueReviewed: + if p.Action == api.HookIssueReviewed { action, err := parseHookPullRequestEventType(event) if err != nil { return WechatworkPayload{}, err From 0813126058727d6a07d32b32ea33e30840ec0f43 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Wed, 31 Jul 2024 00:15:22 +0200 Subject: [PATCH 2/4] test: add more workflow event coverage --- modules/actions/workflows_test.go | 179 ++++++++++++++++-------------- 1 file changed, 98 insertions(+), 81 deletions(-) diff --git a/modules/actions/workflows_test.go b/modules/actions/workflows_test.go index 0042f5944..965d01f13 100644 --- a/modules/actions/workflows_test.go +++ b/modules/actions/workflows_test.go @@ -16,58 +16,67 @@ import ( func TestDetectMatched(t *testing.T) { testCases := []struct { - desc string - commit *git.Commit - triggedEvent webhook_module.HookEventType - payload api.Payloader - yamlOn string - expected bool + desc string + commit *git.Commit + triggeredEvent webhook_module.HookEventType + payload api.Payloader + yamlOn string + expected bool }{ { - desc: "HookEventCreate(create) matches GithubEventCreate(create)", - triggedEvent: webhook_module.HookEventCreate, - payload: nil, - yamlOn: "on: create", - expected: true, + desc: "HookEventCreate(create) matches GithubEventCreate(create)", + triggeredEvent: webhook_module.HookEventCreate, + payload: nil, + yamlOn: "on: create", + expected: true, }, { - desc: "HookEventIssues(issues) `opened` action matches GithubEventIssues(issues)", - triggedEvent: webhook_module.HookEventIssues, - payload: &api.IssuePayload{Action: api.HookIssueOpened}, - yamlOn: "on: issues", - expected: true, + desc: "HookEventIssues(issues) `opened` action matches GithubEventIssues(issues)", + triggeredEvent: webhook_module.HookEventIssues, + payload: &api.IssuePayload{Action: api.HookIssueOpened}, + yamlOn: "on: issues", + expected: true, }, { - desc: "HookEventIssues(issues) `milestoned` action matches GithubEventIssues(issues)", - triggedEvent: webhook_module.HookEventIssues, - payload: &api.IssuePayload{Action: api.HookIssueMilestoned}, - yamlOn: "on: issues", - expected: true, + desc: "HookEventIssueComment(issue_comment) `created` action matches GithubEventIssueComment(issue_comment)", + triggeredEvent: webhook_module.HookEventIssueComment, + payload: &api.IssueCommentPayload{Action: api.HookIssueCommentCreated}, + yamlOn: "on:\n issue_comment:\n types: [created]", + expected: true, + }, + + { + desc: "HookEventIssues(issues) `milestoned` action matches GithubEventIssues(issues)", + triggeredEvent: webhook_module.HookEventIssues, + payload: &api.IssuePayload{Action: api.HookIssueMilestoned}, + yamlOn: "on: issues", + expected: true, + }, + + { + desc: "HookEventPullRequestSync(pull_request_sync) matches GithubEventPullRequest(pull_request)", + triggeredEvent: webhook_module.HookEventPullRequestSync, + payload: &api.PullRequestPayload{Action: api.HookIssueSynchronized}, + yamlOn: "on: pull_request", + expected: true, }, { - desc: "HookEventPullRequestSync(pull_request_sync) matches GithubEventPullRequest(pull_request)", - triggedEvent: webhook_module.HookEventPullRequestSync, - payload: &api.PullRequestPayload{Action: api.HookIssueSynchronized}, - yamlOn: "on: pull_request", - expected: true, + desc: "HookEventPullRequest(pull_request) `label_updated` action doesn't match GithubEventPullRequest(pull_request) with no activity type", + triggeredEvent: webhook_module.HookEventPullRequest, + payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, + yamlOn: "on: pull_request", + expected: false, }, { - desc: "HookEventPullRequest(pull_request) `label_updated` action doesn't match GithubEventPullRequest(pull_request) with no activity type", - triggedEvent: webhook_module.HookEventPullRequest, - payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, - yamlOn: "on: pull_request", - expected: false, + desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with no activity type", + triggeredEvent: webhook_module.HookEventPullRequest, + payload: &api.PullRequestPayload{Action: api.HookIssueClosed}, + yamlOn: "on: pull_request", + expected: false, }, { - desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with no activity type", - triggedEvent: webhook_module.HookEventPullRequest, - payload: &api.PullRequestPayload{Action: api.HookIssueClosed}, - yamlOn: "on: pull_request", - expected: false, - }, - { - desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with branches", - triggedEvent: webhook_module.HookEventPullRequest, + desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with branches", + triggeredEvent: webhook_module.HookEventPullRequest, payload: &api.PullRequestPayload{ Action: api.HookIssueClosed, PullRequest: &api.PullRequest{ @@ -78,60 +87,68 @@ func TestDetectMatched(t *testing.T) { expected: false, }, { - desc: "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type", - triggedEvent: webhook_module.HookEventPullRequest, - payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, - yamlOn: "on:\n pull_request:\n types: [labeled]", - expected: true, + desc: "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type", + triggeredEvent: webhook_module.HookEventPullRequest, + payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, + yamlOn: "on:\n pull_request:\n types: [labeled]", + expected: true, }, { - desc: "HookEventPullRequestReviewComment(pull_request_review_comment) matches GithubEventPullRequestReviewComment(pull_request_review_comment)", - triggedEvent: webhook_module.HookEventPullRequestReviewComment, - payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, - yamlOn: "on:\n pull_request_review_comment:\n types: [created]", - expected: true, + desc: "HookEventPullRequestReviewComment(pull_request_review_comment) matches GithubEventPullRequestReviewComment(pull_request_review_comment)", + triggeredEvent: webhook_module.HookEventPullRequestReviewComment, + payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, + yamlOn: "on:\n pull_request_review_comment:\n types: [created]", + expected: true, }, { - desc: "HookEventPullRequestReviewRejected(pull_request_review_rejected) doesn't match GithubEventPullRequestReview(pull_request_review) with `dismissed` activity type (we don't support `dismissed` at present)", - triggedEvent: webhook_module.HookEventPullRequestReviewRejected, - payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, - yamlOn: "on:\n pull_request_review:\n types: [dismissed]", - expected: false, + desc: "HookEventPullRequestReviewRejected(pull_request_review_rejected) doesn't match GithubEventPullRequestReview(pull_request_review) with `dismissed` activity type (we don't support `dismissed` at present)", + triggeredEvent: webhook_module.HookEventPullRequestReviewRejected, + payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, + yamlOn: "on:\n pull_request_review:\n types: [dismissed]", + expected: false, }, { - desc: "HookEventRelease(release) `published` action matches GithubEventRelease(release) with `published` activity type", - triggedEvent: webhook_module.HookEventRelease, - payload: &api.ReleasePayload{Action: api.HookReleasePublished}, - yamlOn: "on:\n release:\n types: [published]", - expected: true, + desc: "HookEventRelease(release) `published` action matches GithubEventRelease(release) with `published` activity type", + triggeredEvent: webhook_module.HookEventRelease, + payload: &api.ReleasePayload{Action: api.HookReleasePublished}, + yamlOn: "on:\n release:\n types: [published]", + expected: true, }, { - desc: "HookEventPackage(package) `created` action doesn't match GithubEventRegistryPackage(registry_package) with `updated` activity type", - triggedEvent: webhook_module.HookEventPackage, - payload: &api.PackagePayload{Action: api.HookPackageCreated}, - yamlOn: "on:\n registry_package:\n types: [updated]", - expected: false, + desc: "HookEventRelease(updated) `updated` action matches GithubEventRelease(edited) with `edited` activity type", + triggeredEvent: webhook_module.HookEventRelease, + payload: &api.ReleasePayload{Action: api.HookReleaseUpdated}, + yamlOn: "on:\n release:\n types: [edited]", + expected: true, + }, + + { + desc: "HookEventPackage(package) `created` action doesn't match GithubEventRegistryPackage(registry_package) with `updated` activity type", + triggeredEvent: webhook_module.HookEventPackage, + payload: &api.PackagePayload{Action: api.HookPackageCreated}, + yamlOn: "on:\n registry_package:\n types: [updated]", + expected: false, }, { - desc: "HookEventWiki(wiki) matches GithubEventGollum(gollum)", - triggedEvent: webhook_module.HookEventWiki, - payload: nil, - yamlOn: "on: gollum", - expected: true, + desc: "HookEventWiki(wiki) matches GithubEventGollum(gollum)", + triggeredEvent: webhook_module.HookEventWiki, + payload: nil, + yamlOn: "on: gollum", + expected: true, }, { - desc: "HookEventSchedue(schedule) matches GithubEventSchedule(schedule)", - triggedEvent: webhook_module.HookEventSchedule, - payload: nil, - yamlOn: "on: schedule", - expected: true, + desc: "HookEventSchedule(schedule) matches GithubEventSchedule(schedule)", + triggeredEvent: webhook_module.HookEventSchedule, + payload: nil, + yamlOn: "on: schedule", + expected: true, }, { - desc: "HookEventWorkflowDispatch(workflow_dispatch) matches GithubEventWorkflowDispatch(workflow_dispatch)", - triggedEvent: webhook_module.HookEventWorkflowDispatch, - payload: nil, - yamlOn: "on: workflow_dispatch", - expected: true, + desc: "HookEventWorkflowDispatch(workflow_dispatch) matches GithubEventWorkflowDispatch(workflow_dispatch)", + triggeredEvent: webhook_module.HookEventWorkflowDispatch, + payload: nil, + yamlOn: "on: workflow_dispatch", + expected: true, }, } @@ -140,7 +157,7 @@ func TestDetectMatched(t *testing.T) { evts, err := GetEventsFromContent([]byte(tc.yamlOn)) require.NoError(t, err) assert.Len(t, evts, 1) - assert.Equal(t, tc.expected, detectMatched(nil, tc.commit, tc.triggedEvent, tc.payload, evts[0])) + assert.Equal(t, tc.expected, detectMatched(nil, tc.commit, tc.triggeredEvent, tc.payload, evts[0])) }) } } From 529bbbde4dff206e762aa8a61a1d743c209ffe78 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sun, 18 Aug 2024 15:37:42 +0200 Subject: [PATCH 3/4] style: change one argument switch to if --- routers/web/user/package.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routers/web/user/package.go b/routers/web/user/package.go index 204efe600..d47a36e16 100644 --- a/routers/web/user/package.go +++ b/routers/web/user/package.go @@ -208,8 +208,7 @@ func ViewPackageVersion(ctx *context.Context) { groups := make(container.Set[string]) for _, f := range pd.Files { for _, pp := range f.Properties { - switch pp.Name { - case arch_model.PropertyDistribution: + if pp.Name == arch_model.PropertyDistribution { groups.Add(pp.Value) } } From f7bb75ce56ca3319f9189c051cc537e0ad607d25 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sun, 18 Aug 2024 16:36:06 +0200 Subject: [PATCH 4/4] revert: accidental change --- modules/markup/markdown/callout/github.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/markup/markdown/callout/github.go b/modules/markup/markdown/callout/github.go index c6da30f7f..9b8b611d1 100644 --- a/modules/markup/markdown/callout/github.go +++ b/modules/markup/markdown/callout/github.go @@ -90,6 +90,7 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea firstParagraph.Parent().InsertBefore(firstParagraph.Parent(), firstParagraph, attentionParagraph) firstParagraph.RemoveChild(firstParagraph, firstTextNode) firstParagraph.RemoveChild(firstParagraph, secondTextNode) + firstParagraph.RemoveChild(firstParagraph, thirdTextNode) } return ast.WalkContinue, nil })