Skip to content

Commit edca2c1

Browse files
authored
Merge branch 'main' into reattempt-a11y-fixes
2 parents 1372bac + 72738f0 commit edca2c1

Some content is hidden

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

93 files changed

+463
-406
lines changed

docs/content/doc/developers/integrations.en-us.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,22 @@ If you are looking for [CI/CD](https://gitea.com/gitea/awesome-gitea#user-conten
2424
an [SDK](https://gitea.com/gitea/awesome-gitea#user-content-sdk),
2525
or even some extra [themes](https://gitea.com/gitea/awesome-gitea#user-content-themes),
2626
you can find them listed in the [awesome-gitea](https://gitea.com/gitea/awesome-gitea) repository!
27+
28+
## Pre-Fill New File name and contents
29+
30+
If you'd like to open a new file with a given name and contents,
31+
you can do so with query parameters:
32+
33+
```txt
34+
GET /{{org}}/{{repo}}/_new/{{filepath}}
35+
?filename={{filename}}
36+
&value={{content}}
37+
```
38+
39+
For example:
40+
41+
```txt
42+
GET https://git.example.com/johndoe/bliss/_new/articles/
43+
?filename=hello-world.md
44+
&value=Hello%2C%20World!
45+
```

modules/context/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func genAPILinks(curURL *url.URL, total, pageSize, curPage int) []string {
177177

178178
// SetLinkHeader sets pagination link header by given total number and page size.
179179
func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
180-
links := genAPILinks(ctx.Req.URL, total, pageSize, ctx.QueryInt("page"))
180+
links := genAPILinks(ctx.Req.URL, total, pageSize, ctx.FormInt("page"))
181181

182182
if len(links) > 0 {
183183
ctx.Header().Set("Link", strings.Join(links, ","))

modules/context/context.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -287,41 +287,38 @@ func (ctx *Context) Header() http.Header {
287287
return ctx.Resp.Header()
288288
}
289289

290-
// FIXME: We should differ Query and Form, currently we just use form as query
291-
// Currently to be compatible with macaron, we keep it.
292-
293-
// Query returns request form as string with default
294-
func (ctx *Context) Query(key string, defaults ...string) string {
290+
// Form returns request form as string with default
291+
func (ctx *Context) Form(key string, defaults ...string) string {
295292
return (*Forms)(ctx.Req).MustString(key, defaults...)
296293
}
297294

298-
// QueryTrim returns request form as string with default and trimmed spaces
299-
func (ctx *Context) QueryTrim(key string, defaults ...string) string {
295+
// FormTrim returns request form as string with default and trimmed spaces
296+
func (ctx *Context) FormTrim(key string, defaults ...string) string {
300297
return (*Forms)(ctx.Req).MustTrimmed(key, defaults...)
301298
}
302299

303-
// QueryStrings returns request form as strings with default
304-
func (ctx *Context) QueryStrings(key string, defaults ...[]string) []string {
300+
// FormStrings returns request form as strings with default
301+
func (ctx *Context) FormStrings(key string, defaults ...[]string) []string {
305302
return (*Forms)(ctx.Req).MustStrings(key, defaults...)
306303
}
307304

308-
// QueryInt returns request form as int with default
309-
func (ctx *Context) QueryInt(key string, defaults ...int) int {
305+
// FormInt returns request form as int with default
306+
func (ctx *Context) FormInt(key string, defaults ...int) int {
310307
return (*Forms)(ctx.Req).MustInt(key, defaults...)
311308
}
312309

313-
// QueryInt64 returns request form as int64 with default
314-
func (ctx *Context) QueryInt64(key string, defaults ...int64) int64 {
310+
// FormInt64 returns request form as int64 with default
311+
func (ctx *Context) FormInt64(key string, defaults ...int64) int64 {
315312
return (*Forms)(ctx.Req).MustInt64(key, defaults...)
316313
}
317314

318-
// QueryBool returns request form as bool with default
319-
func (ctx *Context) QueryBool(key string, defaults ...bool) bool {
315+
// FormBool returns request form as bool with default
316+
func (ctx *Context) FormBool(key string, defaults ...bool) bool {
320317
return (*Forms)(ctx.Req).MustBool(key, defaults...)
321318
}
322319

323-
// QueryOptionalBool returns request form as OptionalBool with default
324-
func (ctx *Context) QueryOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
320+
// FormOptionalBool returns request form as OptionalBool with default
321+
func (ctx *Context) FormOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
325322
return (*Forms)(ctx.Req).MustOptionalBool(key, defaults...)
326323
}
327324

modules/context/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
346346

347347
// Check access.
348348
if ctx.Repo.Permission.AccessMode == models.AccessModeNone {
349-
if ctx.Query("go-get") == "1" {
349+
if ctx.Form("go-get") == "1" {
350350
EarlyResponseForGoGetMeta(ctx)
351351
return
352352
}
@@ -415,7 +415,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
415415
owner, err = models.GetUserByName(userName)
416416
if err != nil {
417417
if models.IsErrUserNotExist(err) {
418-
if ctx.Query("go-get") == "1" {
418+
if ctx.Form("go-get") == "1" {
419419
EarlyResponseForGoGetMeta(ctx)
420420
return
421421
}
@@ -437,7 +437,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
437437
if err == nil {
438438
RedirectToRepo(ctx, redirectRepoID)
439439
} else if models.IsErrRepoRedirectNotExist(err) {
440-
if ctx.Query("go-get") == "1" {
440+
if ctx.Form("go-get") == "1" {
441441
EarlyResponseForGoGetMeta(ctx)
442442
return
443443
}
@@ -618,7 +618,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
618618
}
619619
}
620620

621-
if ctx.Query("go-get") == "1" {
621+
if ctx.Form("go-get") == "1" {
622622
ctx.Data["GoGetImport"] = ComposeGoGetImport(owner.Name, repo.Name)
623623
prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", "branch", ctx.Repo.BranchName)
624624
ctx.Data["GoDocDirectory"] = prefix + "{/dir}"

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ editor.require_signed_commit = Branch requires a signed commit
10401040
commits.desc = Browse source code change history.
10411041
commits.commits = Commits
10421042
commits.no_commits = No commits in common. '%s' and '%s' have entirely different histories.
1043+
commits.nothing_to_compare = These branches are equal.
10431044
commits.search = Search commits…
10441045
commits.search.tooltip = You can prefix keywords with "author:", "committer:", "after:", or "before:", e.g. "revert author:Alice before:2019-04-01".
10451046
commits.find = Search

routers/api/v1/admin/adopt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
4242
// "$ref": "#/responses/forbidden"
4343

4444
listOptions := utils.GetListOptions(ctx)
45-
repoNames, count, err := repository.ListUnadoptedRepositories(ctx.Query("query"), &listOptions)
45+
repoNames, count, err := repository.ListUnadoptedRepositories(ctx.Form("query"), &listOptions)
4646
if err != nil {
4747
ctx.InternalServerError(err)
4848
}

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import (
9393

9494
func sudo() func(ctx *context.APIContext) {
9595
return func(ctx *context.APIContext) {
96-
sudo := ctx.Query("sudo")
96+
sudo := ctx.Form("sudo")
9797
if len(sudo) == 0 {
9898
sudo = ctx.Req.Header.Get("Sudo")
9999
}

routers/api/v1/notify/notifications.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificatio
3737
UpdatedBeforeUnix: before,
3838
UpdatedAfterUnix: since,
3939
}
40-
if !ctx.QueryBool("all") {
41-
statuses := ctx.QueryStrings("status-types")
40+
if !ctx.FormBool("all") {
41+
statuses := ctx.FormStrings("status-types")
4242
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread", "pinned"})
4343
}
4444

45-
subjectTypes := ctx.QueryStrings("subject-type")
45+
subjectTypes := ctx.FormStrings("subject-type")
4646
if len(subjectTypes) != 0 {
4747
opts.Source = subjectToSource(subjectTypes)
4848
}

routers/api/v1/notify/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
171171
// "$ref": "#/responses/empty"
172172

173173
lastRead := int64(0)
174-
qLastRead := strings.Trim(ctx.Query("last_read_at"), " ")
174+
qLastRead := strings.Trim(ctx.Form("last_read_at"), " ")
175175
if len(qLastRead) > 0 {
176176
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
177177
if err != nil {
@@ -189,8 +189,8 @@ func ReadRepoNotifications(ctx *context.APIContext) {
189189
UpdatedBeforeUnix: lastRead,
190190
}
191191

192-
if !ctx.QueryBool("all") {
193-
statuses := ctx.QueryStrings("status-types")
192+
if !ctx.FormBool("all") {
193+
statuses := ctx.FormStrings("status-types")
194194
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
195195
log.Error("%v", opts.Status)
196196
}
@@ -200,7 +200,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
200200
return
201201
}
202202

203-
targetStatus := statusStringToNotificationStatus(ctx.Query("to-status"))
203+
targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
204204
if targetStatus == 0 {
205205
targetStatus = models.NotificationStatusRead
206206
}

routers/api/v1/notify/threads.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func ReadThread(ctx *context.APIContext) {
8282
return
8383
}
8484

85-
targetStatus := statusStringToNotificationStatus(ctx.Query("to-status"))
85+
targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
8686
if targetStatus == 0 {
8787
targetStatus = models.NotificationStatusRead
8888
}

routers/api/v1/notify/user.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func ReadNotifications(ctx *context.APIContext) {
122122
// "$ref": "#/responses/empty"
123123

124124
lastRead := int64(0)
125-
qLastRead := strings.Trim(ctx.Query("last_read_at"), " ")
125+
qLastRead := strings.Trim(ctx.Form("last_read_at"), " ")
126126
if len(qLastRead) > 0 {
127127
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
128128
if err != nil {
@@ -137,8 +137,8 @@ func ReadNotifications(ctx *context.APIContext) {
137137
UserID: ctx.User.ID,
138138
UpdatedBeforeUnix: lastRead,
139139
}
140-
if !ctx.QueryBool("all") {
141-
statuses := ctx.QueryStrings("status-types")
140+
if !ctx.FormBool("all") {
141+
statuses := ctx.FormStrings("status-types")
142142
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
143143
}
144144
nl, err := models.GetNotifications(opts)
@@ -147,7 +147,7 @@ func ReadNotifications(ctx *context.APIContext) {
147147
return
148148
}
149149

150-
targetStatus := statusStringToNotificationStatus(ctx.Query("to-status"))
150+
targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
151151
if targetStatus == 0 {
152152
targetStatus = models.NotificationStatusRead
153153
}

routers/api/v1/org/label.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ListLabels(ctx *context.APIContext) {
4343
// "200":
4444
// "$ref": "#/responses/LabelList"
4545

46-
labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Query("sort"), utils.GetListOptions(ctx))
46+
labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Form("sort"), utils.GetListOptions(ctx))
4747
if err != nil {
4848
ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err)
4949
return

routers/api/v1/org/team.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ func SearchTeam(ctx *context.APIContext) {
658658

659659
opts := &models.SearchTeamOptions{
660660
UserID: ctx.User.ID,
661-
Keyword: strings.TrimSpace(ctx.Query("q")),
661+
Keyword: strings.TrimSpace(ctx.Form("q")),
662662
OrgID: ctx.Org.Organization.ID,
663-
IncludeDesc: ctx.Query("include_desc") == "" || ctx.QueryBool("include_desc"),
663+
IncludeDesc: ctx.Form("include_desc") == "" || ctx.FormBool("include_desc"),
664664
ListOptions: listOptions,
665665
}
666666

routers/api/v1/repo/commits.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func GetAllCommits(ctx *context.APIContext) {
147147
listOptions.PageSize = setting.Git.CommitsRangeSize
148148
}
149149

150-
sha := ctx.Query("sha")
150+
sha := ctx.Form("sha")
151151

152152
var baseCommit *git.Commit
153153
if len(sha) == 0 {

routers/api/v1/repo/file.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func GetRawFile(ctx *context.APIContext) {
6262

6363
commit := ctx.Repo.Commit
6464

65-
if ref := ctx.QueryTrim("ref"); len(ref) > 0 {
65+
if ref := ctx.FormTrim("ref"); len(ref) > 0 {
6666
var err error
6767
commit, err = ctx.Repo.GitRepo.GetCommit(ref)
6868
if err != nil {
@@ -549,7 +549,7 @@ func GetContents(ctx *context.APIContext) {
549549
}
550550

551551
treePath := ctx.Params("*")
552-
ref := ctx.QueryTrim("ref")
552+
ref := ctx.FormTrim("ref")
553553

554554
if fileList, err := repofiles.GetContentsOrList(ctx.Repo.Repository, treePath, ref); err != nil {
555555
if git.IsErrNotExist(err) {

0 commit comments

Comments
 (0)