Skip to content

Commit f33edbe

Browse files
authored
Merge branch 'main' into main
2 parents 55f14af + 8fb3a50 commit f33edbe

File tree

14 files changed

+85
-46
lines changed

14 files changed

+85
-46
lines changed

docs/content/doc/installation/database-preparation.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ menu:
1515

1616
# Database Preparation
1717

18-
You need a database to use Gitea. Gitea supports PostgreSQL, MySQL, SQLite, and MSSQL. This page will guide into preparing database. Only PostgreSQL and MySQL will be covered here since those database engines are widely-used in production.
18+
You need a database to use Gitea. Gitea supports PostgreSQL (>=10), MySQL (>=5.7), SQLite, and MSSQL (>=2008R2 SP3). This page will guide into preparing database. Only PostgreSQL and MySQL will be covered here since those database engines are widely-used in production.
1919

2020
Database instance can be on same machine as Gitea (local database setup), or on different machine (remote database).
2121

docs/content/page/index.en-us.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.
6969
- Logging
7070
- Configuration
7171
- Databases
72-
- MySQL
73-
- PostgreSQL
72+
- MySQL (>=5.7)
73+
- PostgreSQL (>=10)
7474
- SQLite3
75-
- MSSQL
75+
- MSSQL (>=2008R2 SP3)
7676
- TiDB (experimental, not recommended)
7777
- Configuration file
7878
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)

models/notification.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -772,20 +772,20 @@ func setRepoNotificationStatusReadIfUnread(e Engine, userID, repoID int64) error
772772
}
773773

