1
0
Fork 0
forked from forgejo/forgejo

Remove unused route "/tasks/trigger" (#18160)

ref: https://github.com/go-gitea/gitea/pull/18160#issuecomment-1004091325
This commit is contained in:
Gusted 2022-01-03 17:23:43 +00:00 committed by GitHub
parent 48aab263d1
commit 650a50a7ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 66 deletions

View file

@ -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)