Skip to content

Commit bdac1a4

Browse files
authored
Merge branch 'main' into fix-incorrect-value-in-oauth-tmpl
2 parents a3f5205 + fbd4eac commit bdac1a4

File tree

90 files changed

+757
-346
lines changed

Some content is hidden

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

90 files changed

+757
-346
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ rules:
164164
jquery/no-parse-html: [2]
165165
jquery/no-prop: [0]
166166
jquery/no-proxy: [2]
167-
jquery/no-ready: [0]
167+
jquery/no-ready: [2]
168168
jquery/no-serialize: [2]
169169
jquery/no-show: [2]
170170
jquery/no-size: [2]

build/backport-locales.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ func main() {
7777
if secNew.HasKey(keyEnUs.Name()) {
7878
oldStr := secOld.Key(keyEnUs.Name()).String()
7979
newStr := secNew.Key(keyEnUs.Name()).String()
80-
// A bug: many of new translations with ";" are broken in Crowdin (due to last messy restoring)
81-
// As the broken strings are gradually fixed, this workaround check could be removed (in a few months?)
82-
if strings.Contains(oldStr, ";") && !strings.Contains(newStr, ";") {
83-
println("skip potential broken string", path, secEnUS.Name(), keyEnUs.Name())
80+
if oldStr != "" && strings.Count(oldStr, "%") != strings.Count(newStr, "%") {
81+
fmt.Printf("WARNING: locale %s [%s]%s has different number of arguments, skipping\n", path, secEnUS.Name(), keyEnUs.Name())
82+
fmt.Printf("\told: %s\n", oldStr)
83+
fmt.Printf("\tnew: %s\n", newStr)
84+
fmt.Println("---- ")
8485
continue
8586
}
8687
secOld.Key(keyEnUs.Name()).SetValue(newStr)

build/update-locales.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@ fi
1717

1818
mv ./options/locale/locale_en-US.ini ./options/
1919

20-
# the "ini" library for locale has many quirks
21-
# * `a="xx"` gets `xx` (no quote)
22-
# * `a=x\"y` gets `x\"y` (no unescaping)
23-
# * `a="x\"y"` gets `"x\"y"` (no unescaping, the quotes are still there)
24-
# * `a='x\"y'` gets `x\"y` (no unescaping, no quote)
25-
# * `a="foo` gets `"foo` (although the quote is not closed)
26-
# * 'a=`foo`' works like single-quote
27-
# crowdin needs the strings to be quoted correctly and doesn't like incomplete quotes
28-
# crowdin always outputs quoted strings if there are quotes in the strings.
29-
30-
# this script helps to unquote the crowdin outputs for the quirky ini library
20+
# the "ini" library for locale has many quirks, its behavior is different from Crowdin.
21+
# see i18n_test.go for more details
22+
23+
# this script helps to unquote the Crowdin outputs for the quirky ini library
3124
# * find all `key="...\"..."` lines
3225
# * remove the leading quote
3326
# * remove the trailing quote

custom/conf/app.example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,10 @@ ROUTER = console
12381238
;;
12391239
;; Whether to enable a Service Worker to cache frontend assets
12401240
;USE_SERVICE_WORKER = false
1241+
;;
1242+
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
1243+
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
1244+
;ONLY_SHOW_RELEVANT_REPOS = false
12411245

12421246
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12431247
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/administration/config-cheat-sheet.en-us.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,13 @@ The following configuration set `Content-Type: application/vnd.android.package-a
226226
Values can be emoji alias (:smile:) or a unicode emoji.
227227
For custom reactions, add a tightly cropped square image to public/img/emoji/reaction_name.png
228228
- `CUSTOM_EMOJIS`: **gitea, codeberg, gitlab, git, github, gogs**: Additional Emojis not defined in the utf8 standard.
229-
By default we support Gitea (:gitea:), to add more copy them to public/img/emoji/emoji_name.png and
229+
By default, we support Gitea (:gitea:), to add more copy them to public/img/emoji/emoji_name.png and
230230
add it to this config.
231231
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
232232
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
233233
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
234+
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
235+
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
234236

235237
### UI - Admin (`ui.admin`)
236238

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
289289

290290
replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix
291291

292-
replace github.com/nektos/act => gitea.com/gitea/act v0.243.1
292+
replace github.com/nektos/act => gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab
293293

294294
exclude github.com/gofrs/uuid v3.2.0+incompatible
295295

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi
5252
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
5353
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
5454
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
55-
gitea.com/gitea/act v0.243.1 h1:zIVlhGOLE4SHFPW++u3+5Y/jX5mub3QIhB13oNf6rtA=
56-
gitea.com/gitea/act v0.243.1/go.mod h1:iLHCXqOPUElA2nSyHo4wtxSmvdkym3WU7CkP3AxF39Q=
55+
gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab h1:HDImhO/XpMJrw2PJcADI/wgur9Gro/pegLFaRt8Wpg0=
56+
gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab/go.mod h1:mabw6AZAiDgxGlK83orWLrNERSPvgBJzEUS3S7u2bHI=
5757
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4=
5858
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
5959
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=

models/actions/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
197197
for _, v := range jobs {
198198
id, job := v.Job()
199199
needs := job.Needs()
200-
job.EraseNeeds()
200+
if err := v.SetJob(id, job.EraseNeeds()); err != nil {
201+
return err
202+
}
201203
payload, _ := v.Marshal()
202204
status := StatusWaiting
203205
if len(needs) > 0 || run.NeedApproval {

models/auth/source.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@ func UpdateSource(source *Source) error {
317317
}
318318
}
319319

320-
_, err := db.GetEngine(db.DefaultContext).ID(source.ID).AllCols().Update(source)
320+
has, err := db.GetEngine(db.DefaultContext).Where("name=? AND id!=?", source.Name, source.ID).Exist(new(Source))
321+
if err != nil {
322+
return err
323+
} else if has {
324+
return ErrSourceAlreadyExist{source.Name}
325+
}
326+
327+
_, err = db.GetEngine(db.DefaultContext).ID(source.ID).AllCols().Update(source)
321328
if err != nil {
322329
return err
323330
}

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ var migrations = []Migration{
477477
NewMigration("Add version column to action_runner table", v1_20.AddVersionToActionRunner),
478478
// v249 -> v250
479479
NewMigration("Improve Action table indices v3", v1_20.ImproveActionTableIndices),
480+
// v250 -> v251
481+
NewMigration("Change Container Metadata", v1_20.ChangeContainerMetadataMultiArch),
480482
}
481483

482484
// GetCurrentDBVersion returns the current db version

models/migrations/v1_20/v250.go

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_20 //nolint
5+
6+
import (
7+
"strings"
8+
9+
"code.gitea.io/gitea/modules/json"
10+
11+
"xorm.io/xorm"
12+
)
13+
14+
func ChangeContainerMetadataMultiArch(x *xorm.Engine) error {
15+
sess := x.NewSession()
16+
defer sess.Close()
17+
18+
if err := sess.Begin(); err != nil {
19+
return err
20+
}
21+
22+
type PackageVersion struct {
23+
ID int64 `xorm:"pk"`
24+
MetadataJSON string `xorm:"metadata_json"`
25+
}
26+
27+
type PackageBlob struct{}
28+
29+
// Get all relevant packages (manifest list images have a container.manifest.reference property)
30+
31+
var pvs []*PackageVersion
32+
err := sess.
33+
Table("package_version").
34+
Select("id, metadata_json").
35+
Where("id IN (SELECT DISTINCT ref_id FROM package_property WHERE ref_type = 0 AND name = 'container.manifest.reference')").
36+
Find(&pvs)
37+
if err != nil {
38+
return err
39+
}
40+
41+
type MetadataOld struct {
42+
Type string `json:"type"`
43+
IsTagged bool `json:"is_tagged"`
44+
Platform string `json:"platform,omitempty"`
45+
Description string `json:"description,omitempty"`
46+
Authors []string `json:"authors,omitempty"`
47+
Licenses string `json:"license,omitempty"`
48+
ProjectURL string `json:"project_url,omitempty"`
49+
RepositoryURL string `json:"repository_url,omitempty"`
50+
DocumentationURL string `json:"documentation_url,omitempty"`
51+
Labels map[string]string `json:"labels,omitempty"`
52+
ImageLayers []string `json:"layer_creation,omitempty"`
53+
MultiArch map[string]string `json:"multiarch,omitempty"`
54+
}
55+
56+
type Manifest struct {
57+
Platform string `json:"platform"`
58+
Digest string `json:"digest"`
59+
Size int64 `json:"size"`
60+
}
61+
62+
type MetadataNew struct {
63+
Type string `json:"type"`
64+
IsTagged bool `json:"is_tagged"`
65+
Platform string `json:"platform,omitempty"`
66+
Description string `json:"description,omitempty"`
67+
Authors []string `json:"authors,omitempty"`
68+
Licenses string `json:"license,omitempty"`
69+
ProjectURL string `json:"project_url,omitempty"`
70+
RepositoryURL string `json:"repository_url,omitempty"`
71+
DocumentationURL string `json:"documentation_url,omitempty"`
72+
Labels map[string]string `json:"labels,omitempty"`
73+
ImageLayers []string `json:"layer_creation,omitempty"`
74+
Manifests []*Manifest `json:"manifests,omitempty"`
75+
}
76+
77+
for _, pv := range pvs {
78+
var old *MetadataOld
79+
if err := json.Unmarshal([]byte(pv.MetadataJSON), &old); err != nil {
80+
return err
81+
}
82+
83+
// Calculate the size of every contained manifest
84+
85+
manifests := make([]*Manifest, 0, len(old.MultiArch))
86+
for platform, digest := range old.MultiArch {
87+
size, err := sess.
88+
Table("package_blob").
89+
Join("INNER", "package_file", "package_blob.id = package_file.blob_id").
90+
Join("INNER", "package_version pv", "pv.id = package_file.version_id").
91+
Join("INNER", "package_version pv2", "pv2.package_id = pv.package_id").
92+
Where("pv.lower_version = ? AND pv2.id = ?", strings.ToLower(digest), pv.ID).
93+
SumInt(new(PackageBlob), "size")
94+
if err != nil {
95+
return err
96+
}
97+
98+
manifests = append(manifests, &Manifest{
99+
Platform: platform,
100+
Digest: digest,
101+
Size: size,
102+
})
103+
}
104+
105+
// Convert to new metadata format
106+
107+
new := &MetadataNew{
108+
Type: old.Type,
109+
IsTagged: old.IsTagged,
110+
Platform: old.Platform,
111+
Description: old.Description,
112+
Authors: old.Authors,
113+
Licenses: old.Licenses,
114+
ProjectURL: old.ProjectURL,
115+
RepositoryURL: old.RepositoryURL,
116+
DocumentationURL: old.DocumentationURL,
117+
Labels: old.Labels,
118+
ImageLayers: old.ImageLayers,
119+
Manifests: manifests,
120+
}
121+
122+
metadataJSON, err := json.Marshal(new)
123+
if err != nil {
124+
return err
125+
}
126+
127+
pv.MetadataJSON = string(metadataJSON)
128+
129+
if _, err := sess.ID(pv.ID).Update(pv); err != nil {
130+
return err
131+
}
132+
}
133+
134+
return sess.Commit()
135+
}

modules/actions/workflows.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
122122
webhook_module.HookEventRepository,
123123
webhook_module.HookEventRelease,
124124
webhook_module.HookEventPackage:
125-
if len(evt.Acts) != 0 {
126-
log.Warn("Ignore unsupported %s event arguments %q", triggedEvent, evt.Acts)
125+
if len(evt.Acts()) != 0 {
126+
log.Warn("Ignore unsupported %s event arguments %v", triggedEvent, evt.Acts())
127127
}
128128
// no special filter parameters for these events, just return true if name matched
129129
return true
@@ -148,7 +148,7 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
148148

149149
func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobparser.Event) bool {
150150
// with no special filter parameters
151-
if len(evt.Acts) == 0 {
151+
if len(evt.Acts()) == 0 {
152152
return true
153153
}
154154

@@ -157,7 +157,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
157157
hasTagFilter := false
158158
refName := git.RefName(pushPayload.Ref)
159159
// all acts conditions should be satisfied
160-
for cond, vals := range evt.Acts {
160+
for cond, vals := range evt.Acts() {
161161
switch cond {
162162
case "branches":
163163
hasBranchFilter = true
@@ -241,18 +241,18 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
241241
if hasBranchFilter && hasTagFilter {
242242
matchTimes++
243243
}
244-
return matchTimes == len(evt.Acts)
244+
return matchTimes == len(evt.Acts())
245245
}
246246

247247
func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *jobparser.Event) bool {
248248
// with no special filter parameters
249-
if len(evt.Acts) == 0 {
249+
if len(evt.Acts()) == 0 {
250250
return true
251251
}
252252

253253
matchTimes := 0
254254
// all acts conditions should be satisfied
255-
for cond, vals := range evt.Acts {
255+
for cond, vals := range evt.Acts() {
256256
switch cond {
257257
case "types":
258258
for _, val := range vals {
@@ -265,19 +265,19 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
265265
log.Warn("issue event unsupported condition %q", cond)
266266
}
267267
}
268-
return matchTimes == len(evt.Acts)
268+
return matchTimes == len(evt.Acts())
269269
}
270270

271271
func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool {
272272
// with no special filter parameters
273-
if len(evt.Acts) == 0 {
273+
if len(evt.Acts()) == 0 {
274274
// defaultly, only pull request opened and synchronized will trigger workflow
275275
return prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened
276276
}
277277

278278
matchTimes := 0
279279
// all acts conditions should be satisfied
280-
for cond, vals := range evt.Acts {
280+
for cond, vals := range evt.Acts() {
281281
switch cond {
282282
case "types":
283283
action := prPayload.Action
@@ -339,18 +339,18 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
339339
log.Warn("pull request event unsupported condition %q", cond)
340340
}
341341
}
342-
return matchTimes == len(evt.Acts)
342+
return matchTimes == len(evt.Acts())
343343
}
344344

345345
func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool {
346346
// with no special filter parameters
347-
if len(evt.Acts) == 0 {
347+
if len(evt.Acts()) == 0 {
348348
return true
349349
}
350350

351351
matchTimes := 0
352352
// all acts conditions should be satisfied
353-
for cond, vals := range evt.Acts {
353+
for cond, vals := range evt.Acts() {
354354
switch cond {
355355
case "types":
356356
for _, val := range vals {
@@ -363,5 +363,5 @@ func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCo
363363
log.Warn("issue comment unsupported condition %q", cond)
364364
}
365365
}
366-
return matchTimes == len(evt.Acts)
366+
return matchTimes == len(evt.Acts())
367367
}

modules/packages/container/metadata.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ type Metadata struct {
6262
DocumentationURL string `json:"documentation_url,omitempty"`
6363
Labels map[string]string `json:"labels,omitempty"`
6464
ImageLayers []string `json:"layer_creation,omitempty"`
65-
MultiArch map[string]string `json:"multiarch,omitempty"`
65+
Manifests []*Manifest `json:"manifests,omitempty"`
66+
}
67+
68+
type Manifest struct {
69+
Platform string `json:"platform"`
70+
Digest string `json:"digest"`
71+
Size int64 `json:"size"`
6672
}
6773

6874
// ParseImageConfig parses the metadata of an image config

modules/packages/container/metadata_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestParseImageConfig(t *testing.T) {
4646
},
4747
metadata.Labels,
4848
)
49-
assert.Empty(t, metadata.MultiArch)
49+
assert.Empty(t, metadata.Manifests)
5050

5151
configHelm := `{"description":"` + description + `", "home": "` + projectURL + `", "sources": ["` + repositoryURL + `"], "maintainers":[{"name":"` + author + `"}]}`
5252

0 commit comments

Comments
 (0)