774774
// SetNotificationStatus change the notification status
775-
func SetNotificationStatus(notificationID int64, user *User, status NotificationStatus) error {
775+
func SetNotificationStatus(notificationID int64, user *User, status NotificationStatus) (*Notification, error) {
776776
notification, err := getNotificationByID(x, notificationID)
777777
if err != nil {
778-
return err
778+
return notification, err
779779
}
780780

781781
if notification.UserID != user.ID {
782-
return fmt.Errorf("Can't change notification of another user: %d, %d", notification.UserID, user.ID)
782+
return nil, fmt.Errorf("Can't change notification of another user: %d, %d", notification.UserID, user.ID)
783783
}
784784

785785
notification.Status = status
786786

787787
_, err = x.ID(notificationID).Update(notification)
788-
return err
788+
return notification, err
789789
}
790790

791791
// GetNotificationByID return notification by ID

models/notification_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ func TestSetNotificationStatus(t *testing.T) {
7676
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
7777
notf := AssertExistsAndLoadBean(t,
7878
&Notification{UserID: user.ID, Status: NotificationStatusRead}).(*Notification)
79-
assert.NoError(t, SetNotificationStatus(notf.ID, user, NotificationStatusPinned))
79+
_, err := SetNotificationStatus(notf.ID, user, NotificationStatusPinned)
80+
assert.NoError(t, err)
8081
AssertExistsAndLoadBean(t,
8182
&Notification{ID: notf.ID, Status: NotificationStatusPinned})
8283

83-
assert.Error(t, SetNotificationStatus(1, user, NotificationStatusRead))
84-
assert.Error(t, SetNotificationStatus(NonexistentID, user, NotificationStatusRead))
84+
_, err = SetNotificationStatus(1, user, NotificationStatusRead)
85+
assert.Error(t, err)
86+
_, err = SetNotificationStatus(NonexistentID, user, NotificationStatusRead)
87+
assert.Error(t, err)
8588
}
8689

8790
func TestUpdateNotificationStatuses(t *testing.T) {

modules/git/batch_reader.go

+21-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"bufio"
99
"bytes"
1010
"context"
11+
"fmt"
1112
"io"
1213
"math"
14+
"runtime"
1315
"strconv"
1416
"strings"
1517

@@ -40,9 +42,14 @@ func CatFileBatchCheck(repoPath string) (WriteCloserError, *bufio.Reader, func()
4042
<-closed
4143
}
4244

45+
_, filename, line, _ := runtime.Caller(2)
46+
filename = strings.TrimPrefix(filename, callerPrefix)
47+
4348
go func() {
4449
stderr := strings.Builder{}
45-
err := NewCommandContext(ctx, "cat-file", "--batch-check").RunInDirFullPipeline(repoPath, batchStdoutWriter, &stderr, batchStdinReader)
50+
err := NewCommandContext(ctx, "cat-file", "--batch-check").
51+
SetDescription(fmt.Sprintf("%s cat-file --batch-check [repo_path: %s] (%s:%d)", GitExecutable, repoPath, filename, line)).
52+
RunInDirFullPipeline(repoPath, batchStdoutWriter, &stderr, batchStdinReader)
4653
if err != nil {
4754
_ = batchStdoutWriter.CloseWithError(ConcatenateError(err, (&stderr).String()))
4855
_ = batchStdinReader.CloseWithError(ConcatenateError(err, (&stderr).String()))
@@ -76,9 +83,14 @@ func CatFileBatch(repoPath string) (WriteCloserError, *bufio.Reader, func()) {
7683
<-closed
7784
}
7885

86+
_, filename, line, _ := runtime.Caller(2)
87+
filename = strings.TrimPrefix(filename, callerPrefix)
88+
7989
go func() {
8090
stderr := strings.Builder{}
81-
err := NewCommandContext(ctx, "cat-file", "--batch").RunInDirFullPipeline(repoPath, batchStdoutWriter, &stderr, batchStdinReader)
91+
err := NewCommandContext(ctx, "cat-file", "--batch").
92+
SetDescription(fmt.Sprintf("%s cat-file --batch [repo_path: %s] (%s:%d)", GitExecutable, repoPath, filename, line)).
93+
RunInDirFullPipeline(repoPath, batchStdoutWriter, &stderr, batchStdinReader)
8294
if err != nil {
8395
_ = batchStdoutWriter.CloseWithError(ConcatenateError(err, (&stderr).String()))
8496
_ = batchStdinReader.CloseWithError(ConcatenateError(err, (&stderr).String()))
@@ -292,3 +304,10 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn
292304
sha = shaBuf
293305
return
294306
}
307+
308+
var callerPrefix string
309+
310+
func init() {
311+
_, filename, _, _ := runtime.Caller(0)
312+
callerPrefix = strings.TrimSuffix(filename, "modules/git/batch_reader.go")
313+
}

options/locale/locale_el-GR.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ comment_issue=`σχολίασε στο ζήτημα <a href="%s/issues/%s">%s#%[
27322732
comment_pull=`σχολίασε στο pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
27332733
merge_pull_request=`συγχώνευσε το pull request <a href="%s/pulls/%s">%s#%[2]s</a>`
27342734
transfer_repo=μετέφερε το αποθετήριο <code>%s</code> σε <a href="%s">%s</a>
2735-
push_tag=ώθησε την ετικέτα <a href="%s/src/tag/%s">%[4]s</a> σε <a href="%[1]s">%[3]s</a>
2735+
push_tag=ώθησε την ετικέτα <a href="%s/src/tag/%s">%[4]s</a> στο <a href="%[1]s">%[3]s</a>
27362736
delete_tag=διέγραψε την ετικέτα %[2]s από <a href="%[1]s">%[3]s</a>
27372737
delete_branch=διέγραψε το κλάδο %[2]s από <a href="%[1]s">%[3]s</a>
27382738
compare_branch=Σύγκριση

routers/api/v1/notify/repo.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/modules/context"
1414
"code.gitea.io/gitea/modules/convert"
1515
"code.gitea.io/gitea/modules/log"
16+
"code.gitea.io/gitea/modules/structs"
1617
)
1718

1819
func statusStringToNotificationStatus(status string) models.NotificationStatus {
@@ -176,7 +177,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
176177
// required: false
177178
// responses:
178179
// "205":
179-
// "$ref": "#/responses/empty"
180+
// "$ref": "#/responses/NotificationThreadList"
180181

181182
lastRead := int64(0)
182183
qLastRead := ctx.FormTrim("last_read_at")
@@ -213,14 +214,16 @@ func ReadRepoNotifications(ctx *context.APIContext) {
213214
targetStatus = models.NotificationStatusRead
214215
}
215216

217+
changed := make([]*structs.NotificationThread, len(nl))
218+
216219
for _, n := range nl {
217-
err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
220+
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
218221
if err != nil {
219222
ctx.InternalServerError(err)
220223
return
221224
}
222-
ctx.Status(http.StatusResetContent)
225+
_ = notif.LoadAttributes()
226+
changed = append(changed, convert.ToNotificationThread(notif))
223227
}
224-
225-
ctx.Status(http.StatusResetContent)
228+
ctx.JSON(http.StatusResetContent, changed)
226229
}

routers/api/v1/notify/threads.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ReadThread(ctx *context.APIContext) {
7171
// required: false
7272
// responses:
7373
// "205":
74-
// "$ref": "#/responses/empty"
74+
// "$ref": "#/responses/NotificationThread"
7575
// "403":
7676
// "$ref": "#/responses/forbidden"
7777
// "404":
@@ -87,12 +87,16 @@ func ReadThread(ctx *context.APIContext) {
8787
targetStatus = models.NotificationStatusRead
8888
}
8989

90-
err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
90+
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
9191
if err != nil {
9292
ctx.InternalServerError(err)
9393
return
9494
}
95-
ctx.Status(http.StatusResetContent)
95+
if err = notif.LoadAttributes(); err != nil {
96+
ctx.InternalServerError(err)
97+
return
98+
}
99+
ctx.JSON(http.StatusResetContent, convert.ToNotificationThread(notif))
96100
}
97101

98102
func getThread(ctx *context.APIContext) *models.Notification {

routers/api/v1/notify/user.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/models"
1212
"code.gitea.io/gitea/modules/context"
1313
"code.gitea.io/gitea/modules/convert"
14+
"code.gitea.io/gitea/modules/structs"
1415
)
1516

1617
// ListNotifications list users's notification threads
@@ -125,7 +126,7 @@ func ReadNotifications(ctx *context.APIContext) {
125126
// required: false
126127
// responses:
127128
// "205":
128-
// "$ref": "#/responses/empty"
129+
// "$ref": "#/responses/NotificationThreadList"
129130

130131
lastRead := int64(0)
131132
qLastRead := ctx.FormTrim("last_read_at")
@@ -158,14 +159,17 @@ func ReadNotifications(ctx *context.APIContext) {
158159
targetStatus = models.NotificationStatusRead
159160
}
160161

162+
changed := make([]*structs.NotificationThread, 0, len(nl))
163+
161164
for _, n := range nl {
162-
err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
165+
notif, err := models.SetNotificationStatus(n.ID, ctx.User, targetStatus)
163166
if err != nil {
164167
ctx.InternalServerError(err)
165168
return
166169
}
167-
ctx.Status(http.StatusResetContent)
170+
_ = notif.LoadAttributes()
171+
changed = append(changed, convert.ToNotificationThread(notif))
168172
}
169173

170-
ctx.Status(http.StatusResetContent)
174+
ctx.JSON(http.StatusResetContent, changed)
171175
}

routers/api/v1/repo/file.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ func GetArchive(ctx *context.APIContext) {
119119
// "$ref": "#/responses/notFound"
120120

121121
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
122-
gitRepo, err := git.OpenRepository(repoPath)
123-
if err != nil {
124-
ctx.Error(http.StatusInternalServerError, "OpenRepository", err)
125-
return
122+
if ctx.Repo.GitRepo == nil {
123+
gitRepo, err := git.OpenRepository(repoPath)
124+
if err != nil {
125+
ctx.Error(http.StatusInternalServerError, "OpenRepository", err)
126+
return
127+
}
128+
ctx.Repo.GitRepo = gitRepo
129+
defer gitRepo.Close()
126130
}
127-
ctx.Repo.GitRepo = gitRepo
128-
defer gitRepo.Close()
129131

130132
repo.Download(ctx.Context)
131133
}

routers/api/v1/repo/issue.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -317,27 +317,27 @@ func ListIssues(ctx *context.APIContext) {
317317
// type: string
318318
// - name: since
319319
// in: query
320-
// description: Only show notifications updated after the given time. This is a timestamp in RFC 3339 format
320+
// description: Only show items updated after the given time. This is a timestamp in RFC 3339 format
321321
// type: string
322322
// format: date-time
323323
// required: false
324324
// - name: before
325325
// in: query
326-
// description: Only show notifications updated before the given time. This is a timestamp in RFC 3339 format
326+
// description: Only show items updated before the given time. This is a timestamp in RFC 3339 format
327327
// type: string
328328
// format: date-time
329329
// required: false
330330
// - name: created_by
331331
// in: query
332-
// description: filter (issues / pulls) created to
332+
// description: Only show items which were created by the the given user
333333
// type: string
334334
// - name: assigned_by
335335
// in: query
336-
// description: filter (issues / pulls) assigned to
336+
// description: Only show items for which the given user is assigned
337337
// type: string
338338
// - name: mentioned_by
339339
// in: query
340-
// description: filter (issues / pulls) mentioning to
340+
// description: Only show items in which the given user was mentioned
341341
// type: string
342342
// - name: page
343343
// in: query

routers/web/repo/view.go

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ func renderDirectory(ctx *context.Context, treeLink string) {
353353
}
354354
} else {
355355
ctx.Data["IsRenderedHTML"] = true
356+
buf, err = ioutil.ReadAll(rd)
357+
if err != nil {
358+
log.Error("ReadAll failed: %v", err)
359+
}
356360
ctx.Data["FileContent"] = strings.ReplaceAll(
357361
gotemplate.HTMLEscapeString(string(buf)), "\n", `<br>`,
358362
)

routers/web/user/notification.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func NotificationStatusPost(c *context.Context) {
160160
return
161161
}
162162

163-
if err := models.SetNotificationStatus(notificationID, c.User, status); err != nil {
163+
if _, err := models.SetNotificationStatus(notificationID, c.User, status); err != nil {
164164
c.ServerError("SetNotificationStatus", err)
165165
return
166166
}

templates/swagger/v1_json.tmpl

+8-8
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@
739739
],
740740
"responses": {
741741
"205": {
742-
"$ref": "#/responses/empty"
742+
"$ref": "#/responses/NotificationThreadList"
743743
}
744744
}
745745
}
@@ -822,7 +822,7 @@
822822
],
823823
"responses": {
824824
"205": {
825-
"$ref": "#/responses/empty"
825+
"$ref": "#/responses/NotificationThread"
826826
},
827827
"403": {
828828
"$ref": "#/responses/forbidden"
@@ -4334,32 +4334,32 @@
43344334
{
43354335
"type": "string",
43364336
"format": "date-time",
4337-
"description": "Only show notifications updated after the given time. This is a timestamp in RFC 3339 format",
4337+
"description": "Only show items updated after the given time. This is a timestamp in RFC 3339 format",
43384338
"name": "since",
43394339
"in": "query"
43404340
},
43414341
{
43424342
"type": "string",
43434343
"format": "date-time",
4344-
"description": "Only show notifications updated before the given time. This is a timestamp in RFC 3339 format",
4344+
"description": "Only show items updated before the given time. This is a timestamp in RFC 3339 format",
43454345
"name": "before",
43464346
"in": "query"
43474347
},
43484348
{
43494349
"type": "string",
4350-
"description": "filter (issues / pulls) created to",
4350+
"description": "Only show items which were created by the the given user",
43514351
"name": "created_by",
43524352
"in": "query"
43534353
},
43544354
{
43554355
"type": "string",
4356-
"description": "filter (issues / pulls) assigned to",
4356+
"description": "Only show items for which the given user is assigned",
43574357
"name": "assigned_by",
43584358
"in": "query"
43594359
},
43604360
{
43614361
"type": "string",
4362-
"description": "filter (issues / pulls) mentioning to",
4362+
"description": "Only show items in which the given user was mentioned",
43634363
"name": "mentioned_by",
43644364
"in": "query"
43654365
},
@@ -7058,7 +7058,7 @@
70587058
],
70597059
"responses": {
70607060
"205": {
7061-
"$ref": "#/responses/empty"
7061+
"$ref": "#/responses/NotificationThreadList"
70627062
}
70637063
}
70647064
}

0 commit comments

Comments
 (0)