Skip to content

Commit 338cbf6

Browse files
authored
Merge branch 'main' into fix/new-file-space
2 parents 7a3ffb2 + 55f1fcf commit 338cbf6

File tree

49 files changed

+1113
-258
lines changed

Some content is hidden

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

49 files changed

+1113
-258
lines changed

assets/go-licenses.json

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ module code.gitea.io/gitea
22

33
go 1.23
44

5+
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
6+
// But some CAs use negative serial number, just relax the check. related:
7+
// Default TLS cert uses negative serial number #895 https://github.com/microsoft/mssql-docker/issues/895
8+
godebug x509negativeserial=1
9+
510
require (
611
code.gitea.io/actions-proto-go v0.4.0
712
code.gitea.io/gitea-vet v0.2.3
@@ -23,6 +28,9 @@ require (
2328
github.com/PuerkitoBio/goquery v1.9.2
2429
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2
2530
github.com/alecthomas/chroma/v2 v2.14.0
31+
github.com/aws/aws-sdk-go v1.43.21
32+
github.com/aws/aws-sdk-go-v2/credentials v1.17.30
33+
github.com/aws/aws-sdk-go-v2/service/codecommit v1.25.1
2634
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
2735
github.com/blevesearch/bleve/v2 v2.4.2
2836
github.com/buildkite/terminal-to-html/v3 v3.12.1
@@ -146,6 +154,10 @@ require (
146154
github.com/andybalholm/cascadia v1.3.2 // indirect
147155
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
148156
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
157+
github.com/aws/aws-sdk-go-v2 v1.30.4 // indirect
158+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 // indirect
159+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 // indirect
160+
github.com/aws/smithy-go v1.20.4 // indirect
149161
github.com/aymerick/douceur v0.2.0 // indirect
150162
github.com/beorn7/perks v1.0.1 // indirect
151163
github.com/bits-and-blooms/bitset v1.13.0 // indirect

go.sum

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
109109
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
110110
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
111111
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
112+
github.com/aws/aws-sdk-go v1.43.21 h1:E4S2eX3d2gKJyI/ISrcIrSwXwqjIvCK85gtBMt4sAPE=
113+
github.com/aws/aws-sdk-go v1.43.21/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
114+
github.com/aws/aws-sdk-go-v2 v1.30.4 h1:frhcagrVNrzmT95RJImMHgabt99vkXGslubDaDagTk8=
115+
github.com/aws/aws-sdk-go-v2 v1.30.4/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0=
116+
github.com/aws/aws-sdk-go-v2/credentials v1.17.30 h1:aau/oYFtibVovr2rDt8FHlU17BTicFEMAi29V1U+L5Q=
117+
github.com/aws/aws-sdk-go-v2/credentials v1.17.30/go.mod h1:BPJ/yXV92ZVq6G8uYvbU0gSl8q94UB63nMT5ctNO38g=
118+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 h1:TNyt/+X43KJ9IJJMjKfa3bNTiZbUP7DeCxfbTROESwY=
119+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16/go.mod h1:2DwJF39FlNAUiX5pAc0UNeiz16lK2t7IaFcm0LFHEgc=
120+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 h1:jYfy8UPmd+6kJW5YhY0L1/KftReOGxI/4NtVSTh9O/I=
121+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16/go.mod h1:7ZfEPZxkW42Afq4uQB8H2E2e6ebh6mXTueEpYzjCzcs=
122+
github.com/aws/aws-sdk-go-v2/service/codecommit v1.25.1 h1:mOOALIM4JzhYkq3voCBbmZqmyEVEhHsfasMTbVxLkNs=
123+
github.com/aws/aws-sdk-go-v2/service/codecommit v1.25.1/go.mod h1:6zf5j3mIUXKM0s2iz5ttR2Qwq+o47D0jotpAyaKgZRA=
124+
github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4=
125+
github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
112126
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
113127
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
114128
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -504,6 +518,9 @@ github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LF
504518
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
505519
github.com/jhillyerd/enmime v1.2.0 h1:dIu1IPEymQgoT2dzuB//ttA/xcV40NMPpQtmd4wslHk=
506520
github.com/jhillyerd/enmime v1.2.0/go.mod h1:FRFuUPCLh8PByQv+8xRcLO9QHqaqTqreYhopv5eyk4I=
521+
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
522+
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
523+
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
507524
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
508525
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
509526
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -894,6 +911,7 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R
894911
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
895912
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
896913
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
914+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
897915
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
898916
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
899917
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=

models/issues/issue_project.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ func (issue *Issue) ProjectColumnID(ctx context.Context) int64 {
4848
}
4949

5050
// LoadIssuesFromColumn load issues assigned to this column
51-
func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column) (IssueList, error) {
52-
issueList, err := Issues(ctx, &IssuesOptions{
53-
ProjectColumnID: b.ID,
54-
ProjectID: b.ProjectID,
55-
SortType: "project-column-sorting",
56-
})
51+
func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column, opts *IssuesOptions) (IssueList, error) {
52+
issueList, err := Issues(ctx, opts.Copy(func(o *IssuesOptions) {
53+
o.ProjectColumnID = b.ID
54+
o.ProjectID = b.ProjectID
55+
o.SortType = "project-column-sorting"
56+
}))
5757
if err != nil {
5858
return nil, err
5959
}
@@ -78,10 +78,10 @@ func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column) (IssueLi
7878
}
7979

8080
// LoadIssuesFromColumnList load issues assigned to the columns
81-
func LoadIssuesFromColumnList(ctx context.Context, bs project_model.ColumnList) (map[int64]IssueList, error) {
81+
func LoadIssuesFromColumnList(ctx context.Context, bs project_model.ColumnList, opts *IssuesOptions) (map[int64]IssueList, error) {
8282
issuesMap := make(map[int64]IssueList, len(bs))
8383
for i := range bs {
84-
il, err := LoadIssuesFromColumn(ctx, bs[i])
84+
il, err := LoadIssuesFromColumn(ctx, bs[i], opts)
8585
if err != nil {
8686
return nil, err
8787
}

models/issues/issue_search.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ type IssuesOptions struct { //nolint
5454
User *user_model.User // issues permission scope
5555
}
5656

57+
// Copy returns a copy of the options.
58+
// Be careful, it's not a deep copy, so `IssuesOptions.RepoIDs = {...}` is OK while `IssuesOptions.RepoIDs[0] = ...` is not.
59+
func (o *IssuesOptions) Copy(edit ...func(options *IssuesOptions)) *IssuesOptions {
60+
if o == nil {
61+
return nil
62+
}
63+
v := *o
64+
for _, e := range edit {
65+
e(&v)
66+
}
67+
return &v
68+
}
69+
5770
// applySorts sort an issues-related session based on the provided
5871
// sortType string
5972
func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) {

models/organization/org_user.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import (
99

1010
"code.gitea.io/gitea/models/db"
1111
"code.gitea.io/gitea/models/perm"
12+
"code.gitea.io/gitea/models/unit"
1213
user_model "code.gitea.io/gitea/models/user"
14+
"code.gitea.io/gitea/modules/container"
1315
"code.gitea.io/gitea/modules/log"
1416

1517
"xorm.io/builder"
@@ -112,6 +114,49 @@ func IsUserOrgOwner(ctx context.Context, users user_model.UserList, orgID int64)
112114
return results
113115
}
114116

117+
// GetOrgAssignees returns all users that have write access and can be assigned to issues
118+
// of the any repository in the organization.
119+
func GetOrgAssignees(ctx context.Context, orgID int64) (_ []*user_model.User, err error) {
120+
e := db.GetEngine(ctx)
121+
userIDs := make([]int64, 0, 10)
122+
if err = e.Table("access").
123+
Join("INNER", "repository", "`repository`.id = `access`.repo_id").
124+
Where("`repository`.owner_id = ? AND `access`.mode >= ?", orgID, perm.AccessModeWrite).
125+
Select("user_id").
126+
Find(&userIDs); err != nil {
127+
return nil, err
128+
}
129+
130+
additionalUserIDs := make([]int64, 0, 10)
131+
if err = e.Table("team_user").
132+
Join("INNER", "team_repo", "`team_repo`.team_id = `team_user`.team_id").
133+
Join("INNER", "team_unit", "`team_unit`.team_id = `team_user`.team_id").
134+
Join("INNER", "repository", "`repository`.id = `team_repo`.repo_id").
135+
Where("`repository`.owner_id = ? AND (`team_unit`.access_mode >= ? OR (`team_unit`.access_mode = ? AND `team_unit`.`type` = ?))",
136+
orgID, perm.AccessModeWrite, perm.AccessModeRead, unit.TypePullRequests).
137+
Distinct("`team_user`.uid").
138+
Select("`team_user`.uid").
139+
Find(&additionalUserIDs); err != nil {
140+
return nil, err
141+
}
142+
143+
uniqueUserIDs := make(container.Set[int64])
144+
uniqueUserIDs.AddMultiple(userIDs...)
145+
uniqueUserIDs.AddMultiple(additionalUserIDs...)
146+
147+
users := make([]*user_model.User, 0, len(uniqueUserIDs))
148+
if len(userIDs) > 0 {
149+
if err = e.In("id", uniqueUserIDs.Values()).
150+
Where(builder.Eq{"`user`.is_active": true}).
151+
OrderBy(user_model.GetOrderByName()).
152+
Find(&users); err != nil {
153+
return nil, err
154+
}
155+
}
156+
157+
return users, nil
158+
}
159+
115160
func loadOrganizationOwners(ctx context.Context, users user_model.UserList, orgID int64) (map[int64]*TeamUser, error) {
116161
if len(users) == 0 {
117162
return nil, nil

models/repo/release.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ type FindReleasesOptions struct {
234234
IsDraft optional.Option[bool]
235235
TagNames []string
236236
HasSha1 optional.Option[bool] // useful to find draft releases which are created with existing tags
237+
NamePattern optional.Option[string]
237238
}
238239

239240
func (opts FindReleasesOptions) ToConds() builder.Cond {
@@ -261,6 +262,11 @@ func (opts FindReleasesOptions) ToConds() builder.Cond {
261262
cond = cond.And(builder.Eq{"sha1": ""})
262263
}
263264
}
265+
266+
if opts.NamePattern.Has() && opts.NamePattern.Value() != "" {
267+
cond = cond.And(builder.Like{"lower_tag_name", strings.ToLower(opts.NamePattern.Value())})
268+
}
269+
264270
return cond
265271
}
266272

modules/hostmatcher/http.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import (
1313
)
1414

1515
// NewDialContext returns a DialContext for Transport, the DialContext will do allow/block list check
16-
func NewDialContext(usage string, allowList, blockList *HostMatchList) func(ctx context.Context, network, addr string) (net.Conn, error) {
17-
return NewDialContextWithProxy(usage, allowList, blockList, nil)
18-
}
19-
20-
func NewDialContextWithProxy(usage string, allowList, blockList *HostMatchList, proxy *url.URL) func(ctx context.Context, network, addr string) (net.Conn, error) {
16+
func NewDialContext(usage string, allowList, blockList *HostMatchList, proxy *url.URL) func(ctx context.Context, network, addr string) (net.Conn, error) {
2117
// How Go HTTP Client works with redirection:
2218
// transport.RoundTrip URL=http://domain.com, Host=domain.com
2319
// transport.DialContext addrOrHost=domain.com:80

modules/migration/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ type MigrateOptions struct {
3838
ReleaseAssets bool
3939
MigrateToRepoID int64
4040
MirrorInterval string `json:"mirror_interval"`
41+
42+
AWSAccessKeyID string
43+
AWSSecretAccessKey string
4144
}

modules/structs/repo.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,16 @@ type GitServiceType int
291291

292292
// enumerate all GitServiceType
293293
const (
294-
NotMigrated GitServiceType = iota // 0 not migrated from external sites
295-
PlainGitService // 1 plain git service
296-
GithubService // 2 github.com
297-
GiteaService // 3 gitea service
298-
GitlabService // 4 gitlab service
299-
GogsService // 5 gogs service
300-
OneDevService // 6 onedev service
301-
GitBucketService // 7 gitbucket service
302-
CodebaseService // 8 codebase service
294+
NotMigrated GitServiceType = iota // 0 not migrated from external sites
295+
PlainGitService // 1 plain git service
296+
GithubService // 2 github.com
297+
GiteaService // 3 gitea service
298+
GitlabService // 4 gitlab service
299+
GogsService // 5 gogs service
300+
OneDevService // 6 onedev service
301+
GitBucketService // 7 gitbucket service
302+
CodebaseService // 8 codebase service
303+
CodeCommitService // 9 codecommit service
303304
)
304305

305306
// Name represents the service type's name
@@ -325,6 +326,8 @@ func (gt GitServiceType) Title() string {
325326
return "GitBucket"
326327
case CodebaseService:
327328
return "Codebase"
329+
case CodeCommitService:
330+
return "CodeCommit"
328331
case PlainGitService:
329332
return "Git"
330333
}
@@ -361,6 +364,9 @@ type MigrateRepoOptions struct {
361364
PullRequests bool `json:"pull_requests"`
362365
Releases bool `json:"releases"`
363366
MirrorInterval string `json:"mirror_interval"`
367+
368+
AWSAccessKeyID string `json:"aws_access_key_id"`
369+
AWSSecretAccessKey string `json:"aws_secret_access_key"`
364370
}
365371

366372
// TokenAuth represents whether a service type supports token-based auth
@@ -382,6 +388,7 @@ var SupportedFullGitService = []GitServiceType{
382388
OneDevService,
383389
GitBucketService,
384390
CodebaseService,
391+
CodeCommitService,
385392
}
386393

387394
// RepoTransfer represents a pending repo transfer

0 commit comments

Comments
 (0)