aboutsummaryrefslogtreecommitdiffstats
path: root/models/webhook.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-24 16:05:56 -0700
committerUnknwon <u@gogs.io>2016-08-24 16:05:56 -0700
commit0b273ac4d566837b668d9e521476cd94ac28b6d4 (patch)
tree034db5238583a8f73bc5c83c2e4f1ae724eea092 /models/webhook.go
parent84b56c3c53fb931f569f9d0b5e2bf3832aba6abe (diff)
downloadgitea-0b273ac4d566837b668d9e521476cd94ac28b6d4.tar.gz
gitea-0b273ac4d566837b668d9e521476cd94ac28b6d4.zip
#3383 code cleanup
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/models/webhook.go b/models/webhook.go
index ad4ac189bb..01a014223b 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -210,15 +210,18 @@ func GetWebhookByOrgID(orgID, id int64) (*Webhook, error) {
}
// GetActiveWebhooksByRepoID returns all active webhooks of repository.
-func GetActiveWebhooksByRepoID(repoID int64) (ws []*Webhook, err error) {
- err = x.Where("repo_id=?", repoID).And("is_active=?", true).Find(&ws)
- return ws, err
+func GetActiveWebhooksByRepoID(repoID int64) ([]*Webhook, error) {
+ webhooks := make([]*Webhook, 0, 5)
+ return webhooks, x.Find(&webhooks, &Webhook{
+ RepoID: repoID,
+ IsActive: true,
+ })
}
-// GetWebhooksByRepoID returns all webhooks of repository.
-func GetWebhooksByRepoID(repoID int64) (ws []*Webhook, err error) {
- err = x.Find(&ws, &Webhook{RepoID: repoID})
- return ws, err
+// GetWebhooksByRepoID returns all webhooks of a repository.
+func GetWebhooksByRepoID(repoID int64) ([]*Webhook, error) {
+ webhooks := make([]*Webhook, 0, 5)
+ return webhooks, x.Find(&webhooks, &Webhook{RepoID: repoID})
}
// UpdateWebhook updates information of webhook.