aboutsummaryrefslogtreecommitdiffstats
path: root/models/release.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-05-21 10:28:29 +0800
committerGitHub <noreply@github.com>2018-05-21 10:28:29 +0800
commit6bdc556b7f490be7360104b731ce817050cc1d80 (patch)
tree63887addb45b5b2be1e672580c984497fa9f4112 /models/release.go
parentdc0ef38950ec8aca78f6e870fb83d1ca68074682 (diff)
downloadgitea-6bdc556b7f490be7360104b731ce817050cc1d80.tar.gz
gitea-6bdc556b7f490be7360104b731ce817050cc1d80.zip
Fix some webhooks bugs (#3981)
* fix some webhooks bugs * update vendor Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * fix test * fix clearlabels * fix pullrequest webhook bug fix #3492 * update release webhook description * remove unused code * fix push webhook in pull request * small changes
Diffstat (limited to 'models/release.go')
-rw-r--r--models/release.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/models/release.go b/models/release.go
index bc0260c71d..630995a741 100644
--- a/models/release.go
+++ b/models/release.go
@@ -207,6 +207,8 @@ func CreateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []stri
Sender: rel.Publisher.APIFormat(),
}); err != nil {
log.Error(2, "PrepareWebhooks: %v", err)
+ } else {
+ go HookQueue.Add(rel.Repo.ID)
}
}
}
@@ -371,7 +373,7 @@ func SortReleases(rels []*Release) {
}
// UpdateRelease updates information of a release.
-func UpdateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []string) (err error) {
+func UpdateRelease(doer *User, gitRepo *git.Repository, rel *Release, attachmentUUIDs []string) (err error) {
if err = createTag(gitRepo, rel); err != nil {
return err
}
@@ -382,8 +384,25 @@ func UpdateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []stri
return err
}
+ err = rel.loadAttributes(x)
+ if err != nil {
+ return err
+ }
+
err = addReleaseAttachments(rel.ID, attachmentUUIDs)
+ mode, _ := accessLevel(x, doer.ID, rel.Repo)
+ if err1 := PrepareWebhooks(rel.Repo, HookEventRelease, &api.ReleasePayload{
+ Action: api.HookReleaseUpdated,
+ Release: rel.APIFormat(),
+ Repository: rel.Repo.APIFormat(mode),
+ Sender: rel.Publisher.APIFormat(),
+ }); err1 != nil {
+ log.Error(2, "PrepareWebhooks: %v", err)
+ } else {
+ go HookQueue.Add(rel.Repo.ID)
+ }
+
return err
}
@@ -429,6 +448,18 @@ func DeleteReleaseByID(id int64, u *User, delTag bool) error {
}
}
+ mode, _ := accessLevel(x, u.ID, rel.Repo)
+ if err := PrepareWebhooks(rel.Repo, HookEventRelease, &api.ReleasePayload{
+ Action: api.HookReleaseDeleted,
+ Release: rel.APIFormat(),
+ Repository: rel.Repo.APIFormat(mode),
+ Sender: rel.Publisher.APIFormat(),
+ }); err != nil {
+ log.Error(2, "PrepareWebhooks: %v", err)
+ } else {
+ go HookQueue.Add(rel.Repo.ID)
+ }
+
return nil
}