aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-01-03 17:23:43 +0000
committerGitHub <noreply@github.com>2022-01-03 18:23:43 +0100
commit650a50a7ba8efcd8d02c4c93e5abc19f27e6c4b5 (patch)
treee23f5e66970a96be1599bfdd13fd203df005237b /routers
parent48aab263d1d60612be05a67c46172b5a5a718dba (diff)
downloadgitea-650a50a7ba8efcd8d02c4c93e5abc19f27e6c4b5.tar.gz
gitea-650a50a7ba8efcd8d02c4c93e5abc19f27e6c4b5.zip
Remove unused route "/tasks/trigger" (#18160)
ref: https://github.com/go-gitea/gitea/pull/18160#issuecomment-1004091325
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/pull.go39
-rw-r--r--routers/web/repo/setting.go25
-rw-r--r--routers/web/web.go2
3 files changed, 0 insertions, 66 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 1a6a5e55e6..37826abfb4 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -7,7 +7,6 @@
package repo
import (
- "crypto/subtle"
"errors"
"fmt"
"html"
@@ -1208,44 +1207,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
ctx.Redirect(pullIssue.Link())
}
-// TriggerTask response for a trigger task request
-func TriggerTask(ctx *context.Context) {
- pusherID := ctx.FormInt64("pusher")
- branch := ctx.FormString("branch")
- secret := ctx.FormString("secret")
- if len(branch) == 0 || len(secret) == 0 || pusherID <= 0 {
- ctx.Error(http.StatusNotFound)
- log.Trace("TriggerTask: branch or secret is empty, or pusher ID is not valid")
- return
- }
- owner, repo := parseOwnerAndRepo(ctx)
- if ctx.Written() {
- return
- }
- got := []byte(base.EncodeMD5(owner.Salt))
- want := []byte(secret)
- if subtle.ConstantTimeCompare(got, want) != 1 {
- ctx.Error(http.StatusNotFound)
- log.Trace("TriggerTask [%s/%s]: invalid secret", owner.Name, repo.Name)
- return
- }
-
- pusher, err := user_model.GetUserByID(pusherID)
- if err != nil {
- if user_model.IsErrUserNotExist(err) {
- ctx.Error(http.StatusNotFound)
- } else {
- ctx.ServerError("GetUserByID", err)
- }
- return
- }
-
- log.Trace("TriggerTask '%s/%s' by %s", repo.Name, branch, pusher.Name)
-
- go pull_service.AddTestPullRequestTask(pusher, repo.ID, branch, true, "", "")
- ctx.Status(202)
-}
-
// CleanUpPullRequest responses for delete merged branch when PR has been merged
func CleanUpPullRequest(ctx *context.Context) {
issue := checkPullInfo(ctx)
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index 7ff83cc3d7..b7269b6718 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -994,31 +994,6 @@ func DeleteTeam(ctx *context.Context) {
})
}
-// parseOwnerAndRepo get repos by owner
-func parseOwnerAndRepo(ctx *context.Context) (*user_model.User, *repo_model.Repository) {
- owner, err := user_model.GetUserByName(ctx.Params(":username"))
- if err != nil {
- if user_model.IsErrUserNotExist(err) {
- ctx.NotFound("GetUserByName", err)
- } else {
- ctx.ServerError("GetUserByName", err)
- }
- return nil, nil
- }
-
- repo, err := repo_model.GetRepositoryByName(owner.ID, ctx.Params(":reponame"))
- if err != nil {
- if repo_model.IsErrRepoNotExist(err) {
- ctx.NotFound("GetRepositoryByName", err)
- } else {
- ctx.ServerError("GetRepositoryByName", err)
- }
- return nil, nil
- }
-
- return owner, repo
-}
-
// GitHooks hooks of a repository
func GitHooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
diff --git a/routers/web/web.go b/routers/web/web.go
index 3589ec9bd6..2796904cee 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -1064,8 +1064,6 @@ func RegisterRoutes(m *web.Route) {
m.GetOptions("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", repo.GetPackFile)
m.GetOptions("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", repo.GetIdxFile)
}, ignSignInAndCsrf)
-
- m.Head("/tasks/trigger", repo.TriggerTask)
})
})
// ***** END: Repository *****