mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 19:47:07 +09:00
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:
2 files changed
+7
-2
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user