mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 16:44:41 +02:00
enhance(webhook): mention release assets in notifications (#39631)
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: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
bb58160aed
commit
1244e06d76
2 files changed
+7
-2
No files matched your search
@@ -255,6 +255,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
|
||||
}
|
||||
|
||||
|
||||
@@ -624,6 +624,7 @@ func TestGetWikiPayloadInfo(t *testing.T) {
|
||||
|
||||
func TestGetReleasePayloadInfo(t *testing.T) {
|
||||
p := pullReleaseTestPayload()
|
||||
p.Release.Attachments = []*api.Attachment{{}, {}}
|
||||
|
||||
cases := []struct {
|
||||
action api.HookReleaseAction
|
||||
@@ -632,12 +633,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,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user