Skip to content

Commit 0456f72

Browse files
committed
fix
1 parent 6d5aa92 commit 0456f72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+429
-411
lines changed

routers/api/v1/admin/adopt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func AdoptRepository(ctx *context.APIContext) {
8080
// "$ref": "#/responses/notFound"
8181
// "403":
8282
// "$ref": "#/responses/forbidden"
83-
ownerName := ctx.PathParam(":username")
84-
repoName := ctx.PathParam(":reponame")
83+
ownerName := ctx.PathParam("username")
84+
repoName := ctx.PathParam("reponame")
8585

8686
ctxUser, err := user_model.GetUserByName(ctx, ownerName)
8787
if err != nil {
@@ -142,8 +142,8 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) {
142142
// "$ref": "#/responses/empty"
143143
// "403":
144144
// "$ref": "#/responses/forbidden"
145-
ownerName := ctx.PathParam(":username")
146-
repoName := ctx.PathParam(":reponame")
145+
ownerName := ctx.PathParam("username")
146+
repoName := ctx.PathParam("reponame")
147147

148148
ctxUser, err := user_model.GetUserByName(ctx, ownerName)
149149
if err != nil {

routers/api/v1/admin/cron.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func PostCronTask(ctx *context.APIContext) {
7474
// "$ref": "#/responses/empty"
7575
// "404":
7676
// "$ref": "#/responses/notFound"
77-
task := cron.GetTask(ctx.PathParam(":task"))
77+
task := cron.GetTask(ctx.PathParam("task"))
7878
if task == nil {
7979
ctx.NotFound()
8080
return

routers/api/v1/admin/email.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func GetAllEmails(ctx *context.APIContext) {
3838
listOptions := utils.GetListOptions(ctx)
3939

4040
emails, maxResults, err := user_model.SearchEmails(ctx, &user_model.SearchEmailOptions{
41-
Keyword: ctx.PathParam(":email"),
41+
Keyword: ctx.PathParam("email"),
4242
ListOptions: listOptions,
4343
})
4444
if err != nil {
@@ -82,6 +82,6 @@ func SearchEmail(ctx *context.APIContext) {
8282
// "403":
8383
// "$ref": "#/responses/forbidden"
8484

85-
ctx.SetPathParam(":email", ctx.FormTrim("q"))
85+
ctx.SetPathParam("email", ctx.FormTrim("q"))
8686
GetAllEmails(ctx)
8787
}

routers/api/v1/admin/hooks.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func GetHook(ctx *context.APIContext) {
7373
// "200":
7474
// "$ref": "#/responses/Hook"
7575

76-
hookID := ctx.PathParamInt64(":id")
76+
hookID := ctx.PathParamInt64("id")
7777
hook, err := webhook.GetSystemOrDefaultWebhook(ctx, hookID)
7878
if err != nil {
7979
if errors.Is(err, util.ErrNotExist) {
@@ -142,7 +142,7 @@ func EditHook(ctx *context.APIContext) {
142142
form := web.GetForm(ctx).(*api.EditHookOption)
143143

144144
// TODO in body params
145-
hookID := ctx.PathParamInt64(":id")
145+
hookID := ctx.PathParamInt64("id")
146146
utils.EditSystemHook(ctx, form, hookID)
147147
}
148148

@@ -164,7 +164,7 @@ func DeleteHook(ctx *context.APIContext) {
164164
// "204":
165165
// "$ref": "#/responses/empty"
166166

167-
hookID := ctx.PathParamInt64(":id")
167+
hookID := ctx.PathParamInt64("id")
168168
if err := webhook.DeleteDefaultSystemWebhook(ctx, hookID); err != nil {
169169
if errors.Is(err, util.ErrNotExist) {
170170
ctx.NotFound()

routers/api/v1/admin/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) {
375375
// "404":
376376
// "$ref": "#/responses/notFound"
377377

378-
if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.PathParamInt64(":id")); err != nil {
378+
if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.PathParamInt64("id")); err != nil {
379379
if asymkey_model.IsErrKeyNotExist(err) {
380380
ctx.NotFound()
381381
} else if asymkey_model.IsErrKeyAccessDenied(err) {

routers/api/v1/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,12 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
596596

597597
var err error
598598
if assignOrg {
599-
ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.PathParam(":org"))
599+
ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.PathParam("org"))
600600
if err != nil {
601601
if organization.IsErrOrgNotExist(err) {
602-
redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.PathParam(":org"))
602+
redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.PathParam("org"))
603603
if err == nil {
604-
context.RedirectToUser(ctx.Base, ctx.PathParam(":org"), redirectUserID)
604+
context.RedirectToUser(ctx.Base, ctx.PathParam("org"), redirectUserID)
605605
} else if user_model.IsErrUserRedirectNotExist(err) {
606606
ctx.NotFound("GetOrgByName", err)
607607
} else {
@@ -616,7 +616,7 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
616616
}
617617

618618
if assignTeam {
619-
ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.PathParamInt64(":teamid"))
619+
ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.PathParamInt64("teamid"))
620620
if err != nil {
621621
if organization.IsErrTeamNotExist(err) {
622622
ctx.NotFound()

routers/api/v1/notify/threads.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func ReadThread(ctx *context.APIContext) {
101101
}
102102

103103
func getThread(ctx *context.APIContext) *activities_model.Notification {
104-
n, err := activities_model.GetNotificationByID(ctx, ctx.PathParamInt64(":id"))
104+
n, err := activities_model.GetNotificationByID(ctx, ctx.PathParamInt64("id"))
105105
if err != nil {
106106
if db.IsErrNotExist(err) {
107107
ctx.Error(http.StatusNotFound, "GetNotificationByID", err)

routers/api/v1/org/label.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func GetLabel(ctx *context.APIContext) {
139139
label *issues_model.Label
140140
err error
141141
)
142-
strID := ctx.PathParam(":id")
142+
strID := ctx.PathParam("id")
143143
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
144144
label, err = issues_model.GetLabelInOrgByName(ctx, ctx.Org.Organization.ID, strID)
145145
} else {
@@ -190,7 +190,7 @@ func EditLabel(ctx *context.APIContext) {
190190
// "422":
191191
// "$ref": "#/responses/validationError"
192192
form := web.GetForm(ctx).(*api.EditLabelOption)
193-
l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64(":id"))
193+
l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64("id"))
194194
if err != nil {
195195
if issues_model.IsErrOrgLabelNotExist(err) {
196196
ctx.NotFound()
@@ -249,7 +249,7 @@ func DeleteLabel(ctx *context.APIContext) {
249249
// "404":
250250
// "$ref": "#/responses/notFound"
251251

252-
if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64(":id")); err != nil {
252+
if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64("id")); err != nil {
253253
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
254254
return
255255
}

routers/api/v1/org/team.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func GetTeamRepo(ctx *context.APIContext) {
645645

646646
// getRepositoryByParams get repository by a team's organization ID and repo name
647647
func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository {
648-
repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.PathParam(":reponame"))
648+
repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.PathParam("reponame"))
649649
if err != nil {
650650
if repo_model.IsErrRepoNotExist(err) {
651651
ctx.NotFound()

routers/api/v1/repo/branch.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func GetBranchProtection(ctx *context.APIContext) {
487487
// "$ref": "#/responses/notFound"
488488

489489
repo := ctx.Repo.Repository
490-
bpName := ctx.PathParam(":name")
490+
bpName := ctx.PathParam("name")
491491
bp, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName)
492492
if err != nil {
493493
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
@@ -805,7 +805,7 @@ func EditBranchProtection(ctx *context.APIContext) {
805805
// "$ref": "#/responses/repoArchivedError"
806806
form := web.GetForm(ctx).(*api.EditBranchProtectionOption)
807807
repo := ctx.Repo.Repository
808-
bpName := ctx.PathParam(":name")
808+
bpName := ctx.PathParam("name")
809809
protectBranch, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName)
810810
if err != nil {
811811
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
@@ -1124,7 +1124,7 @@ func DeleteBranchProtection(ctx *context.APIContext) {
11241124
// "$ref": "#/responses/notFound"
11251125

11261126
repo := ctx.Repo.Repository
1127-
bpName := ctx.PathParam(":name")
1127+
bpName := ctx.PathParam("name")
11281128
bp, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName)
11291129
if err != nil {
11301130
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)

routers/api/v1/repo/collaborators.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func IsCollaborator(ctx *context.APIContext) {
103103
// "422":
104104
// "$ref": "#/responses/validationError"
105105

106-
user, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
106+
user, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator"))
107107
if err != nil {
108108
if user_model.IsErrUserNotExist(err) {
109109
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -163,7 +163,7 @@ func AddOrUpdateCollaborator(ctx *context.APIContext) {
163163

164164
form := web.GetForm(ctx).(*api.AddCollaboratorOption)
165165

166-
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
166+
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator"))
167167
if err != nil {
168168
if user_model.IsErrUserNotExist(err) {
169169
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -226,7 +226,7 @@ func DeleteCollaborator(ctx *context.APIContext) {
226226
// "422":
227227
// "$ref": "#/responses/validationError"
228228

229-
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
229+
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator"))
230230
if err != nil {
231231
if user_model.IsErrUserNotExist(err) {
232232
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -274,12 +274,12 @@ func GetRepoPermissions(ctx *context.APIContext) {
274274
// "403":
275275
// "$ref": "#/responses/forbidden"
276276

277-
if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.PathParam(":collaborator") && !ctx.IsUserRepoAdmin() {
277+
if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.PathParam("collaborator") && !ctx.IsUserRepoAdmin() {
278278
ctx.Error(http.StatusForbidden, "User", "Only admins can query all permissions, repo admins can query all repo permissions, collaborators can query only their own")
279279
return
280280
}
281281

282-
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
282+
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator"))
283283
if err != nil {
284284
if user_model.IsErrUserNotExist(err) {
285285
ctx.Error(http.StatusNotFound, "GetUserByName", err)

routers/api/v1/repo/commits.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func GetSingleCommit(ctx *context.APIContext) {
6363
// "404":
6464
// "$ref": "#/responses/notFound"
6565

66-
sha := ctx.PathParam(":sha")
66+
sha := ctx.PathParam("sha")
6767
if !git.IsValidRefPattern(sha) {
6868
ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha))
6969
return
@@ -312,8 +312,8 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) {
312312
// "$ref": "#/responses/string"
313313
// "404":
314314
// "$ref": "#/responses/notFound"
315-
sha := ctx.PathParam(":sha")
316-
diffType := git.RawDiffType(ctx.PathParam(":diffType"))
315+
sha := ctx.PathParam("sha")
316+
diffType := git.RawDiffType(ctx.PathParam("diffType"))
317317

318318
if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, diffType, ctx.Resp); err != nil {
319319
if git.IsErrNotExist(err) {

routers/api/v1/repo/git_hook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func GetGitHook(ctx *context.APIContext) {
7979
// "404":
8080
// "$ref": "#/responses/notFound"
8181

82-
hookID := ctx.PathParam(":id")
82+
hookID := ctx.PathParam("id")
8383
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
8484
if err != nil {
8585
if err == git.ErrNotValidHook {
@@ -126,7 +126,7 @@ func EditGitHook(ctx *context.APIContext) {
126126
// "$ref": "#/responses/notFound"
127127

128128
form := web.GetForm(ctx).(*api.EditGitHookOption)
129-
hookID := ctx.PathParam(":id")
129+
hookID := ctx.PathParam("id")
130130
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
131131
if err != nil {
132132
if err == git.ErrNotValidHook {
@@ -175,7 +175,7 @@ func DeleteGitHook(ctx *context.APIContext) {
175175
// "404":
176176
// "$ref": "#/responses/notFound"
177177

178-
hookID := ctx.PathParam(":id")
178+
hookID := ctx.PathParam("id")
179179
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
180180
if err != nil {
181181
if err == git.ErrNotValidHook {

routers/api/v1/repo/hook.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func GetHook(ctx *context.APIContext) {
109109
// "$ref": "#/responses/notFound"
110110

111111
repo := ctx.Repo
112-
hookID := ctx.PathParamInt64(":id")
112+
hookID := ctx.PathParamInt64("id")
113113
hook, err := utils.GetRepoHook(ctx, repo.Repository.ID, hookID)
114114
if err != nil {
115115
return
@@ -168,7 +168,7 @@ func TestHook(ctx *context.APIContext) {
168168
ref = r
169169
}
170170

171-
hookID := ctx.PathParamInt64(":id")
171+
hookID := ctx.PathParamInt64("id")
172172
hook, err := utils.GetRepoHook(ctx, ctx.Repo.Repository.ID, hookID)
173173
if err != nil {
174174
return
@@ -263,7 +263,7 @@ func EditHook(ctx *context.APIContext) {
263263
// "404":
264264
// "$ref": "#/responses/notFound"
265265
form := web.GetForm(ctx).(*api.EditHookOption)
266-
hookID := ctx.PathParamInt64(":id")
266+
hookID := ctx.PathParamInt64("id")
267267
utils.EditRepoHook(ctx, form, hookID)
268268
}
269269

@@ -296,7 +296,7 @@ func DeleteHook(ctx *context.APIContext) {
296296
// "$ref": "#/responses/empty"
297297
// "404":
298298
// "$ref": "#/responses/notFound"
299-
if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")); err != nil {
299+
if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id")); err != nil {
300300
if webhook.IsErrWebhookNotExist(err) {
301301
ctx.NotFound()
302302
} else {

routers/api/v1/repo/hook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestTestHook(t *testing.T) {
1818
unittest.PrepareTestEnv(t)
1919

2020
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages")
21-
ctx.SetPathParam(":id", "1")
21+
ctx.SetPathParam("id", "1")
2222
contexttest.LoadRepo(t, ctx, 1)
2323
contexttest.LoadRepoCommit(t, ctx)
2424
contexttest.LoadUser(t, ctx, 2)

routers/api/v1/repo/issue.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ func GetIssue(ctx *context.APIContext) {
613613
// "404":
614614
// "$ref": "#/responses/notFound"
615615

616-
issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
616+
issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
617617
if err != nil {
618618
if issues_model.IsErrIssueNotExist(err) {
619619
ctx.NotFound()
@@ -793,7 +793,7 @@ func EditIssue(ctx *context.APIContext) {
793793
// "$ref": "#/responses/error"
794794

795795
form := web.GetForm(ctx).(*api.EditIssueOption)
796-
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
796+
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
797797
if err != nil {
798798
if issues_model.IsErrIssueNotExist(err) {
799799
ctx.NotFound()
@@ -976,7 +976,7 @@ func DeleteIssue(ctx *context.APIContext) {
976976
// "$ref": "#/responses/forbidden"
977977
// "404":
978978
// "$ref": "#/responses/notFound"
979-
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
979+
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
980980
if err != nil {
981981
if issues_model.IsErrIssueNotExist(err) {
982982
ctx.NotFound(err)
@@ -1032,7 +1032,7 @@ func UpdateIssueDeadline(ctx *context.APIContext) {
10321032
// "404":
10331033
// "$ref": "#/responses/notFound"
10341034
form := web.GetForm(ctx).(*api.EditDeadlineOption)
1035-
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
1035+
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
10361036
if err != nil {
10371037
if issues_model.IsErrIssueNotExist(err) {
10381038
ctx.NotFound()

0 commit comments

Comments
 (0)