1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Rename context.Query to context.Form (#16562)

This commit is contained in:
Lunny Xiao
2021-07-29 09:42:15 +08:00
committed by GitHub
parent 3705168837
commit 33e0b38287
85 changed files with 393 additions and 396 deletions

View File

@@ -71,7 +71,7 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) {
// DeleteAttachment response for deleting issue's attachment
func DeleteAttachment(ctx *context.Context) {
file := ctx.Query("file")
file := ctx.Form("file")
attach, err := models.GetAttachmentByUUID(file)
if err != nil {
ctx.Error(http.StatusBadRequest, err.Error())

View File

@@ -57,12 +57,12 @@ func Branches(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
ctx.Data["PageIsBranches"] = true
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
limit := ctx.QueryInt("limit")
limit := ctx.FormInt("limit")
if limit <= 0 || limit > setting.Git.BranchesRangeSize {
limit = setting.Git.BranchesRangeSize
}
@@ -84,7 +84,7 @@ func Branches(ctx *context.Context) {
// DeleteBranchPost responses for delete merged branch
func DeleteBranchPost(ctx *context.Context) {
defer redirect(ctx)
branchName := ctx.Query("name")
branchName := ctx.Form("name")
if err := repo_service.DeleteBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.GitRepo, branchName); err != nil {
switch {
@@ -112,8 +112,8 @@ func DeleteBranchPost(ctx *context.Context) {
func RestoreBranchPost(ctx *context.Context) {
defer redirect(ctx)
branchID := ctx.QueryInt64("branch_id")
branchName := ctx.Query("name")
branchID := ctx.FormInt64("branch_id")
branchName := ctx.Form("name")
deletedBranch, err := ctx.Repo.Repository.GetDeletedBranchByID(branchID)
if err != nil {

View File

@@ -56,12 +56,12 @@ func Commits(ctx *context.Context) {
return
}
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
pageSize := ctx.QueryInt("limit")
pageSize := ctx.FormInt("limit")
if pageSize <= 0 {
pageSize = setting.Git.CommitsRangeSize
}
@@ -94,14 +94,14 @@ func Graph(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.commit_graph")
ctx.Data["PageIsCommits"] = true
ctx.Data["PageIsViewCode"] = true
mode := strings.ToLower(ctx.QueryTrim("mode"))
mode := strings.ToLower(ctx.FormTrim("mode"))
if mode != "monochrome" {
mode = "color"
}
ctx.Data["Mode"] = mode
hidePRRefs := ctx.QueryBool("hide-pr-refs")
hidePRRefs := ctx.FormBool("hide-pr-refs")
ctx.Data["HidePRRefs"] = hidePRRefs
branches := ctx.QueryStrings("branch")
branches := ctx.FormStrings("branch")
realBranches := make([]string, len(branches))
copy(realBranches, branches)
for i, branch := range realBranches {
@@ -110,7 +110,7 @@ func Graph(ctx *context.Context) {
}
}
ctx.Data["SelectedBranches"] = realBranches
files := ctx.QueryStrings("file")
files := ctx.FormStrings("file")
commitsCount, err := ctx.Repo.GetCommitsCount()
if err != nil {
@@ -130,7 +130,7 @@ func Graph(ctx *context.Context) {
}
}
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
graph, err := gitgraph.GetCommitGraph(ctx.Repo.GitRepo, page, 0, hidePRRefs, realBranches, files)
if err != nil {
@@ -167,7 +167,7 @@ func Graph(ctx *context.Context) {
paginator.AddParamString("file", file)
}
ctx.Data["Page"] = paginator
if ctx.QueryBool("div-only") {
if ctx.FormBool("div-only") {
ctx.HTML(http.StatusOK, tplGraphDiv)
return
}
@@ -180,13 +180,13 @@ func SearchCommits(ctx *context.Context) {
ctx.Data["PageIsCommits"] = true
ctx.Data["PageIsViewCode"] = true
query := strings.Trim(ctx.Query("q"), " ")
query := strings.Trim(ctx.Form("q"), " ")
if len(query) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchNameSubURL())
return
}
all := ctx.QueryBool("all")
all := ctx.FormBool("all")
opts := git.NewSearchCommitsOptions(query, all)
commits, err := ctx.Repo.Commit.SearchCommits(opts)
if err != nil {
@@ -229,7 +229,7 @@ func FileHistory(ctx *context.Context) {
return
}
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}

View File

@@ -696,15 +696,15 @@ func CompareDiff(ctx *context.Context) {
// ExcerptBlob render blob excerpt contents
func ExcerptBlob(ctx *context.Context) {
commitID := ctx.Params("sha")
lastLeft := ctx.QueryInt("last_left")
lastRight := ctx.QueryInt("last_right")
idxLeft := ctx.QueryInt("left")
idxRight := ctx.QueryInt("right")
leftHunkSize := ctx.QueryInt("left_hunk_size")
rightHunkSize := ctx.QueryInt("right_hunk_size")
anchor := ctx.Query("anchor")
direction := ctx.Query("direction")
filePath := ctx.Query("path")
lastLeft := ctx.FormInt("last_left")
lastRight := ctx.FormInt("last_right")
idxLeft := ctx.FormInt("left")
idxRight := ctx.FormInt("right")
leftHunkSize := ctx.FormInt("left_hunk_size")
rightHunkSize := ctx.FormInt("right_hunk_size")
anchor := ctx.Form("anchor")
direction := ctx.Form("direction")
filePath := ctx.Form("path")
gitRepo := ctx.Repo.GitRepo
chunkSize := gitdiff.BlobExcerptChunkSize
commit, err := gitRepo.GetCommit(commitID)

View File

@@ -70,13 +70,13 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
username := ctx.Params(":username")
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
if ctx.Query("go-get") == "1" {
if ctx.Form("go-get") == "1" {
context.EarlyResponseForGoGetMeta(ctx)
return
}
var isPull, receivePack bool
service := ctx.Query("service")
service := ctx.Form("service")
if service == "git-receive-pack" ||
strings.HasSuffix(ctx.Req.URL.Path, "git-receive-pack") {
isPull = false

View File

@@ -110,15 +110,15 @@ func MustAllowPulls(ctx *context.Context) {
func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption util.OptionalBool) {
var err error
viewType := ctx.Query("type")
sortType := ctx.Query("sort")
viewType := ctx.Form("type")
sortType := ctx.Form("sort")
types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned", "review_requested"}
if !util.IsStringInSlice(viewType, types, true) {
viewType = "all"
}
var (
assigneeID = ctx.QueryInt64("assignee")
assigneeID = ctx.FormInt64("assignee")
posterID int64
mentionedID int64
reviewRequestedID int64
@@ -140,7 +140,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
repo := ctx.Repo.Repository
var labelIDs []int64
selectLabels := ctx.Query("labels")
selectLabels := ctx.Form("labels")
if len(selectLabels) > 0 && selectLabels != "0" {
labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
if err != nil {
@@ -149,7 +149,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
}
keyword := strings.Trim(ctx.Query("q"), " ")
keyword := strings.Trim(ctx.Form("q"), " ")
if bytes.Contains([]byte(keyword), []byte{0x00}) {
keyword = ""
}
@@ -187,13 +187,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
}
isShowClosed := ctx.Query("state") == "closed"
isShowClosed := ctx.Form("state") == "closed"
// if open issues are zero and close don't, use closed as default
if len(ctx.Query("state")) == 0 && issueStats.OpenCount == 0 && issueStats.ClosedCount != 0 {
if len(ctx.Form("state")) == 0 && issueStats.OpenCount == 0 && issueStats.ClosedCount != 0 {
isShowClosed = true
}
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
@@ -285,7 +285,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
if repo.Owner.IsOrganization() {
orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Query("sort"), models.ListOptions{})
orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Form("sort"), models.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByOrgID", err)
return
@@ -301,7 +301,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
ctx.Data["Labels"] = labels
ctx.Data["NumLabels"] = len(labels)
if ctx.QueryInt64("assignee") == 0 {
if ctx.FormInt64("assignee") == 0 {
assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
}
@@ -371,7 +371,7 @@ func Issues(ctx *context.Context) {
ctx.Data["NewIssueChooseTemplate"] = len(ctx.IssueTemplatesFromDefaultBranch()) > 0
}
issues(ctx, ctx.QueryInt64("milestone"), ctx.QueryInt64("project"), util.OptionalBoolOf(isPullList))
issues(ctx, ctx.FormInt64("milestone"), ctx.FormInt64("project"), util.OptionalBoolOf(isPullList))
if ctx.Written() {
return
}
@@ -380,7 +380,7 @@ func Issues(ctx *context.Context) {
// Get milestones
ctx.Data["Milestones"], err = models.GetMilestones(models.GetMilestonesOption{
RepoID: ctx.Repo.Repository.ID,
State: api.StateType(ctx.Query("state")),
State: api.StateType(ctx.Form("state")),
})
if err != nil {
ctx.ServerError("GetAllRepoMilestones", err)
@@ -655,7 +655,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository, isPull boo
}
ctx.Data["Labels"] = labels
if repo.Owner.IsOrganization() {
orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Query("sort"), models.ListOptions{})
orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Form("sort"), models.ListOptions{})
if err != nil {
return nil
}
@@ -719,9 +719,9 @@ func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (str
func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs []string, possibleFiles []string) {
templateCandidates := make([]string, 0, len(possibleFiles))
if ctx.Query("template") != "" {
if ctx.Form("template") != "" {
for _, dirName := range possibleDirs {
templateCandidates = append(templateCandidates, path.Join(dirName, ctx.Query("template")))
templateCandidates = append(templateCandidates, path.Join(dirName, ctx.Form("template")))
}
}
templateCandidates = append(templateCandidates, possibleFiles...) // Append files to the end because they should be fallback
@@ -741,7 +741,7 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs [
if repoLabels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, "", models.ListOptions{}); err == nil {
ctx.Data["Labels"] = repoLabels
if ctx.Repo.Owner.IsOrganization() {
if orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.Query("sort"), models.ListOptions{}); err == nil {
if orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.Form("sort"), models.ListOptions{}); err == nil {
ctx.Data["OrgLabels"] = orgLabels
repoLabels = append(repoLabels, orgLabels...)
}
@@ -773,16 +773,16 @@ func NewIssue(ctx *context.Context) {
ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
title := ctx.Query("title")
title := ctx.Form("title")
ctx.Data["TitleQuery"] = title
body := ctx.Query("body")
body := ctx.Form("body")
ctx.Data["BodyQuery"] = body
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(models.UnitTypeProjects)
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
upload.AddUploadContext(ctx, "comment")
milestoneID := ctx.QueryInt64("milestone")
milestoneID := ctx.FormInt64("milestone")
if milestoneID > 0 {
milestone, err := models.GetMilestoneByID(milestoneID)
if err != nil {
@@ -793,7 +793,7 @@ func NewIssue(ctx *context.Context) {
}
}
projectID := ctx.QueryInt64("project")
projectID := ctx.FormInt64("project")
if projectID > 0 {
project, err := models.GetProjectByID(projectID)
if err != nil {
@@ -822,7 +822,7 @@ func NewIssue(ctx *context.Context) {
func NewIssueChooseTemplate(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
ctx.Data["milestone"] = ctx.QueryInt64("milestone")
ctx.Data["milestone"] = ctx.FormInt64("milestone")
issueTemplates := ctx.IssueTemplatesFromDefaultBranch()
ctx.Data["NewIssueChooseTemplate"] = len(issueTemplates) > 0
@@ -1174,7 +1174,7 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Labels"] = labels
if repo.Owner.IsOrganization() {
orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Query("sort"), models.ListOptions{})
orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Form("sort"), models.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByOrgID", err)
return
@@ -1624,7 +1624,7 @@ func checkIssueRights(ctx *context.Context, issue *models.Issue) {
}
func getActionIssues(ctx *context.Context) []*models.Issue {
commaSeparatedIssueIDs := ctx.Query("issue_ids")
commaSeparatedIssueIDs := ctx.Form("issue_ids")
if len(commaSeparatedIssueIDs) == 0 {
return nil
}
@@ -1670,7 +1670,7 @@ func UpdateIssueTitle(ctx *context.Context) {
return
}
title := ctx.QueryTrim("title")
title := ctx.FormTrim("title")
if len(title) == 0 {
ctx.Error(http.StatusNoContent)
return
@@ -1698,7 +1698,7 @@ func UpdateIssueRef(ctx *context.Context) {
return
}
ref := ctx.QueryTrim("ref")
ref := ctx.FormTrim("ref")
if err := issue_service.ChangeIssueRef(issue, ctx.User, ref); err != nil {
ctx.ServerError("ChangeRef", err)
@@ -1722,20 +1722,20 @@ func UpdateIssueContent(ctx *context.Context) {
return
}
content := ctx.Query("content")
content := ctx.Form("content")
if err := issue_service.ChangeContent(issue, ctx.User, content); err != nil {
ctx.ServerError("ChangeContent", err)
return
}
files := ctx.QueryStrings("files[]")
files := ctx.FormStrings("files[]")
if err := updateAttachments(issue, files); err != nil {
ctx.ServerError("UpdateAttachments", err)
return
}
content, err := markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Query("context"),
URLPrefix: ctx.Form("context"),
Metas: ctx.Repo.Repository.ComposeMetas(),
GitRepo: ctx.Repo.GitRepo,
}, issue.Content)
@@ -1757,7 +1757,7 @@ func UpdateIssueMilestone(ctx *context.Context) {
return
}
milestoneID := ctx.QueryInt64("id")
milestoneID := ctx.FormInt64("id")
for _, issue := range issues {
oldMilestoneID := issue.MilestoneID
if oldMilestoneID == milestoneID {
@@ -1782,8 +1782,8 @@ func UpdateIssueAssignee(ctx *context.Context) {
return
}
assigneeID := ctx.QueryInt64("id")
action := ctx.Query("action")
assigneeID := ctx.FormInt64("id")
action := ctx.Form("action")
for _, issue := range issues {
switch action {
@@ -1828,8 +1828,8 @@ func UpdatePullReviewRequest(ctx *context.Context) {
return
}
reviewID := ctx.QueryInt64("id")
action := ctx.Query("action")
reviewID := ctx.FormInt64("id")
action := ctx.Form("action")
// TODO: Not support 'clear' now
if action != "attach" && action != "detach" {
@@ -1954,7 +1954,7 @@ func UpdateIssueStatus(ctx *context.Context) {
}
var isClosed bool
switch action := ctx.Query("action"); action {
switch action := ctx.Form("action"); action {
case "open":
isClosed = false
case "close":
@@ -2145,7 +2145,7 @@ func UpdateCommentContent(ctx *context.Context) {
}
oldContent := comment.Content
comment.Content = ctx.Query("content")
comment.Content = ctx.Form("content")
if len(comment.Content) == 0 {
ctx.JSON(http.StatusOK, map[string]interface{}{
"content": "",
@@ -2157,14 +2157,14 @@ func UpdateCommentContent(ctx *context.Context) {
return
}
files := ctx.QueryStrings("files[]")
files := ctx.FormStrings("files[]")
if err := updateAttachments(comment, files); err != nil {
ctx.ServerError("UpdateAttachments", err)
return
}
content, err := markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Query("context"),
URLPrefix: ctx.Form("context"),
Metas: ctx.Repo.Repository.ComposeMetas(),
GitRepo: ctx.Repo.GitRepo,
}, comment.Content)

View File

@@ -27,7 +27,7 @@ func AddDependency(ctx *context.Context) {
return
}
depID := ctx.QueryInt64("newDependency")
depID := ctx.FormInt64("newDependency")
if err = issue.LoadRepo(); err != nil {
ctx.ServerError("LoadRepo", err)
@@ -86,7 +86,7 @@ func RemoveDependency(ctx *context.Context) {
return
}
depID := ctx.QueryInt64("removeDependencyID")
depID := ctx.FormInt64("removeDependencyID")
if err = issue.LoadRepo(); err != nil {
ctx.ServerError("LoadRepo", err)

View File

@@ -53,7 +53,7 @@ func InitializeLabels(ctx *context.Context) {
// RetrieveLabels find all the labels of a repository and organization
func RetrieveLabels(ctx *context.Context) {
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"), models.ListOptions{})
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Form("sort"), models.ListOptions{})
if err != nil {
ctx.ServerError("RetrieveLabels.GetLabels", err)
return
@@ -66,7 +66,7 @@ func RetrieveLabels(ctx *context.Context) {
ctx.Data["Labels"] = labels
if ctx.Repo.Owner.IsOrganization() {
orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.Query("sort"), models.ListOptions{})
orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.Form("sort"), models.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByOrgID", err)
return
@@ -93,7 +93,7 @@ func RetrieveLabels(ctx *context.Context) {
}
}
ctx.Data["NumLabels"] = len(labels)
ctx.Data["SortType"] = ctx.Query("sort")
ctx.Data["SortType"] = ctx.Form("sort")
}
// NewLabel create new label for repository
@@ -147,7 +147,7 @@ func UpdateLabel(ctx *context.Context) {
// DeleteLabel delete a label
func DeleteLabel(ctx *context.Context) {
if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteLabel: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
@@ -165,7 +165,7 @@ func UpdateIssueLabel(ctx *context.Context) {
return
}
switch action := ctx.Query("action"); action {
switch action := ctx.Form("action"); action {
case "clear":
for _, issue := range issues {
if err := issue_service.ClearLabels(issue, ctx.User); err != nil {
@@ -174,7 +174,7 @@ func UpdateIssueLabel(ctx *context.Context) {
}
}
case "attach", "detach", "toggle":
label, err := models.GetLabelByID(ctx.QueryInt64("id"))
label, err := models.GetLabelByID(ctx.FormInt64("id"))
if err != nil {
if models.IsErrRepoLabelNotExist(err) {
ctx.Error(http.StatusNotFound, "GetLabelByID")

View File

@@ -42,7 +42,7 @@ func LFSFiles(ctx *context.Context) {
ctx.NotFound("LFSFiles", nil)
return
}
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
@@ -74,7 +74,7 @@ func LFSLocks(ctx *context.Context) {
}
ctx.Data["LFSFilesLink"] = ctx.Repo.RepoLink + "/settings/lfs"
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
@@ -195,7 +195,7 @@ func LFSLockFile(ctx *context.Context) {
ctx.NotFound("LFSLocks", nil)
return
}
originalPath := ctx.Query("path")
originalPath := ctx.Form("path")
lockPath := originalPath
if len(lockPath) == 0 {
ctx.Flash.Error(ctx.Tr("repo.settings.lfs_invalid_locking_path", originalPath))
@@ -366,13 +366,13 @@ func LFSFileFind(ctx *context.Context) {
ctx.NotFound("LFSFind", nil)
return
}
oid := ctx.Query("oid")
size := ctx.QueryInt64("size")
oid := ctx.Form("oid")
size := ctx.FormInt64("size")
if len(oid) == 0 || size == 0 {
ctx.NotFound("LFSFind", nil)
return
}
sha := ctx.Query("sha")
sha := ctx.Form("sha")
ctx.Data["Title"] = oid
ctx.Data["PageIsSettingsLFS"] = true
var hash git.SHA1
@@ -511,7 +511,7 @@ func LFSAutoAssociate(ctx *context.Context) {
ctx.NotFound("LFSAutoAssociate", nil)
return
}
oids := ctx.QueryStrings("oid")
oids := ctx.FormStrings("oid")
metas := make([]*models.LFSMetaObject, len(oids))
for i, oid := range oids {
idx := strings.IndexRune(oid, ' ')

View File

@@ -34,7 +34,7 @@ func SetEditorconfigIfExists(ctx *context.Context) {
// SetDiffViewStyle set diff style as render variable
func SetDiffViewStyle(ctx *context.Context) {
queryStyle := ctx.Query("style")
queryStyle := ctx.Form("style")
if !ctx.IsSigned {
ctx.Data["IsSplitStyle"] = queryStyle == "split"
@@ -62,7 +62,7 @@ func SetDiffViewStyle(ctx *context.Context) {
// SetWhitespaceBehavior set whitespace behavior as render variable
func SetWhitespaceBehavior(ctx *context.Context) {
whitespaceBehavior := ctx.Query("whitespace")
whitespaceBehavior := ctx.Form("whitespace")
switch whitespaceBehavior {
case "ignore-all", "ignore-eol", "ignore-change":
ctx.Data["WhitespaceBehavior"] = whitespaceBehavior

View File

@@ -34,29 +34,29 @@ func Migrate(ctx *context.Context) {
return
}
serviceType := structs.GitServiceType(ctx.QueryInt("service_type"))
serviceType := structs.GitServiceType(ctx.FormInt("service_type"))
setMigrationContextData(ctx, serviceType)
if serviceType == 0 {
ctx.Data["Org"] = ctx.Query("org")
ctx.Data["Mirror"] = ctx.Query("mirror")
ctx.Data["Org"] = ctx.Form("org")
ctx.Data["Mirror"] = ctx.Form("mirror")
ctx.HTML(http.StatusOK, tplMigrate)
return
}
ctx.Data["private"] = getRepoPrivate(ctx)
ctx.Data["mirror"] = ctx.Query("mirror") == "1"
ctx.Data["lfs"] = ctx.Query("lfs") == "1"
ctx.Data["wiki"] = ctx.Query("wiki") == "1"
ctx.Data["milestones"] = ctx.Query("milestones") == "1"
ctx.Data["labels"] = ctx.Query("labels") == "1"
ctx.Data["issues"] = ctx.Query("issues") == "1"
ctx.Data["pull_requests"] = ctx.Query("pull_requests") == "1"
ctx.Data["releases"] = ctx.Query("releases") == "1"
ctx.Data["mirror"] = ctx.Form("mirror") == "1"
ctx.Data["lfs"] = ctx.Form("lfs") == "1"
ctx.Data["wiki"] = ctx.Form("wiki") == "1"
ctx.Data["milestones"] = ctx.Form("milestones") == "1"
ctx.Data["labels"] = ctx.Form("labels") == "1"
ctx.Data["issues"] = ctx.Form("issues") == "1"
ctx.Data["pull_requests"] = ctx.Form("pull_requests") == "1"
ctx.Data["releases"] = ctx.Form("releases") == "1"
ctxUser := checkContextUser(ctx, ctx.QueryInt64("org"))
ctxUser := checkContextUser(ctx, ctx.FormInt64("org"))
if ctx.Written() {
return
}

View File

@@ -36,7 +36,7 @@ func Milestones(ctx *context.Context) {
ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsMilestones"] = true
isShowClosed := ctx.Query("state") == "closed"
isShowClosed := ctx.Form("state") == "closed"
stats, err := models.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}))
if err != nil {
ctx.ServerError("MilestoneStats", err)
@@ -45,11 +45,11 @@ func Milestones(ctx *context.Context) {
ctx.Data["OpenCount"] = stats.OpenCount
ctx.Data["ClosedCount"] = stats.ClosedCount
sortType := ctx.Query("sort")
sortType := ctx.Form("sort")
keyword := strings.Trim(ctx.Query("q"), " ")
keyword := strings.Trim(ctx.Form("q"), " ")
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
@@ -253,7 +253,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
// DeleteMilestone delete a milestone
func DeleteMilestone(ctx *context.Context) {
if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))

View File

@@ -46,11 +46,11 @@ func MustEnableProjects(ctx *context.Context) {
func Projects(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.project_board")
sortType := ctx.QueryTrim("sort")
sortType := ctx.FormTrim("sort")
isShowClosed := strings.ToLower(ctx.QueryTrim("state")) == "closed"
isShowClosed := strings.ToLower(ctx.FormTrim("state")) == "closed"
repo := ctx.Repo.Repository
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}
@@ -346,7 +346,7 @@ func UpdateIssueProject(ctx *context.Context) {
return
}
projectID := ctx.QueryInt64("id")
projectID := ctx.FormInt64("id")
for _, issue := range issues {
oldProjectID := issue.ProjectID()
if oldProjectID == projectID {

View File

@@ -1128,9 +1128,9 @@ func CompareAndPullRequestPost(ctx *context.Context) {
// TriggerTask response for a trigger task request
func TriggerTask(ctx *context.Context) {
pusherID := ctx.QueryInt64("pusher")
branch := ctx.Query("branch")
secret := ctx.Query("secret")
pusherID := ctx.FormInt64("pusher")
branch := ctx.Form("branch")
secret := ctx.Form("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")
@@ -1347,7 +1347,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
return
}
targetBranch := ctx.QueryTrim("target_branch")
targetBranch := ctx.FormTrim("target_branch")
if len(targetBranch) == 0 {
ctx.Error(http.StatusNoContent)
return

View File

@@ -101,9 +101,9 @@ func CreateCodeComment(ctx *context.Context) {
// UpdateResolveConversation add or remove an Conversation resolved mark
func UpdateResolveConversation(ctx *context.Context) {
origin := ctx.Query("origin")
action := ctx.Query("action")
commentID := ctx.QueryInt64("comment_id")
origin := ctx.Form("origin")
action := ctx.Form("action")
commentID := ctx.FormInt64("comment_id")
comment, err := models.GetCommentByID(commentID)
if err != nil {

View File

@@ -96,8 +96,8 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
opts := models.FindReleasesOptions{
ListOptions: models.ListOptions{
Page: ctx.QueryInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
Page: ctx.FormInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
},
IncludeDrafts: writeAccess && !isTagList,
IncludeTags: isTagList,
@@ -252,7 +252,7 @@ func NewRelease(ctx *context.Context) {
ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch
if tagName := ctx.Query("tag"); len(tagName) > 0 {
if tagName := ctx.Form("tag"); len(tagName) > 0 {
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
if err != nil && !models.IsErrReleaseNotExist(err) {
ctx.ServerError("GetRelease", err)
@@ -507,7 +507,7 @@ func DeleteTag(ctx *context.Context) {
}
func deleteReleaseOrTag(ctx *context.Context, isDelTag bool) {
if err := releaseservice.DeleteReleaseByID(ctx.QueryInt64("id"), ctx.User, isDelTag); err != nil {
if err := releaseservice.DeleteReleaseByID(ctx.FormInt64("id"), ctx.User, isDelTag); err != nil {
ctx.Flash.Error("DeleteReleaseByID: " + err.Error())
} else {
if isDelTag {

View File

@@ -133,14 +133,14 @@ func Create(ctx *context.Context) {
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
ctx.Data["default_branch"] = setting.Repository.DefaultBranch
ctxUser := checkContextUser(ctx, ctx.QueryInt64("org"))
ctxUser := checkContextUser(ctx, ctx.FormInt64("org"))
if ctx.Written() {
return
}
ctx.Data["ContextUser"] = ctxUser
ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select")
templateID := ctx.QueryInt64("template_id")
templateID := ctx.FormInt64("template_id")
if templateID > 0 {
templateRepo, err := models.GetRepositoryByID(templateID)
if err == nil && templateRepo.CheckUnitUser(ctxUser, models.UnitTypeCode) {
@@ -291,8 +291,8 @@ func Action(ctx *context.Context) {
return
}
ctx.Repo.Repository.Description = ctx.Query("desc")
ctx.Repo.Repository.Website = ctx.Query("site")
ctx.Repo.Repository.Description = ctx.Form("desc")
ctx.Repo.Repository.Website = ctx.Form("site")
err = models.UpdateRepository(ctx.Repo.Repository, false)
}
@@ -301,7 +301,7 @@ func Action(ctx *context.Context) {
return
}
ctx.RedirectToFirst(ctx.Query("redirect_to"), ctx.Repo.RepoLink)
ctx.RedirectToFirst(ctx.Form("redirect_to"), ctx.Repo.RepoLink)
}
func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {

View File

@@ -22,13 +22,13 @@ func Search(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink, 302)
return
}
language := strings.TrimSpace(ctx.Query("l"))
keyword := strings.TrimSpace(ctx.Query("q"))
page := ctx.QueryInt("page")
language := strings.TrimSpace(ctx.Form("l"))
keyword := strings.TrimSpace(ctx.Form("q"))
page := ctx.FormInt("page")
if page <= 0 {
page = 1
}
queryType := strings.TrimSpace(ctx.Query("t"))
queryType := strings.TrimSpace(ctx.Form("t"))
isMatch := queryType == "match"
total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch([]int64{ctx.Repo.Repository.ID},

View File

@@ -70,7 +70,7 @@ func SettingsPost(ctx *context.Context) {
repo := ctx.Repo.Repository
switch ctx.Query("action") {
switch ctx.Form("action") {
case "update":
if ctx.HasError() {
ctx.HTML(http.StatusOK, tplSettingsOptions)
@@ -560,7 +560,7 @@ func SettingsPost(ctx *context.Context) {
return
}
newOwner, err := models.GetUserByName(ctx.Query("new_owner_name"))
newOwner, err := models.GetUserByName(ctx.Form("new_owner_name"))
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), tplSettingsOptions, nil)
@@ -775,7 +775,7 @@ func Collaboration(ctx *context.Context) {
// CollaborationPost response for actions for a collaboration of a repository
func CollaborationPost(ctx *context.Context) {
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Query("collaborator")))
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("collaborator")))
if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path)
return
@@ -827,15 +827,15 @@ func CollaborationPost(ctx *context.Context) {
// ChangeCollaborationAccessMode response for changing access of a collaboration
func ChangeCollaborationAccessMode(ctx *context.Context) {
if err := ctx.Repo.Repository.ChangeCollaborationAccessMode(
ctx.QueryInt64("uid"),
models.AccessMode(ctx.QueryInt("mode"))); err != nil {
ctx.FormInt64("uid"),
models.AccessMode(ctx.FormInt("mode"))); err != nil {
log.Error("ChangeCollaborationAccessMode: %v", err)
}
}
// DeleteCollaboration delete a collaboration for a repository
func DeleteCollaboration(ctx *context.Context) {
if err := ctx.Repo.Repository.DeleteCollaboration(ctx.QueryInt64("id")); err != nil {
if err := ctx.Repo.Repository.DeleteCollaboration(ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteCollaboration: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
@@ -854,7 +854,7 @@ func AddTeamPost(ctx *context.Context) {
return
}
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Query("team")))
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("team")))
if len(name) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
return
@@ -900,7 +900,7 @@ func DeleteTeam(ctx *context.Context) {
return
}
team, err := models.GetTeamByID(ctx.QueryInt64("id"))
team, err := models.GetTeamByID(ctx.FormInt64("id"))
if err != nil {
ctx.ServerError("GetTeamByID", err)
return
@@ -988,7 +988,7 @@ func GitHooksEditPost(ctx *context.Context) {
}
return
}
hook.Content = ctx.Query("content")
hook.Content = ctx.Form("content")
if err = hook.Update(); err != nil {
ctx.ServerError("hook.Update", err)
return
@@ -1074,7 +1074,7 @@ func DeployKeysPost(ctx *context.Context) {
// DeleteDeployKey response for deleting a deploy key
func DeleteDeployKey(ctx *context.Context) {
if err := models.DeleteDeployKey(ctx.User, ctx.QueryInt64("id")); err != nil {
if err := models.DeleteDeployKey(ctx.User, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteDeployKey: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success"))

View File

@@ -60,14 +60,14 @@ func ProtectedBranchPost(ctx *context.Context) {
repo := ctx.Repo.Repository
switch ctx.Query("action") {
switch ctx.Form("action") {
case "default_branch":
if ctx.HasError() {
ctx.HTML(http.StatusOK, tplBranches)
return
}
branch := ctx.Query("branch")
branch := ctx.Form("branch")
if !ctx.Repo.GitRepo.IsBranchExist(branch) {
ctx.Status(404)
return

View File

@@ -161,7 +161,7 @@ func setTagsContext(ctx *context.Context) error {
}
func selectProtectedTagByContext(ctx *context.Context) *models.ProtectedTag {
id := ctx.QueryInt64("id")
id := ctx.FormInt64("id")
if id == 0 {
id = ctx.ParamsInt64(":id")
}

View File

@@ -23,7 +23,7 @@ func TopicsPost(ctx *context.Context) {
}
var topics = make([]string, 0)
var topicsStr = strings.TrimSpace(ctx.Query("topics"))
var topicsStr = strings.TrimSpace(ctx.Form("topics"))
if len(topicsStr) > 0 {
topics = strings.Split(topicsStr, ",")
}

View File

@@ -416,7 +416,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
isTextFile := st.IsText()
isLFSFile := false
isDisplayingSource := ctx.Query("display") == "source"
isDisplayingSource := ctx.Form("display") == "source"
isDisplayingRendered := !isDisplayingSource
//Check for LFS meta file
@@ -756,7 +756,7 @@ func renderCode(ctx *context.Context) {
// RenderUserCards render a page show users according the input template
func RenderUserCards(ctx *context.Context, total int, getter func(opts models.ListOptions) ([]*models.User, error), tpl base.TplName) {
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 0 {
page = 1
}

View File

@@ -1192,7 +1192,7 @@ func TestWebhook(ctx *context.Context) {
// DeleteWebhook delete a webhook
func DeleteWebhook(ctx *context.Context) {
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteWebhookByRepoID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))

View File

@@ -298,7 +298,7 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
ctx.Data["CommitCount"] = commitsCount
// get page
page := ctx.QueryInt("page")
page := ctx.FormInt("page")
if page <= 1 {
page = 1
}