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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 6 additions & 3 deletions
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

Lines changed: 21 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 5 deletions
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

Lines changed: 7 additions & 3 deletions
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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 8 additions & 6 deletions
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
}

0 commit comments

Comments
 (0)