Skip to content

Commit 494abf6

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Show lock owner instead of repo owner on LFS setting page (go-gitea#31788) Move repository visibility to danger zone in the settings area (go-gitea#31126) [skip ci] Updated translations via Crowdin Add types to various low-level functions (go-gitea#31781) Add warning message in merge instructions when `AutodetectManualMerge` was not enabled (go-gitea#31805) Show latest run when visit /run/latest (go-gitea#31808) Fix typo for `LOG_COMPRESSION` in ini (go-gitea#31809) Add label `docs-update-needed` for PRs that modify `app.example.ini` (go-gitea#31810) Fix `IsObjectExist` with gogit (go-gitea#31790) Support compression for Actions logs (go-gitea#31761) Add issue comment when moving issues from one column to another of the project (go-gitea#29311) [skip ci] Updated translations via Crowdin Fix RPM resource leak (go-gitea#31794)
2 parents 40212b5 + 0470646 commit 494abf6

Some content is hidden

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

60 files changed

+1416
-232
lines changed

.github/labeler.yml

+5
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ modifies/js:
7575
- any-glob-to-any-file:
7676
- "**/*.js"
7777
- "**/*.vue"
78+
79+
docs-update-needed:
80+
- changed-files:
81+
- any-glob-to-any-file:
82+
- "custom/conf/app.example.ini"

assets/go-licenses.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom/conf/app.example.ini

+6
Original file line numberDiff line numberDiff line change
@@ -2687,6 +2687,12 @@ LEVEL = Info
26872687
;DEFAULT_ACTIONS_URL = github
26882688
;; Logs retention time in days. Old logs will be deleted after this period.
26892689
;LOG_RETENTION_DAYS = 365
2690+
;; Log compression type, `none` for no compression, `zstd` for zstd compression.
2691+
;; Other compression types like `gzip` are NOT supported, since seekable stream is required for log view.
2692+
;; It's always recommended to use compression when using local disk as log storage if CPU or memory is not a bottleneck.
2693+
;; And for object storage services like S3, which is billed for requests, it would cause extra 2 times of get requests for each log view.
2694+
;; But it will save storage space and network bandwidth, so it's still recommended to use compression.
2695+
;LOG_COMPRESSION = none
26902696
;; Default artifact retention time in days. Artifacts could have their own retention periods by setting the `retention-days` option in `actions/upload-artifact` step.
26912697
;ARTIFACT_RETENTION_DAYS = 90
26922698
;; Timeout to stop the task which have running status, but haven't been updated for a long time

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
2121
github.com/ProtonMail/go-crypto v1.0.0
2222
github.com/PuerkitoBio/goquery v1.9.2
23+
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2
2324
github.com/alecthomas/chroma/v2 v2.14.0
2425
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
2526
github.com/blevesearch/bleve/v2 v2.4.2
@@ -209,6 +210,7 @@ require (
209210
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
210211
github.com/golang/protobuf v1.5.4 // indirect
211212
github.com/golang/snappy v0.0.4 // indirect
213+
github.com/google/btree v1.1.2 // indirect
212214
github.com/google/go-querystring v1.1.0 // indirect
213215
github.com/google/go-tpm v0.9.0 // indirect
214216
github.com/gorilla/css v1.0.1 // indirect

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06
8080
github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I=
8181
github.com/RoaringBitmap/roaring v1.9.4 h1:yhEIoH4YezLYT04s1nHehNO64EKFTop/wBhxv2QzDdQ=
8282
github.com/RoaringBitmap/roaring v1.9.4/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
83+
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2 h1:cSXom2MoKJ9KPPw29RoZtHvUETY4F4n/kXl8m9btnQ0=
84+
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2/go.mod h1:JitQWJ8JuV4Y87l8VsHiiwhb3cgdyn68mX40s7NT6PA=
8385
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
8486
github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
8587
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
@@ -395,6 +397,8 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
395397
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
396398
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
397399
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
400+
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
401+
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
398402
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
399403
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
400404
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=

models/actions/run.go

+13
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,19 @@ func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error)
361361
return run, nil
362362
}
363363

