enhance(webhook): mention release assets in notifications (#39631) (#39912)

Backport #39631 by @stackedbyaradhya

Release webhook notifications never mention attached files, although the
payload carries them.

The summary shared by all webhook providers now appends an asset count
like `(assets: 2)` for created and updated releases.

Closes https://github.com/go-gitea/gitea/issues/39630

Co-authored-by: Aradhya Jain <aradhyaj736@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
authored and GitHub committed 2026-10-21 07:05:55 +00:00
1 parent 01db50f0bf
commit 197e761471
2 files changed
+7 -2

No files matched your search

+4
View File
@@ -225,6 +225,10 @@ func getReleasePayloadInfo(p *api.ReleasePayload, linkFormatter linkFormatter, w
text += " by " + linkFormatter(setting.AppURL+url.PathEscape(p.Sender.UserName), p.Sender.UserName)
}
if p.Action != api.HookReleaseDeleted && len(p.Release.Attachments) > 0 {
text += fmt.Sprintf(" (assets: %d)", len(p.Release.Attachments))
}
return text, color
}
+3 -2
View File
@@ -579,6 +579,7 @@ func TestGetWikiPayloadInfo(t *testing.T) {
func TestGetReleasePayloadInfo(t *testing.T) {
p := pullReleaseTestPayload()
p.Release.Attachments = []*api.Attachment{{}, {}}
cases := []struct {
action api.HookReleaseAction
@@ -587,12 +588,12 @@ func TestGetReleasePayloadInfo(t *testing.T) {
}{
{
api.HookReleasePublished,
"[test/repo] Release created: v1.0 by user1",
"[test/repo] Release created: v1.0 by user1 (assets: 2)",
greenColor,
},
{
api.HookReleaseUpdated,
"[test/repo] Release updated: v1.0 by user1",
"[test/repo] Release updated: v1.0 by user1 (assets: 2)",
yellowColor,
},
{