summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-10 13:13:16 +0800
committerGitHub <noreply@github.com>2021-11-10 13:13:16 +0800
commit33fca2b537d36cf998dd27425b2bb8ed5b0965f3 (patch)
tree817f392502e1c176a5cd7e80290520cb940a8416 /modules
parentedbaa5d3f05b5ca397524587ba9db15edd61bc29 (diff)
downloadgitea-33fca2b537d36cf998dd27425b2bb8ed5b0965f3.tar.gz
gitea-33fca2b537d36cf998dd27425b2bb8ed5b0965f3.zip
Move webhook into models/webhook/ (#17579)
Diffstat (limited to 'modules')
-rw-r--r--modules/convert/convert.go9
-rw-r--r--modules/cron/tasks.go5
-rw-r--r--modules/cron/tasks_basic.go3
-rw-r--r--modules/migrations/update.go3
-rw-r--r--modules/notification/webhook/webhook.go79
-rw-r--r--modules/repository/check.go10
-rw-r--r--modules/repository/hooks.go2
7 files changed, 58 insertions, 53 deletions
diff --git a/modules/convert/convert.go b/modules/convert/convert.go
index 9c5e2037c5..7d67e2b5b1 100644
--- a/modules/convert/convert.go
+++ b/modules/convert/convert.go
@@ -14,11 +14,12 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/login"
"code.gitea.io/gitea/models/unit"
+ "code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
- "code.gitea.io/gitea/services/webhook"
+ webhook_service "code.gitea.io/gitea/services/webhook"
)
// ToEmail convert models.EmailAddress to api.Email
@@ -226,13 +227,13 @@ func ToGPGKeyEmail(email *models.EmailAddress) *api.GPGKeyEmail {
}
// ToHook convert models.Webhook to api.Hook
-func ToHook(repoLink string, w *models.Webhook) *api.Hook {
+func ToHook(repoLink string, w *webhook.Webhook) *api.Hook {
config := map[string]string{
"url": w.URL,
"content_type": w.ContentType.Name(),
}
- if w.Type == models.SLACK {
- s := webhook.GetSlackHook(w)
+ if w.Type == webhook.SLACK {
+ s := webhook_service.GetSlackHook(w)
config["channel"] = s.Channel
config["username"] = s.Username
config["icon_url"] = s.IconURL
diff --git a/modules/cron/tasks.go b/modules/cron/tasks.go
index 6f3a96fd3f..56c363e0b8 100644
--- a/modules/cron/tasks.go
+++ b/modules/cron/tasks.go
@@ -11,6 +11,7 @@ import (
"sync"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
@@ -86,8 +87,8 @@ func (t *Task) RunWithUser(doer *models.User, config Config) {
pid := pm.Add(config.FormatMessage(t.Name, "process", doer), cancel)
defer pm.Remove(pid)
if err := t.fun(ctx, doer, config); err != nil {
- if models.IsErrCancelled(err) {
- message := err.(models.ErrCancelled).Message
+ if db.IsErrCancelled(err) {
+ message := err.(db.ErrCancelled).Message
if err := models.CreateNotice(models.NoticeTask, config.FormatMessage(t.Name, "aborted", doer, message)); err != nil {
log.Error("CreateNotice: %v", err)
}
diff --git a/modules/cron/tasks_basic.go b/modules/cron/tasks_basic.go
index 6c61d628c5..a42c031b36 100644
--- a/modules/cron/tasks_basic.go
+++ b/modules/cron/tasks_basic.go
@@ -9,6 +9,7 @@ import (
"time"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/migrations"
repository_service "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
@@ -122,7 +123,7 @@ func registerCleanupHookTaskTable() {
NumberToKeep: 10,
}, func(ctx context.Context, _ *models.User, config Config) error {
realConfig := config.(*CleanupHookTaskConfig)
- return models.CleanupHookTaskTable(ctx, models.ToHookTaskCleanupType(realConfig.CleanupType), realConfig.OlderThan, realConfig.NumberToKeep)
+ return webhook.CleanupHookTaskTable(ctx, webhook.ToHookTaskCleanupType(realConfig.CleanupType), realConfig.OlderThan, realConfig.NumberToKeep)
})
}
diff --git a/modules/migrations/update.go b/modules/migrations/update.go
index e7a57ceca8..ddc9401ead 100644
--- a/modules/migrations/update.go
+++ b/modules/migrations/update.go
@@ -8,6 +8,7 @@ import (
"context"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/structs"
)
@@ -18,7 +19,7 @@ func UpdateMigrationPosterID(ctx context.Context) error {
select {
case <-ctx.Done():
log.Warn("UpdateMigrationPosterID aborted before %s", gitService.Name())
- return models.ErrCancelledf("during UpdateMigrationPosterID before %s", gitService.Name())
+ return db.ErrCancelledf("during UpdateMigrationPosterID before %s", gitService.Name())
default:
}
if err := updateMigrationPosterIDByGitService(ctx, gitService); err != nil {
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index 35f0cdc596..de6e19a065 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -7,6 +7,7 @@ package webhook
import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/unit"
+ "code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
@@ -49,7 +50,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
return
}
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequestLabel, &api.PullRequestPayload{
Action: api.HookIssueLabelCleared,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest, nil),
@@ -57,7 +58,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
Sender: convert.ToUser(doer, nil),
})
} else {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssueLabel, &api.IssuePayload{
Action: api.HookIssueLabelCleared,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
@@ -75,7 +76,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
mode, _ := models.AccessLevel(doer, repo)
// forked webhook
- if err := webhook_services.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
+ if err := webhook_services.PrepareWebhooks(oldRepo, webhook.HookEventFork, &api.ForkPayload{
Forkee: convert.ToRepo(oldRepo, oldMode),
Repo: convert.ToRepo(repo, mode),
Sender: convert.ToUser(doer, nil),
@@ -87,7 +88,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
// Add to hook queue for created repo after session commit.
if u.IsOrganization() {
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, nil),
@@ -100,7 +101,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
// Add to hook queue for created repo after session commit.
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, nil),
@@ -113,7 +114,7 @@ func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.Us
func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
u := repo.MustOwner()
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoDeleted,
Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, nil),
@@ -125,7 +126,7 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models
func (m *webhookNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
// Add to hook queue for created repo after session commit.
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventRepository, &api.RepositoryPayload{
Action: api.HookRepoCreated,
Repository: convert.ToRepo(repo, models.AccessModeOwner),
Organization: convert.ToUser(u, nil),
@@ -156,7 +157,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
apiPullRequest.Action = api.HookIssueAssigned
}
// Assignee comment triggers a webhook
- if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestAssign, apiPullRequest); err != nil {
+ if err := webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequestAssign, apiPullRequest); err != nil {
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
return
}
@@ -174,7 +175,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
apiIssue.Action = api.HookIssueAssigned
}
// Assignee comment triggers a webhook
- if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueAssign, apiIssue); err != nil {
+ if err := webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssueAssign, apiIssue); err != nil {
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
return
}
@@ -190,7 +191,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
return
}
issue.PullRequest.Issue = issue
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
@@ -203,7 +204,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
Sender: convert.ToUser(doer, nil),
})
} else {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssues, &api.IssuePayload{
Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
@@ -242,7 +243,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
} else {
apiPullRequest.Action = api.HookIssueReOpened
}
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest)
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequest, apiPullRequest)
} else {
apiIssue := &api.IssuePayload{
Index: issue.Index,
@@ -255,7 +256,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
} else {
apiIssue.Action = api.HookIssueReOpened
}
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue)
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssues, apiIssue)
}
if err != nil {
log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
@@ -273,7 +274,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models
}
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
- if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
+ if err := webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssues, &api.IssuePayload{
Action: api.HookIssueOpened,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
@@ -299,7 +300,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mention
}
mode, _ := models.AccessLevel(pull.Issue.Poster, pull.Issue.Repo)
- if err := webhook_services.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
+ if err := webhook_services.PrepareWebhooks(pull.Issue.Repo, webhook.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueOpened,
Index: pull.Issue.Index,
PullRequest: convert.ToAPIPullRequest(pull, nil),
@@ -315,7 +316,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
var err error
if issue.IsPull {
issue.PullRequest.Issue = issue
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
@@ -328,7 +329,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
Sender: convert.ToUser(doer, nil),
})
} else {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssues, &api.IssuePayload{
Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
@@ -365,7 +366,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
mode, _ := models.AccessLevel(doer, c.Issue.Repo)
if c.Issue.IsPull {
- err = webhook_services.PrepareWebhooks(c.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
+ err = webhook_services.PrepareWebhooks(c.Issue.Repo, webhook.HookEventPullRequestComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentEdited,
Issue: convert.ToAPIIssue(c.Issue),
Comment: convert.ToComment(c),
@@ -379,7 +380,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
IsPull: true,
})
} else {
- err = webhook_services.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
+ err = webhook_services.PrepareWebhooks(c.Issue.Repo, webhook.HookEventIssueComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentEdited,
Issue: convert.ToAPIIssue(c.Issue),
Comment: convert.ToComment(c),
@@ -405,7 +406,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
var err error
if issue.IsPull {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequestComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentCreated,
Issue: convert.ToAPIIssue(issue),
Comment: convert.ToComment(comment),
@@ -414,7 +415,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
IsPull: true,
})
} else {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssueComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentCreated,
Issue: convert.ToAPIIssue(issue),
Comment: convert.ToComment(comment),
@@ -449,7 +450,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
mode, _ := models.AccessLevel(doer, comment.Issue.Repo)
if comment.Issue.IsPull {
- err = webhook_services.PrepareWebhooks(comment.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
+ err = webhook_services.PrepareWebhooks(comment.Issue.Repo, webhook.HookEventPullRequestComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentDeleted,
Issue: convert.ToAPIIssue(comment.Issue),
Comment: convert.ToComment(comment),
@@ -458,7 +459,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
IsPull: true,
})
} else {
- err = webhook_services.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
+ err = webhook_services.PrepareWebhooks(comment.Issue.Repo, webhook.HookEventIssueComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentDeleted,
Issue: convert.ToAPIIssue(comment.Issue),
Comment: convert.ToComment(comment),
@@ -498,7 +499,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
log.Error("LoadIssue: %v", err)
return
}
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequestLabel, &api.PullRequestPayload{
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest, nil),
@@ -506,7 +507,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
Sender: convert.ToUser(doer, nil),
})
} else {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssueLabel, &api.IssuePayload{
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
@@ -540,7 +541,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m
log.Error("LoadIssue: %v", err)
return
}
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestMilestone, &api.PullRequestPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequestMilestone, &api.PullRequestPayload{
Action: hookAction,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(issue.PullRequest, nil),
@@ -548,7 +549,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m
Sender: convert.ToUser(doer, nil),
})
} else {
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueMilestone, &api.IssuePayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssueMilestone, &api.IssuePayload{
Action: hookAction,
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
@@ -569,7 +570,7 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re
return
}
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventPush, &api.PushPayload{
Ref: opts.RefFullName,
Before: opts.OldCommitID,
After: opts.NewCommitID,
@@ -616,7 +617,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod
Action: api.HookIssueClosed,
}
- err = webhook_services.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, apiPullRequest)
+ err = webhook_services.PrepareWebhooks(pr.Issue.Repo, webhook.HookEventPullRequest, apiPullRequest)
if err != nil {
log.Error("PrepareWebhooks: %v", err)
}
@@ -635,7 +636,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User,
}
issue.PullRequest.Issue = issue
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
- err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
+ err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueEdited,
Index: issue.Index,
Changes: &api.ChangesPayload{
@@ -654,15 +655,15 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User,
}
func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review *models.Review, comment *models.Comment, mentions []*models.User) {
- var reviewHookType models.HookEventType
+ var reviewHookType webhook.HookEventType
switch review.Type {
case models.ReviewTypeApprove:
- reviewHookType = models.HookEventPullRequestReviewApproved
+ reviewHookType = webhook.HookEventPullRequestReviewApproved
case models.ReviewTypeComment:
- reviewHookType = models.HookEventPullRequestComment
+ reviewHookType = webhook.HookEventPullRequestComment
case models.ReviewTypeReject:
- reviewHookType = models.HookEventPullRequestReviewRejected
+ reviewHookType = webhook.HookEventPullRequestReviewRejected
default:
// unsupported review webhook type here
log.Error("Unsupported review webhook type")
@@ -713,7 +714,7 @@ func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repo
}
gitRepo.Close()
- if err = webhook_services.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
+ if err = webhook_services.PrepareWebhooks(repo, webhook.HookEventCreate, &api.CreatePayload{
Ref: refName,
Sha: shaSum,
RefType: refType,
@@ -734,7 +735,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m
return
}
- if err := webhook_services.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequestSync, &api.PullRequestPayload{
+ if err := webhook_services.PrepareWebhooks(pr.Issue.Repo, webhook.HookEventPullRequestSync, &api.PullRequestPayload{
Action: api.HookIssueSynchronized,
Index: pr.Issue.Index,
PullRequest: convert.ToAPIPullRequest(pr, nil),
@@ -750,7 +751,7 @@ func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repo
apiRepo := convert.ToRepo(repo, models.AccessModeNone)
refName := git.RefEndName(refFullName)
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventDelete, &api.DeletePayload{
Ref: refName,
RefType: refType,
PusherType: api.PusherTypeUser,
@@ -768,7 +769,7 @@ func sendReleaseHook(doer *models.User, rel *models.Release, action api.HookRele
}
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo)
- if err := webhook_services.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
+ if err := webhook_services.PrepareWebhooks(rel.Repo, webhook.HookEventRelease, &api.ReleasePayload{
Action: action,
Release: convert.ToRelease(rel),
Repository: convert.ToRepo(rel.Repo, mode),
@@ -798,7 +799,7 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *model
return
}
- if err := webhook_services.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
+ if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventPush, &api.PushPayload{
Ref: opts.RefFullName,
Before: opts.OldCommitID,
After: opts.NewCommitID,
diff --git a/modules/repository/check.go b/modules/repository/check.go
index 78e6f8a901..1857242f50 100644
--- a/modules/repository/check.go
+++ b/modules/repository/check.go
@@ -31,7 +31,7 @@ func GitFsck(ctx context.Context, timeout time.Duration, args []string) error {
repo := bean.(*models.Repository)
select {
case <-ctx.Done():
- return models.ErrCancelledf("before fsck of %s", repo.FullName())
+ return db.ErrCancelledf("before fsck of %s", repo.FullName())
default:
}
log.Trace("Running health check on repository %v", repo)
@@ -66,7 +66,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
repo := bean.(*models.Repository)
select {
case <-ctx.Done():
- return models.ErrCancelledf("before GC of %s", repo.FullName())
+ return db.ErrCancelledf("before GC of %s", repo.FullName())
default:
}
log.Trace("Running git gc on %v", repo)
@@ -123,7 +123,7 @@ func gatherMissingRepoRecords(ctx context.Context) ([]*models.Repository, error)
repo := bean.(*models.Repository)
select {
case <-ctx.Done():
- return models.ErrCancelledf("during gathering missing repo records before checking %s", repo.FullName())
+ return db.ErrCancelledf("during gathering missing repo records before checking %s", repo.FullName())
default:
}
isDir, err := util.IsDir(repo.RepoPath())
@@ -161,7 +161,7 @@ func DeleteMissingRepositories(ctx context.Context, doer *models.User) error {
for _, repo := range repos {
select {
case <-ctx.Done():
- return models.ErrCancelledf("during DeleteMissingRepositories before %s", repo.FullName())
+ return db.ErrCancelledf("during DeleteMissingRepositories before %s", repo.FullName())
default:
}
log.Trace("Deleting %d/%d...", repo.OwnerID, repo.ID)
@@ -189,7 +189,7 @@ func ReinitMissingRepositories(ctx context.Context) error {
for _, repo := range repos {
select {
case <-ctx.Done():
- return models.ErrCancelledf("during ReinitMissingRepositories before %s", repo.FullName())
+ return db.ErrCancelledf("during ReinitMissingRepositories before %s", repo.FullName())
default:
}
log.Trace("Initializing %d/%d...", repo.OwnerID, repo.ID)
diff --git a/modules/repository/hooks.go b/modules/repository/hooks.go
index 63f00b8f80..23eee8897d 100644
--- a/modules/repository/hooks.go
+++ b/modules/repository/hooks.go
@@ -254,7 +254,7 @@ func SyncRepositoryHooks(ctx context.Context) error {
repo := bean.(*models.Repository)
select {
case <-ctx.Done():
- return models.ErrCancelledf("before sync repository hooks for %s", repo.FullName())
+ return db.ErrCancelledf("before sync repository hooks for %s", repo.FullName())
default:
}