364+
func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
365+
run := &ActionRun{
366+
RepoID: repoID,
367+
}
368+
has, err := db.GetEngine(ctx).Where("repo_id=?", repoID).Desc("index").Get(run)
369+
if err != nil {
370+
return nil, err
371+
} else if !has {
372+
return nil, fmt.Errorf("latest run with repo_id %d: %w", repoID, util.ErrNotExist)
373+
}
374+
return run, nil
375+
}
376+
364377
func GetWorkflowLatestRun(ctx context.Context, repoID int64, workflowFile, branch, event string) (*ActionRun, error) {
365378
var run ActionRun
366379
q := db.GetEngine(ctx).Where("repo_id=?", repoID).

models/actions/task.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,13 @@ func convertTimestamp(timestamp *timestamppb.Timestamp) timeutil.TimeStamp {
502502
}
503503

504504
func logFileName(repoFullName string, taskID int64) string {
505-
return fmt.Sprintf("%s/%02x/%d.log", repoFullName, taskID%256, taskID)
505+
ret := fmt.Sprintf("%s/%02x/%d.log", repoFullName, taskID%256, taskID)
506+
507+
if setting.Actions.LogCompression.IsZstd() {
508+
ret += ".zst"
509+
}
510+
511+
return ret
506512
}
507513

508514
func getTaskIDFromCache(token string) int64 {

models/git/lfs_lock.go

+38-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package git
66
import (
77
"context"
88
"errors"
9+
"fmt"
910
"strings"
1011
"time"
1112

@@ -21,11 +22,12 @@ import (
2122

2223
// LFSLock represents a git lfs lock of repository.
2324
type LFSLock struct {
24-
ID int64 `xorm:"pk autoincr"`
25-
RepoID int64 `xorm:"INDEX NOT NULL"`
26-
OwnerID int64 `xorm:"INDEX NOT NULL"`
27-
Path string `xorm:"TEXT"`
28-
Created time.Time `xorm:"created"`
25+
ID int64 `xorm:"pk autoincr"`
26+
RepoID int64 `xorm:"INDEX NOT NULL"`
27+
OwnerID int64 `xorm:"INDEX NOT NULL"`
28+
Owner *user_model.User `xorm:"-"`
29+
Path string `xorm:"TEXT"`
30+
Created time.Time `xorm:"created"`
2931
}
3032

3133
func init() {
@@ -37,6 +39,35 @@ func (l *LFSLock) BeforeInsert() {
3739
l.Path = util.PathJoinRel(l.Path)
3840
}
3941

42+
// LoadAttributes loads attributes of the lock.
43+
func (l *LFSLock) LoadAttributes(ctx context.Context) error {
44+
// Load owner
45+
if err := l.LoadOwner(ctx); err != nil {
46+
return fmt.Errorf("load owner: %w", err)
47+
}
48+
49+
return nil
50+
}
51+
52+
// LoadOwner loads owner of the lock.
53+
func (l *LFSLock) LoadOwner(ctx context.Context) error {
54+
if l.Owner != nil {
55+
return nil
56+
}
57+
58+
owner, err := user_model.GetUserByID(ctx, l.OwnerID)
59+
if err != nil {
60+
if user_model.IsErrUserNotExist(err) {
61+
l.Owner = user_model.NewGhostUser()
62+
return nil
63+
}
64+
return err
65+
}
66+
l.Owner = owner
67+
68+
return nil
69+
}
70+
4071
// CreateLFSLock creates a new lock.
4172
func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLock) (*LFSLock, error) {
4273
dbCtx, committer, err := db.TxContext(ctx)
@@ -94,7 +125,7 @@ func GetLFSLockByID(ctx context.Context, id int64) (*LFSLock, error) {
94125
}
95126

96127
// GetLFSLockByRepoID returns a list of locks of repository.
97-
func GetLFSLockByRepoID(ctx context.Context, repoID int64, page, pageSize int) ([]*LFSLock, error) {
128+
func GetLFSLockByRepoID(ctx context.Context, repoID int64, page, pageSize int) (LFSLockList, error) {
98129
e := db.GetEngine(ctx)
99130
if page >= 0 && pageSize > 0 {
100131
start := 0
@@ -103,7 +134,7 @@ func GetLFSLockByRepoID(ctx context.Context, repoID int64, page, pageSize int) (
103134
}
104135
e.Limit(pageSize, start)
105136
}
106-
lfsLocks := make([]*LFSLock, 0, pageSize)
137+
lfsLocks := make(LFSLockList, 0, pageSize)
107138
return lfsLocks, e.Find(&lfsLocks, &LFSLock{RepoID: repoID})
108139
}
109140

models/git/lfs_lock_list.go

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package git
5+
6+
import (
7+
"context"
8+
"fmt"
9+
10+
"code.gitea.io/gitea/models/db"
11+
user_model "code.gitea.io/gitea/models/user"
12+
"code.gitea.io/gitea/modules/container"
13+
)
14+
15+
// LFSLockList is a list of LFSLock
16+
type LFSLockList []*LFSLock
17+
18+
// LoadAttributes loads the attributes for the given locks
19+
func (locks LFSLockList) LoadAttributes(ctx context.Context) error {
20+
if len(locks) == 0 {
21+
return nil
22+
}
23+
24+
if err := locks.LoadOwner(ctx); err != nil {
25+
return fmt.Errorf("load owner: %w", err)
26+
}
27+
28+
return nil
29+
}
30+
31+
// LoadOwner loads the owner of the locks
32+
func (locks LFSLockList) LoadOwner(ctx context.Context) error {
33+
if len(locks) == 0 {
34+
return nil
35+
}
36+
37+
usersIDs := container.FilterSlice(locks, func(lock *LFSLock) (int64, bool) {
38+
return lock.OwnerID, true
39+
})
40+
users := make(map[int64]*user_model.User, len(usersIDs))
41+
if err := db.GetEngine(ctx).
42+
In("id", usersIDs).
43+
Find(&users); err != nil {
44+
return fmt.Errorf("find users: %w", err)
45+
}
46+
for _, v := range locks {
47+
v.Owner = users[v.OwnerID]
48+
if v.Owner == nil { // not exist
49+
v.Owner = user_model.NewGhostUser()
50+
}
51+
}
52+
53+
return nil
54+
}

models/issues/comment.go

+50-28
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ func (r RoleInRepo) LocaleHelper(lang translation.Locale) string {
222222
return lang.TrString("repo.issues.role." + string(r) + "_helper")
223223
}
224224

225+
// CommentMetaData stores metadata for a comment, these data will not be changed once inserted into database
226+
type CommentMetaData struct {
227+
ProjectColumnID int64 `json:"project_column_id,omitempty"`
228+
ProjectColumnTitle string `json:"project_column_title,omitempty"`
229+
ProjectTitle string `json:"project_title,omitempty"`
230+
}
231+
225232
// Comment represents a comment in commit and issue page.
226233
type Comment struct {
227234
ID int64 `xorm:"pk autoincr"`
@@ -295,6 +302,8 @@ type Comment struct {
295302
RefAction references.XRefAction `xorm:"SMALLINT"` // What happens if RefIssueID resolves
296303
RefIsPull bool
297304

305+
CommentMetaData *CommentMetaData `xorm:"JSON TEXT"` // put all non-index metadata in a single field
306+
298307
RefRepo *repo_model.Repository `xorm:"-"`
299308
RefIssue *Issue `xorm:"-"`
300309
RefComment *Comment `xorm:"-"`
@@ -797,6 +806,15 @@ func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment,
797806
LabelID = opts.Label.ID
798807
}
799808

809+
var commentMetaData *CommentMetaData
810+
if opts.ProjectColumnTitle != "" {
811+
commentMetaData = &CommentMetaData{
812+
ProjectColumnID: opts.ProjectColumnID,
813+
ProjectColumnTitle: opts.ProjectColumnTitle,
814+
ProjectTitle: opts.ProjectTitle,
815+
}
816+
}
817+
800818
comment := &Comment{
801819
Type: opts.Type,
802820
PosterID: opts.Doer.ID,
@@ -830,6 +848,7 @@ func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment,
830848
RefIsPull: opts.RefIsPull,
831849
IsForcePush: opts.IsForcePush,
832850
Invalidated: opts.Invalidated,
851+
CommentMetaData: commentMetaData,
833852
}
834853
if _, err = e.Insert(comment); err != nil {
835854
return nil, err
@@ -982,34 +1001,37 @@ type CreateCommentOptions struct {
9821001
Issue *Issue
9831002
Label *Label
9841003

985-
DependentIssueID int64
986-
OldMilestoneID int64
987-
MilestoneID int64
988-
OldProjectID int64
989-
ProjectID int64
990-
TimeID int64
991-
AssigneeID int64
992-
AssigneeTeamID int64
993-
RemovedAssignee bool
994-
OldTitle string
995-
NewTitle string
996-
OldRef string
997-
NewRef string
998-
CommitID int64
999-
CommitSHA string
1000-
Patch string
1001-
LineNum int64
1002-
TreePath string
1003-
ReviewID int64
1004-
Content string
1005-
Attachments []string // UUIDs of attachments
1006-
RefRepoID int64
1007-
RefIssueID int64
1008-
RefCommentID int64
1009-
RefAction references.XRefAction
1010-
RefIsPull bool
1011-
IsForcePush bool
1012-
Invalidated bool
1004+
DependentIssueID int64
1005+
OldMilestoneID int64
1006+
MilestoneID int64
1007+
OldProjectID int64
1008+
ProjectID int64
1009+
ProjectTitle string
1010+
ProjectColumnID int64
1011+
ProjectColumnTitle string
1012+
TimeID int64
1013+
AssigneeID int64
1014+
AssigneeTeamID int64
1015+
RemovedAssignee bool
1016+
OldTitle string
1017+
NewTitle string
1018+
OldRef string
1019+
NewRef string
1020+
CommitID int64
1021+
CommitSHA string
1022+
Patch string
1023+
LineNum int64
1024+
TreePath string
1025+
ReviewID int64
1026+
Content string
1027+
Attachments []string // UUIDs of attachments
1028+
RefRepoID int64
1029+
RefIssueID int64
1030+
RefCommentID int64
1031+
RefAction references.XRefAction
1032+
RefIsPull bool
1033+
IsForcePush bool
1034+
Invalidated bool
10131035
}
10141036

10151037
// GetCommentByID returns the comment by given ID.

models/issues/issue_list.go

+1
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ func (issues IssueList) loadComments(ctx context.Context, cond builder.Cond) (er
441441
Join("INNER", "issue", "issue.id = comment.issue_id").
442442
In("issue.id", issuesIDs[:limit]).
443443
Where(cond).
444+
NoAutoCondition().
444445
Rows(new(Comment))
445446
if err != nil {
446447
return err

models/migrations/migrations.go

+2
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ var migrations = []Migration{
597597
NewMigration("Add skip_secondary_authorization option to oauth2 application table", v1_23.AddSkipSecondaryAuthColumnToOAuth2ApplicationTable),
598598
// v302 -> v303
599599
NewMigration("Add index to action_task stopped log_expired", v1_23.AddIndexToActionTaskStoppedLogExpired),
600+
// v303 -> v304
601+
NewMigration("Add metadata column for comment table", v1_23.AddCommentMetaDataColumn),
600602
}
601603

602604
// GetCurrentDBVersion returns the current db version

models/migrations/v1_23/v303.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_23 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
// CommentMetaData stores metadata for a comment, these data will not be changed once inserted into database
11+
type CommentMetaData struct {
12+
ProjectColumnID int64 `json:"project_column_id"`
13+
ProjectColumnTitle string `json:"project_column_title"`
14+
ProjectTitle string `json:"project_title"`
15+
}
16+
17+
func AddCommentMetaDataColumn(x *xorm.Engine) error {
18+
type Comment struct {
19+
CommentMetaData *CommentMetaData `xorm:"JSON TEXT"` // put all non-index metadata in a single field
20+
}
21+
22+
return x.Sync(new(Comment))
23+
}

0 commit comments

Comments
 (0)