diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-09-03 01:20:24 -0700 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-09-03 11:20:24 +0300 |
commit | b689bb61804fddfd2df8df7250522b0fc227484e (patch) | |
tree | 6cd96dfc3c0c7b2a0b265217f2893aa606307b0a /routers | |
parent | 79f7839633167bbb146a7b0d17ce0ec1c990d085 (diff) | |
download | gitea-b689bb61804fddfd2df8df7250522b0fc227484e.tar.gz gitea-b689bb61804fddfd2df8df7250522b0fc227484e.zip |
Webhooks for repo creation/deletion (#1663)
* Webhooks for repo creation/deletion
* add createHookTask
* Add handles for GetSlackPayload and GetDiscordPayload
Diffstat (limited to 'routers')
-rw-r--r-- | routers/admin/admin.go | 2 | ||||
-rw-r--r-- | routers/admin/repos.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/fork.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 10 | ||||
-rw-r--r-- | routers/repo/pull.go | 2 | ||||
-rw-r--r-- | routers/repo/repo.go | 8 | ||||
-rw-r--r-- | routers/repo/setting.go | 2 | ||||
-rw-r--r-- | routers/repo/webhook.go | 1 |
8 files changed, 15 insertions, 14 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go index d439544c8b..94b88a05c3 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -145,7 +145,7 @@ func Dashboard(ctx *context.Context) { err = models.DeleteRepositoryArchives() case cleanMissingRepos: success = ctx.Tr("admin.dashboard.delete_missing_repos_success") - err = models.DeleteMissingRepositories() + err = models.DeleteMissingRepositories(ctx.User) case gitGCRepos: success = ctx.Tr("admin.dashboard.git_gc_repos_success") err = models.GitGcRepos() diff --git a/routers/admin/repos.go b/routers/admin/repos.go index 7f885b34c9..12df6fba1e 100644 --- a/routers/admin/repos.go +++ b/routers/admin/repos.go @@ -39,7 +39,7 @@ func DeleteRepo(ctx *context.Context) { return } - if err := models.DeleteRepository(repo.MustOwner().ID, repo.ID); err != nil { + if err := models.DeleteRepository(ctx.User, repo.MustOwner().ID, repo.ID); err != nil { ctx.Handle(500, "DeleteRepository", err) return } diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go index e4f45004de..2f3addf692 100644 --- a/routers/api/v1/repo/fork.go +++ b/routers/api/v1/repo/fork.go @@ -73,7 +73,7 @@ func CreateFork(ctx *context.APIContext, form api.CreateForkOption) { } forker = org } - fork, err := models.ForkRepository(forker, repo, repo.Name, repo.Description) + fork, err := models.ForkRepository(ctx.User, forker, repo, repo.Name, repo.Description) if err != nil { ctx.Error(500, "ForkRepository", err) return diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 305daa064d..20393102fc 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -105,7 +105,7 @@ func Search(ctx *context.APIContext) { // CreateUserRepo create a repository for a user func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateRepoOption) { - repo, err := models.CreateRepository(owner, models.CreateRepoOptions{ + repo, err := models.CreateRepository(ctx.User, owner, models.CreateRepoOptions{ Name: opt.Name, Description: opt.Description, Gitignores: opt.Gitignores, @@ -121,7 +121,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR ctx.Error(422, "", err) } else { if repo != nil { - if err = models.DeleteRepository(ctx.User.ID, repo.ID); err != nil { + if err = models.DeleteRepository(ctx.User, ctx.User.ID, repo.ID); err != nil { log.Error(4, "DeleteRepository: %v", err) } } @@ -254,7 +254,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { return } - repo, err := models.MigrateRepository(ctxUser, models.MigrateRepoOptions{ + repo, err := models.MigrateRepository(ctx.User, ctxUser, models.MigrateRepoOptions{ Name: form.RepoName, Description: form.Description, IsPrivate: form.Private || setting.Repository.ForcePrivate, @@ -263,7 +263,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { }) if err != nil { if repo != nil { - if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { + if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil { log.Error(4, "DeleteRepository: %v", errDelete) } } @@ -345,7 +345,7 @@ func Delete(ctx *context.APIContext) { return } - if err := models.DeleteRepository(owner.ID, repo.ID); err != nil { + if err := models.DeleteRepository(ctx.User, owner.ID, repo.ID); err != nil { ctx.Error(500, "DeleteRepository", err) return } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index ad4a01ec94..47fcff3128 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -125,7 +125,7 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) { } } - repo, err := models.ForkRepository(ctxUser, forkRepo, form.RepoName, form.Description) + repo, err := models.ForkRepository(ctx.User, ctxUser, forkRepo, form.RepoName, form.Description) if err != nil { ctx.Data["Err_RepoName"] = true switch { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 5fcbb84b9a..ebbce1e19c 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -127,7 +127,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { return } - repo, err := models.CreateRepository(ctxUser, models.CreateRepoOptions{ + repo, err := models.CreateRepository(ctx.User, ctxUser, models.CreateRepoOptions{ Name: form.RepoName, Description: form.Description, Gitignores: form.Gitignores, @@ -143,7 +143,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { } if repo != nil { - if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { + if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil { log.Error(4, "DeleteRepository: %v", errDelete) } } @@ -204,7 +204,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { return } - repo, err := models.MigrateRepository(ctxUser, models.MigrateRepoOptions{ + repo, err := models.MigrateRepository(ctx.User, ctxUser, models.MigrateRepoOptions{ Name: form.RepoName, Description: form.Description, IsPrivate: form.Private || setting.Repository.ForcePrivate, @@ -218,7 +218,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { } if repo != nil { - if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { + if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil { log.Error(4, "DeleteRepository: %v", errDelete) } } diff --git a/routers/repo/setting.go b/routers/repo/setting.go index a50c6a6e22..8b38e80916 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -314,7 +314,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { } } - if err := models.DeleteRepository(ctx.Repo.Owner.ID, repo.ID); err != nil { + if err := models.DeleteRepository(ctx.User, ctx.Repo.Owner.ID, repo.ID); err != nil { ctx.Handle(500, "DeleteRepository", err) return } diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 4011b6f0e6..9c88b4385e 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -121,6 +121,7 @@ func ParseHookEvent(form auth.WebhookForm) *models.HookEvent { Create: form.Create, Push: form.Push, PullRequest: form.PullRequest, + Repository: form.Repository, }, } } |