mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 04:12:10 +00:00
[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
This commit is contained in:
parent
e9fba18a26
commit
16dea6cebd
64 changed files with 504 additions and 441 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"fmt"
|
||||
"html"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -632,7 +633,7 @@ func CompareDiff(ctx *context.Context) {
|
|||
} else {
|
||||
ctx.Data["HasPullRequest"] = true
|
||||
ctx.Data["PullRequest"] = pr
|
||||
ctx.HTML(200, tplCompareDiff)
|
||||
ctx.HTML(http.StatusOK, tplCompareDiff)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -660,7 +661,7 @@ func CompareDiff(ctx *context.Context) {
|
|||
|
||||
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(models.UnitTypePullRequests)
|
||||
|
||||
ctx.HTML(200, tplCompare)
|
||||
ctx.HTML(http.StatusOK, tplCompare)
|
||||
}
|
||||
|
||||
// ExcerptBlob render blob excerpt contents
|
||||
|
@ -679,7 +680,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
chunkSize := gitdiff.BlobExcerptChunkSize
|
||||
commit, err := gitRepo.GetCommit(commitID)
|
||||
if err != nil {
|
||||
ctx.Error(500, "GetCommit")
|
||||
ctx.Error(http.StatusInternalServerError, "GetCommit")
|
||||
return
|
||||
}
|
||||
section := &gitdiff.DiffSection{
|
||||
|
@ -704,7 +705,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
idxRight = lastRight
|
||||
}
|
||||
if err != nil {
|
||||
ctx.Error(500, "getExcerptLines")
|
||||
ctx.Error(http.StatusInternalServerError, "getExcerptLines")
|
||||
return
|
||||
}
|
||||
if idxRight > lastRight {
|
||||
|
@ -735,7 +736,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
ctx.Data["fileName"] = filePath
|
||||
ctx.Data["AfterCommitID"] = commitID
|
||||
ctx.Data["Anchor"] = anchor
|
||||
ctx.HTML(200, tplBlobExcerpt)
|
||||
ctx.HTML(http.StatusOK, tplBlobExcerpt)
|
||||
}
|
||||
|
||||
func getExcerptLines(commit *git.Commit, filePath string, idxLeft int, idxRight int, chunkSize int) ([]*gitdiff.DiffLine, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue