Bump golangci-lint to 2.7.2, enable modernize stringsbuilder (#36180)

Fixes were done automatically by `make lint-go-fix`. These modernize
fixes are very readable.

Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
silverwind
2025-12-17 21:50:53 +01:00
committed by GitHub
parent ebf9b4dc6b
commit 1e22bd712f
16 changed files with 67 additions and 63 deletions

View File

@@ -208,13 +208,13 @@ func (s slackConvertor) Push(p *api.PushPayload) (SlackPayload, error) {
branchLink := SlackLinkToRef(p.Repo.HTMLURL, p.Ref)
text := fmt.Sprintf("[%s:%s] %s pushed by %s", repoLink, branchLink, commitString, p.Pusher.UserName)
var attachmentText string
var attachmentText strings.Builder
// for each commit, generate attachment text
for i, commit := range p.Commits {
attachmentText += fmt.Sprintf("%s: %s - %s", SlackLinkFormatter(commit.URL, commit.ID[:7]), SlackShortTextFormatter(commit.Message), SlackTextFormatter(commit.Author.Name))
attachmentText.WriteString(fmt.Sprintf("%s: %s - %s", SlackLinkFormatter(commit.URL, commit.ID[:7]), SlackShortTextFormatter(commit.Message), SlackTextFormatter(commit.Author.Name)))
// add linebreak to each commit but the last
if i < len(p.Commits)-1 {
attachmentText += "\n"
attachmentText.WriteString("\n")
}
}
@@ -222,7 +222,7 @@ func (s slackConvertor) Push(p *api.PushPayload) (SlackPayload, error) {
Color: s.Color,
Title: p.Repo.HTMLURL,
TitleLink: p.Repo.HTMLURL,
Text: attachmentText,
Text: attachmentText.String(),
}}), nil
}