Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused route #18160

Merged
merged 3 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package repo

import (
"crypto/subtle"
"errors"
"fmt"
"html"
Expand Down Expand Up @@ -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, "", "")
6543 marked this conversation as resolved.
Show resolved Hide resolved
ctx.Status(202)
}

// CleanUpPullRequest responses for delete merged branch when PR has been merged
func CleanUpPullRequest(ctx *context.Context) {
issue := checkPullInfo(ctx)
Expand Down
25 changes: 0 additions & 25 deletions routers/web/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 0 additions & 2 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 *****
Expand Down