diff options
author | 6543 <6543@obermui.de> | 2021-04-05 17:30:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 11:30:52 -0400 |
commit | 16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7 (patch) | |
tree | 75d47012e9899ca24408aeef7fa3adfcd4beaed1 /routers/repo/pull.go | |
parent | e9fba18a26c9d0f8586254a83ef7afcd293a725a (diff) | |
download | gitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.tar.gz gitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.zip |
[refactor] replace int with httpStatusCodes (#15282)
* replace "200" (int) with "http.StatusOK" (const)
* ctx.Error & ctx.HTML
* ctx.JSON Part1
* ctx.JSON Part2
* ctx.JSON Part3
Diffstat (limited to 'routers/repo/pull.go')
-rw-r--r-- | routers/repo/pull.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go index cc6841da47..0002263013 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -167,7 +167,7 @@ func Fork(ctx *context.Context) { return } - ctx.HTML(200, tplFork) + ctx.HTML(http.StatusOK, tplFork) } // ForkPost response for forking a repository @@ -188,7 +188,7 @@ func ForkPost(ctx *context.Context) { ctx.Data["ContextUser"] = ctxUser if ctx.HasError() { - ctx.HTML(200, tplFork) + ctx.HTML(http.StatusOK, tplFork) return } @@ -221,7 +221,7 @@ func ForkPost(ctx *context.Context) { ctx.ServerError("IsOwnedBy", err) return } else if !isOwner { - ctx.Error(403) + ctx.Error(http.StatusForbidden) return } } @@ -570,7 +570,7 @@ func ViewPullCommits(ctx *context.Context) { ctx.Data["CommitCount"] = commits.Len() getBranchData(ctx, issue) - ctx.HTML(200, tplPullCommits) + ctx.HTML(http.StatusOK, tplPullCommits) } // ViewPullFiles render pull request changed files list page @@ -692,7 +692,7 @@ func ViewPullFiles(ctx *context.Context) { getBranchData(ctx, issue) ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID) ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) - ctx.HTML(200, tplPullFiles) + ctx.HTML(http.StatusOK, tplPullFiles) } // UpdatePullRequest merge PR's baseBranch into headBranch @@ -1015,7 +1015,7 @@ func CompareAndPullRequestPost(ctx *context.Context) { return } - ctx.HTML(200, tplCompareDiff) + ctx.HTML(http.StatusOK, tplCompareDiff) return } @@ -1054,7 +1054,7 @@ func CompareAndPullRequestPost(ctx *context.Context) { if err := pull_service.NewPullRequest(repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil { if models.IsErrUserDoesNotHaveAccessToRepo(err) { - ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error()) + ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error()) return } else if git.IsErrPushRejected(err) { pushrejErr := err.(*git.ErrPushRejected) @@ -1090,7 +1090,7 @@ func TriggerTask(ctx *context.Context) { branch := ctx.Query("branch") secret := ctx.Query("secret") if len(branch) == 0 || len(secret) == 0 || pusherID <= 0 { - ctx.Error(404) + ctx.Error(http.StatusNotFound) log.Trace("TriggerTask: branch or secret is empty, or pusher ID is not valid") return } @@ -1101,7 +1101,7 @@ func TriggerTask(ctx *context.Context) { got := []byte(base.EncodeMD5(owner.Salt)) want := []byte(secret) if subtle.ConstantTimeCompare(got, want) != 1 { - ctx.Error(404) + ctx.Error(http.StatusNotFound) log.Trace("TriggerTask [%s/%s]: invalid secret", owner.Name, repo.Name) return } @@ -1109,7 +1109,7 @@ func TriggerTask(ctx *context.Context) { pusher, err := models.GetUserByID(pusherID) if err != nil { if models.IsErrUserNotExist(err) { - ctx.Error(404) + ctx.Error(http.StatusNotFound) } else { ctx.ServerError("GetUserByID", err) } @@ -1179,7 +1179,7 @@ func CleanUpPullRequest(ctx *context.Context) { defer gitBaseRepo.Close() defer func() { - ctx.JSON(200, map[string]interface{}{ + ctx.JSON(http.StatusOK, map[string]interface{}{ "redirect": pr.BaseRepo.Link() + "/pulls/" + fmt.Sprint(issue.Index), }) }() |