summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-07-29 09:42:15 +0800
committerGitHub <noreply@github.com>2021-07-29 03:42:15 +0200
commit33e0b38287fdc3487112062300b8dd3c95415ee7 (patch)
tree603394d8f303de1031c21da0d3d3a3cdc0b2bfda /routers/api/v1/repo
parent370516883717de0e6e2087c12d368eb1465ee3b0 (diff)
downloadgitea-33e0b38287fdc3487112062300b8dd3c95415ee7.tar.gz
gitea-33e0b38287fdc3487112062300b8dd3c95415ee7.zip
Rename context.Query to context.Form (#16562)
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r--routers/api/v1/repo/commits.go2
-rw-r--r--routers/api/v1/repo/file.go4
-rw-r--r--routers/api/v1/repo/issue.go36
-rw-r--r--routers/api/v1/repo/issue_tracked_time.go4
-rw-r--r--routers/api/v1/repo/key.go4
-rw-r--r--routers/api/v1/repo/label.go2
-rw-r--r--routers/api/v1/repo/milestone.go4
-rw-r--r--routers/api/v1/repo/pull.go8
-rw-r--r--routers/api/v1/repo/release.go8
-rw-r--r--routers/api/v1/repo/release_attachment.go2
-rw-r--r--routers/api/v1/repo/repo.go36
-rw-r--r--routers/api/v1/repo/status.go6
-rw-r--r--routers/api/v1/repo/topic.go2
-rw-r--r--routers/api/v1/repo/tree.go2
14 files changed, 60 insertions, 60 deletions
diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go
index 9a0fd1d0b6..e4bea4dee7 100644
--- a/routers/api/v1/repo/commits.go
+++ b/routers/api/v1/repo/commits.go
@@ -147,7 +147,7 @@ func GetAllCommits(ctx *context.APIContext) {
listOptions.PageSize = setting.Git.CommitsRangeSize
}
- sha := ctx.Query("sha")
+ sha := ctx.Form("sha")
var baseCommit *git.Commit
if len(sha) == 0 {
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index e6427ea4f4..2b14d1a93c 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -62,7 +62,7 @@ func GetRawFile(ctx *context.APIContext) {
commit := ctx.Repo.Commit
- if ref := ctx.QueryTrim("ref"); len(ref) > 0 {
+ if ref := ctx.FormTrim("ref"); len(ref) > 0 {
var err error
commit, err = ctx.Repo.GitRepo.GetCommit(ref)
if err != nil {
@@ -549,7 +549,7 @@ func GetContents(ctx *context.APIContext) {
}
treePath := ctx.Params("*")
- ref := ctx.QueryTrim("ref")
+ ref := ctx.FormTrim("ref")
if fileList, err := repofiles.GetContentsOrList(ctx.Repo.Repository, treePath, ref); err != nil {
if git.IsErrNotExist(err) {
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 5a7d10b36f..172ad48031 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -106,7 +106,7 @@ func SearchIssues(ctx *context.APIContext) {
}
var isClosed util.OptionalBool
- switch ctx.Query("state") {
+ switch ctx.Form("state") {
case "closed":
isClosed = util.OptionalBoolTrue
case "all":
@@ -140,7 +140,7 @@ func SearchIssues(ctx *context.APIContext) {
var issues []*models.Issue
var filteredCount int64
- keyword := strings.Trim(ctx.Query("q"), " ")
+ keyword := strings.Trim(ctx.Form("q"), " ")
if strings.IndexByte(keyword, 0) >= 0 {
keyword = ""
}
@@ -153,7 +153,7 @@ func SearchIssues(ctx *context.APIContext) {
}
var isPull util.OptionalBool
- switch ctx.Query("type") {
+ switch ctx.Form("type") {
case "pulls":
isPull = util.OptionalBoolTrue
case "issues":
@@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) {
isPull = util.OptionalBoolNone
}
- labels := strings.TrimSpace(ctx.Query("labels"))
+ labels := strings.TrimSpace(ctx.Form("labels"))
var includedLabelNames []string
if len(labels) > 0 {
includedLabelNames = strings.Split(labels, ",")
}
- milestones := strings.TrimSpace(ctx.Query("milestones"))
+ milestones := strings.TrimSpace(ctx.Form("milestones"))
var includedMilestones []string
if len(milestones) > 0 {
includedMilestones = strings.Split(milestones, ",")
@@ -176,7 +176,7 @@ func SearchIssues(ctx *context.APIContext) {
// this api is also used in UI,
// so the default limit is set to fit UI needs
- limit := ctx.QueryInt("limit")
+ limit := ctx.FormInt("limit")
if limit == 0 {
limit = setting.UI.IssuePagingNum
} else if limit > setting.API.MaxResponseItems {
@@ -188,7 +188,7 @@ func SearchIssues(ctx *context.APIContext) {
if len(keyword) == 0 || len(issueIDs) > 0 || len(includedLabelNames) > 0 || len(includedMilestones) > 0 {
issuesOpt := &models.IssuesOptions{
ListOptions: models.ListOptions{
- Page: ctx.QueryInt("page"),
+ Page: ctx.FormInt("page"),
PageSize: limit,
},
RepoIDs: repoIDs,
@@ -197,23 +197,23 @@ func SearchIssues(ctx *context.APIContext) {
IncludedLabelNames: includedLabelNames,
IncludeMilestones: includedMilestones,
SortType: "priorityrepo",
- PriorityRepoID: ctx.QueryInt64("priority_repo_id"),
+ PriorityRepoID: ctx.FormInt64("priority_repo_id"),
IsPull: isPull,
UpdatedBeforeUnix: before,
UpdatedAfterUnix: since,
}
// Filter for: Created by User, Assigned to User, Mentioning User, Review of User Requested
- if ctx.QueryBool("created") {
+ if ctx.FormBool("created") {
issuesOpt.PosterID = ctx.User.ID
}
- if ctx.QueryBool("assigned") {
+ if ctx.FormBool("assigned") {
issuesOpt.AssigneeID = ctx.User.ID
}
- if ctx.QueryBool("mentioned") {
+ if ctx.FormBool("mentioned") {
issuesOpt.MentionedID = ctx.User.ID
}
- if ctx.QueryBool("review_requested") {
+ if ctx.FormBool("review_requested") {
issuesOpt.ReviewRequestedID = ctx.User.ID
}
@@ -319,7 +319,7 @@ func ListIssues(ctx *context.APIContext) {
}
var isClosed util.OptionalBool
- switch ctx.Query("state") {
+ switch ctx.Form("state") {
case "closed":
isClosed = util.OptionalBoolTrue
case "all":
@@ -331,7 +331,7 @@ func ListIssues(ctx *context.APIContext) {
var issues []*models.Issue
var filteredCount int64
- keyword := strings.Trim(ctx.Query("q"), " ")
+ keyword := strings.Trim(ctx.Form("q"), " ")
if strings.IndexByte(keyword, 0) >= 0 {
keyword = ""
}
@@ -345,7 +345,7 @@ func ListIssues(ctx *context.APIContext) {
}
}
- if splitted := strings.Split(ctx.Query("labels"), ","); len(splitted) > 0 {
+ if splitted := strings.Split(ctx.Form("labels"), ","); len(splitted) > 0 {
labelIDs, err = models.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
@@ -354,7 +354,7 @@ func ListIssues(ctx *context.APIContext) {
}
var mileIDs []int64
- if part := strings.Split(ctx.Query("milestones"), ","); len(part) > 0 {
+ if part := strings.Split(ctx.Form("milestones"), ","); len(part) > 0 {
for i := range part {
// uses names and fall back to ids
// non existent milestones are discarded
@@ -386,7 +386,7 @@ func ListIssues(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
var isPull util.OptionalBool
- switch ctx.Query("type") {
+ switch ctx.Form("type") {
case "pulls":
isPull = util.OptionalBoolTrue
case "issues":
@@ -448,7 +448,7 @@ func ListIssues(ctx *context.APIContext) {
}
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
- userName := ctx.Query(queryName)
+ userName := ctx.Form(queryName)
if len(userName) == 0 {
return 0
}
diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go
index ad774b563b..eaf2c44c7c 100644
--- a/routers/api/v1/repo/issue_tracked_time.go
+++ b/routers/api/v1/repo/issue_tracked_time.go
@@ -90,7 +90,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
IssueID: issue.ID,
}
- qUser := strings.Trim(ctx.Query("user"), " ")
+ qUser := strings.Trim(ctx.Form("user"), " ")
if qUser != "" {
user, err := models.GetUserByName(qUser)
if models.IsErrUserNotExist(err) {
@@ -500,7 +500,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
}
// Filters
- qUser := strings.Trim(ctx.Query("user"), " ")
+ qUser := strings.Trim(ctx.Form("user"), " ")
if qUser != "" {
user, err := models.GetUserByName(qUser)
if models.IsErrUserNotExist(err) {
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index b1b465ca11..d41531dd58 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -78,8 +78,8 @@ func ListDeployKeys(ctx *context.APIContext) {
var keys []*models.DeployKey
var err error
- fingerprint := ctx.Query("fingerprint")
- keyID := ctx.QueryInt64("key_id")
+ fingerprint := ctx.Form("fingerprint")
+ keyID := ctx.FormInt64("key_id")
if fingerprint != "" || keyID != 0 {
keys, err = models.SearchDeployKeys(ctx.Repo.Repository.ID, keyID, fingerprint)
} else {
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go
index f71683f6ec..0d1368d18c 100644
--- a/routers/api/v1/repo/label.go
+++ b/routers/api/v1/repo/label.go
@@ -49,7 +49,7 @@ func ListLabels(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/LabelList"
- labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"), utils.GetListOptions(ctx))
+ labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Form("sort"), utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByRepoID", err)
return
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go
index fc8b4efdbb..1231c3eb21 100644
--- a/routers/api/v1/repo/milestone.go
+++ b/routers/api/v1/repo/milestone.go
@@ -60,8 +60,8 @@ func ListMilestones(ctx *context.APIContext) {
milestones, err := models.GetMilestones(models.GetMilestonesOption{
ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID,
- State: api.StateType(ctx.Query("state")),
- Name: ctx.Query("name"),
+ State: api.StateType(ctx.Form("state")),
+ Name: ctx.Form("name"),
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetMilestones", err)
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index de166d7ecb..ba47c3eb8e 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -86,10 +86,10 @@ func ListPullRequests(ctx *context.APIContext) {
prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{
ListOptions: listOptions,
- State: ctx.QueryTrim("state"),
- SortType: ctx.QueryTrim("sort"),
- Labels: ctx.QueryStrings("labels"),
- MilestoneID: ctx.QueryInt64("milestone"),
+ State: ctx.FormTrim("state"),
+ SortType: ctx.FormTrim("sort"),
+ Labels: ctx.FormStrings("labels"),
+ MilestoneID: ctx.FormInt64("milestone"),
})
if err != nil {
diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index 1b52de55ff..97b90079f2 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -109,16 +109,16 @@ func ListReleases(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/ReleaseList"
listOptions := utils.GetListOptions(ctx)
- if listOptions.PageSize == 0 && ctx.QueryInt("per_page") != 0 {
- listOptions.PageSize = ctx.QueryInt("per_page")
+ if listOptions.PageSize == 0 && ctx.FormInt("per_page") != 0 {
+ listOptions.PageSize = ctx.FormInt("per_page")
}
opts := models.FindReleasesOptions{
ListOptions: listOptions,
IncludeDrafts: ctx.Repo.AccessMode >= models.AccessModeWrite,
IncludeTags: false,
- IsDraft: ctx.QueryOptionalBool("draft"),
- IsPreRelease: ctx.QueryOptionalBool("pre-release"),
+ IsDraft: ctx.FormOptionalBool("draft"),
+ IsPreRelease: ctx.FormOptionalBool("pre-release"),
}
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index 0a6425cddc..7986c47e6f 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -190,7 +190,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
}
var filename = header.Filename
- if query := ctx.Query("name"); query != "" {
+ if query := ctx.Form("name"); query != "" {
filename = query
}
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 5e0228fdbe..9c93408832 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -135,27 +135,27 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{
ListOptions: utils.GetListOptions(ctx),
Actor: ctx.User,
- Keyword: strings.Trim(ctx.Query("q"), " "),
- OwnerID: ctx.QueryInt64("uid"),
- PriorityOwnerID: ctx.QueryInt64("priority_owner_id"),
- TeamID: ctx.QueryInt64("team_id"),
- TopicOnly: ctx.QueryBool("topic"),
+ Keyword: strings.Trim(ctx.Form("q"), " "),
+ OwnerID: ctx.FormInt64("uid"),
+ PriorityOwnerID: ctx.FormInt64("priority_owner_id"),
+ TeamID: ctx.FormInt64("team_id"),
+ TopicOnly: ctx.FormBool("topic"),
Collaborate: util.OptionalBoolNone,
- Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
+ Private: ctx.IsSigned && (ctx.Form("private") == "" || ctx.FormBool("private")),
Template: util.OptionalBoolNone,
- StarredByID: ctx.QueryInt64("starredBy"),
- IncludeDescription: ctx.QueryBool("includeDesc"),
+ StarredByID: ctx.FormInt64("starredBy"),
+ IncludeDescription: ctx.FormBool("includeDesc"),
}
- if ctx.Query("template") != "" {
- opts.Template = util.OptionalBoolOf(ctx.QueryBool("template"))
+ if ctx.Form("template") != "" {
+ opts.Template = util.OptionalBoolOf(ctx.FormBool("template"))
}
- if ctx.QueryBool("exclusive") {
+ if ctx.FormBool("exclusive") {
opts.Collaborate = util.OptionalBoolFalse
}
- var mode = ctx.Query("mode")
+ var mode = ctx.Form("mode")
switch mode {
case "source":
opts.Fork = util.OptionalBoolFalse
@@ -173,17 +173,17 @@ func Search(ctx *context.APIContext) {
return
}
- if ctx.Query("archived") != "" {
- opts.Archived = util.OptionalBoolOf(ctx.QueryBool("archived"))
+ if ctx.Form("archived") != "" {
+ opts.Archived = util.OptionalBoolOf(ctx.FormBool("archived"))
}
- if ctx.Query("is_private") != "" {
- opts.IsPrivate = util.OptionalBoolOf(ctx.QueryBool("is_private"))
+ if ctx.Form("is_private") != "" {
+ opts.IsPrivate = util.OptionalBoolOf(ctx.FormBool("is_private"))
}
- var sortMode = ctx.Query("sort")
+ var sortMode = ctx.Form("sort")
if len(sortMode) > 0 {
- var sortOrder = ctx.Query("order")
+ var sortOrder = ctx.Form("order")
if len(sortOrder) == 0 {
sortOrder = "asc"
}
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index 95c3f00a72..841f60bb56 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -190,11 +190,11 @@ func getCommitStatuses(ctx *context.APIContext, sha string) {
statuses, maxResults, err := models.GetCommitStatuses(repo, sha, &models.CommitStatusOptions{
ListOptions: listOptions,
- SortType: ctx.QueryTrim("sort"),
- State: ctx.QueryTrim("state"),
+ SortType: ctx.FormTrim("sort"),
+ State: ctx.FormTrim("state"),
})
if err != nil {
- ctx.Error(http.StatusInternalServerError, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %v", repo.FullName(), sha, ctx.QueryInt("page"), err))
+ ctx.Error(http.StatusInternalServerError, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %v", repo.FullName(), sha, ctx.FormInt("page"), err))
return
}
diff --git a/routers/api/v1/repo/topic.go b/routers/api/v1/repo/topic.go
index c612c2942c..14712f536f 100644
--- a/routers/api/v1/repo/topic.go
+++ b/routers/api/v1/repo/topic.go
@@ -274,7 +274,7 @@ func TopicSearch(ctx *context.APIContext) {
return
}
- kw := ctx.Query("q")
+ kw := ctx.Form("q")
listOptions := utils.GetListOptions(ctx)
diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go
index e6c57af3e2..aec336235d 100644
--- a/routers/api/v1/repo/tree.go
+++ b/routers/api/v1/repo/tree.go
@@ -60,7 +60,7 @@ func GetTree(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
}
- if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.QueryInt("page"), ctx.QueryInt("per_page"), ctx.QueryBool("recursive")); err != nil {
+ if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.FormInt("page"), ctx.FormInt("per_page"), ctx.FormBool("recursive")); err != nil {
ctx.Error(http.StatusBadRequest, "", err.Error())
} else {
ctx.JSON(http.StatusOK, tree)