Skip to content

Commit 91a5317

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Use `Set[Type]` instead of `map[Type]bool/struct{}`. (go-gitea#26804) Fix verifyCommits error when push a new branch (go-gitea#26664) Fix Uint8Array comparisons and update vitest (go-gitea#26805) Add various missing files-changed dependencies (go-gitea#26799) Improve flex list item padding (go-gitea#26779) Include the GITHUB_TOKEN/GITEA_TOKEN secret for fork pull requests (go-gitea#26759) feat(API): add route and implementation for creating/updating repository secret (go-gitea#26766) Replace deprecated `elliptic.Marshal` (go-gitea#26800) Updating the js libraries to latest version. (go-gitea#26795) Fix some slice append usages (go-gitea#26778) Use Go 1.21 for golangci-lint (go-gitea#26786) Fix notification circle (border-radius) (go-gitea#26794) Fix context filter has no effect in dashboard (go-gitea#26695) Add default label in branch select list (go-gitea#26697) Remove redundant nil check in `WalkGitLog` (go-gitea#26773) Remove fomantic `item` module (go-gitea#26775) Update info regarding internet connection for build (go-gitea#26776) Fix being unable to use a repo that prohibits accepting PRs as a PR source. (go-gitea#26785)
2 parents 764a683 + 5315153 commit 91a5317

File tree

79 files changed

+692
-786
lines changed

Some content is hidden

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

79 files changed

+692
-786
lines changed

.github/workflows/files-changed.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
- "go.mod"
4444
- "go.sum"
4545
- "Makefile"
46+
- ".golangci.yml"
47+
- ".editorconfig"
4648
4749
frontend:
4850
- "**/*.js"
@@ -51,16 +53,21 @@ jobs:
5153
- "package.json"
5254
- "package-lock.json"
5355
- "Makefile"
56+
- ".eslintrc.yaml"
57+
- ".stylelintrc.yaml"
58+
- ".npmrc"
5459
5560
docs:
5661
- "**/*.md"
5762
- "docs/**"
63+
- ".markdownlint.yaml"
5864
5965
actions:
6066
- ".github/workflows/*"
6167
6268
templates:
6369
- "templates/**/*.tmpl"
70+
- "pyproject.toml"
6471
- "poetry.lock"
6572
6673
docker:
@@ -72,3 +79,6 @@ jobs:
7279
swagger:
7380
- "templates/swagger/v1_json.tmpl"
7481
- "Makefile"
82+
- "package.json"
83+
- "package-lock.json"
84+
- ".spectral.yml"

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ linters:
2929
fast: false
3030

3131
run:
32-
go: "1.20"
32+
go: "1.21"
3333
timeout: 10m
3434
skip-dirs:
3535
- node_modules
@@ -75,7 +75,7 @@ linters-settings:
7575
- name: modifies-value-receiver
7676
gofumpt:
7777
extra-rules: true
78-
lang-version: "1.20"
78+
lang-version: "1.21"
7979
depguard:
8080
rules:
8181
main:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ or if SQLite support is required:
7979

8080
The `build` target is split into two sub-targets:
8181

82-
- `make backend` which requires [Go Stable](https://go.dev/dl/), required version is defined in [go.mod](/go.mod).
83-
- `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.
82+
- `make backend` which requires [Go Stable](https://go.dev/dl/), the required version is defined in [go.mod](/go.mod).
83+
- `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater.
8484

85-
When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.
85+
Internet connectivity is required to download the go and npm modules. When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js.
8686

8787
Parallelism (`make -j <num>`) is not supported.
8888

build/backport-locales.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"path/filepath"
1313
"strings"
1414

15+
"code.gitea.io/gitea/modules/container"
1516
"code.gitea.io/gitea/modules/setting"
1617
)
1718

@@ -58,7 +59,7 @@ func main() {
5859

5960
// use old en-US as the base, and copy the new translations to the old locales
6061
enUsOld := inisOld["options/locale/locale_en-US.ini"]
61-
brokenWarned := map[string]bool{}
62+
brokenWarned := make(container.Set[string])
6263
for path, iniOld := range inisOld {
6364
if iniOld == enUsOld {
6465
continue
@@ -77,7 +78,7 @@ func main() {
7778
broken := oldStr != "" && strings.Count(oldStr, "%") != strings.Count(newStr, "%")
7879
broken = broken || strings.Contains(oldStr, "\n") || strings.Contains(oldStr, "\n")
7980
if broken {
80-
brokenWarned[secOld.Name()+"."+keyEnUs.Name()] = true
81+
brokenWarned.Add(secOld.Name() + "." + keyEnUs.Name())
8182
fmt.Println("----")
8283
fmt.Printf("WARNING: skip broken locale: %s , [%s] %s\n", path, secEnUS.Name(), keyEnUs.Name())
8384
fmt.Printf("\told: %s\n", strings.ReplaceAll(oldStr, "\n", "\\n"))
@@ -103,7 +104,7 @@ func main() {
103104
broken = broken || strings.HasPrefix(str, "`\"")
104105
broken = broken || strings.Count(str, `"`)%2 == 1
105106
broken = broken || strings.Count(str, "`")%2 == 1
106-
if broken && !brokenWarned[sec.Name()+"."+key.Name()] {
107+
if broken && !brokenWarned.Contains(sec.Name()+"."+key.Name()) {
107108
fmt.Printf("WARNING: found broken locale: %s , [%s] %s\n", path, sec.Name(), key.Name())
108109
fmt.Printf("\tstr: %s\n", strings.ReplaceAll(str, "\n", "\\n"))
109110
fmt.Println("----")

build/generate-go-licenses.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"regexp"
1616
"sort"
1717
"strings"
18+
19+
"code.gitea.io/gitea/modules/container"
1820
)
1921

2022
// regexp is based on go-license, excluding README and NOTICE
@@ -55,20 +57,14 @@ func main() {
5557
// yml
5658
//
5759
// It could be removed once we have a better regex.
58-
excludedExt := map[string]bool{
59-
".gitignore": true,
60-
".go": true,
61-
".mod": true,
62-
".sum": true,
63-
".toml": true,
64-
".yml": true,
65-
}
60+
excludedExt := container.SetOf(".gitignore", ".go", ".mod", ".sum", ".toml", ".yml")
61+
6662
var paths []string
6763
err := filepath.WalkDir(base, func(path string, entry fs.DirEntry, err error) error {
6864
if err != nil {
6965
return err
7066
}
71-
if entry.IsDir() || !licenseRe.MatchString(entry.Name()) || excludedExt[filepath.Ext(entry.Name())] {
67+
if entry.IsDir() || !licenseRe.MatchString(entry.Name()) || excludedExt.Contains(filepath.Ext(entry.Name())) {
7268
return nil
7369
}
7470
paths = append(paths, path)

models/fixtures/email_address.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,12 @@
276276
277277
lower_email: [email protected]
278278
is_activated: false
279-
is_primary: false
279+
is_primary: false
280+
281+
-
282+
id: 36
283+
uid: 36
284+
285+
lower_email: [email protected]
286+
is_activated: true
287+
is_primary: false

models/fixtures/gpg_key.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
[] # empty
1+
-
2+
id: 5
3+
owner_id: 36
4+
key_id: B15431642629B826
5+
primary_key_id:
6+
content: xsDNBGTrY3UBDAC2HLBqmMplAV15qSnC7g1c4dV406f5EHNhFr95Nup2My6b2eafTlvedv77s8PT/I7F3fy4apOZs5A7w2SsPlLMcQ3ev4uGOsxRtkq5RLy1Yb6SNueX0Da2UVKR5KTC5Q6BWaqxwS0IjKOLZ/xz0Pbe/ClV3bZSKBEY2omkVo3Z0HZ771vB2clPRvGJ/IdeKOsZ3ZytSFXfyiJBdARmeSPmydXLil8+Ibq5iLAeow5PK8hK1TCOnKHzLWNqcNq70tyjoHvcGi70iGjoVEEUgPCLLuU8WmzTJwlvA3BuDzjtaO7TLo/jdE6iqkHtMSS8x+43sAH6hcFRCWAVh/0Uq7n36uGDfNxGnX3YrmX3LR9x5IsBES1rGGWbpxio4o5GIf/Xd+JgDd9rzJCqRuZ3/sW/TxK38htWaVNZV0kMkHUCTc1ctzWpCm635hbFCHBhPYIp+/z206khkAKDbz/CNuU91Wazsh7KO07wrwDtxfDDbInJ8TfHE2TGjzjQzgChfmcAEQEAAQ==
7+
verified: true
8+
can_sign: true
9+
can_encrypt_comms: true
10+
can_encrypt_storage: true
11+
can_certify: true
12+
13+
-
14+
id: 6
15+
owner_id: 36
16+
key_id: EE3AF48454AFD619
17+
primary_key_id: B15431642629B826
18+
content: zsDNBGTrY3UBDADsHrzuOicQaPdUQm0+0UNrs92cESm/j/4yBBUk+sfLZAo6J99c4eh4nAQzzZ7al080rYKB0G+7xoRz1eHcQH6zrVcqB8KYtf/sdY47WaMiMyxM+kTSvzp7tsv7QuSQZ0neUEXRyYMz5ttBfIjWUd+3NDItuHyB+MtNWlS3zXgaUbe5VifqKaNmzN0Ye4yXTKcpypE3AOqPVz+iIFv3c6TmsqLHJaR4VoicCleAqLyF/28WsJO7M9dDW+EM3MZVnsVpycTURyHAJGfSk10waQZAaRwmarCN/q0KEJ+aEAK/SRliUneBZoMO5hY5iBeG432tofwaQqAahPv9uXIb1n2JEMKwnMlMA9UGD1AcDbywfj1m/ZGBBw95i4Ekkfn43RvV3THr7uJU/dRqqP+iic4MwpUrOxqELW/kmeHXlBcNbZZhEEvwRoW7U2/9eeuog4nRleRJ0pi/xOP9wmxkKjaIPIK3phdBtEpVk4w/UTAWNdyIIrFggukeAnZFyGJwlm8AEQEAAQ==
19+
verified: true
20+
can_sign: true
21+
can_encrypt_comms: true
22+
can_encrypt_storage: true
23+
can_certify: true

models/fixtures/user.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@
13011301
lower_name: limited_org36
13021302
name: limited_org36
13031303
full_name: Limited Org 36
1304-
email: limited_org36@example.com
1304+
email: abcde@gitea.com
13051305
keep_email_private: false
13061306
email_notifications_preference: enabled
13071307
passwd: ZogKvWdyEx:password
@@ -1320,7 +1320,7 @@
13201320
allow_create_organization: true
13211321
prohibit_login: false
13221322
avatar: avatar22
1323-
avatar_email: limited_org36@example.com
1323+
avatar_email: abcde@gitea.com
13241324
use_custom_avatar: false
13251325
num_followers: 0
13261326
num_following: 0

models/migrations/v1_16/v210.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package v1_16 //nolint
55

66
import (
7-
"crypto/elliptic"
87
"encoding/base32"
98
"fmt"
109
"strings"
@@ -123,13 +122,17 @@ func RemigrateU2FCredentials(x *xorm.Engine) error {
123122
if err != nil {
124123
continue
125124
}
125+
pubKey, err := parsed.PubKey.ECDH()
126+
if err != nil {
127+
continue
128+
}
126129
remigrated := &webauthnCredential{
127130
ID: reg.ID,
128131
Name: reg.Name,
129132
LowerName: strings.ToLower(reg.Name),
130133
UserID: reg.UserID,
131134
CredentialID: base32.HexEncoding.EncodeToString(parsed.KeyHandle),
132-
PublicKey: elliptic.Marshal(elliptic.P256(), parsed.PubKey.X, parsed.PubKey.Y),
135+
PublicKey: pubKey.Bytes(),
133136
AttestationType: "fido-u2f",
134137
AAGUID: []byte{},
135138
SignCount: reg.Counter,

models/secret/secret.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,31 @@ func DeleteSecret(ctx context.Context, orgID, repoID int64, name string) error {
160160

161161
return nil
162162
}
163+
164+
// CreateOrUpdateSecret creates or updates a secret and returns true if it was created
165+
func CreateOrUpdateSecret(ctx context.Context, orgID, repoID int64, name, data string) (bool, error) {
166+
sc := new(Secret)
167+
name = strings.ToUpper(name)
168+
has, err := db.GetEngine(ctx).
169+
Where("owner_id=?", orgID).
170+
And("repo_id=?", repoID).
171+
And("name=?", name).
172+
Get(sc)
173+
if err != nil {
174+
return false, err
175+
}
176+
177+
if !has {
178+
_, err = InsertEncryptedSecret(ctx, orgID, repoID, name, data)
179+
if err != nil {
180+
return false, err
181+
}
182+
return true, nil
183+
}
184+
185+
if err := UpdateSecret(ctx, orgID, repoID, name, data); err != nil {
186+
return false, err
187+
}
188+
189+
return false, nil
190+
}

models/unit/unit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
"code.gitea.io/gitea/models/perm"
12+
"code.gitea.io/gitea/modules/container"
1213
"code.gitea.io/gitea/modules/log"
1314
"code.gitea.io/gitea/modules/setting"
1415
)
@@ -318,14 +319,13 @@ var (
318319

319320
// FindUnitTypes give the unit key names and return valid unique units and invalid keys
320321
func FindUnitTypes(nameKeys ...string) (res []Type, invalidKeys []string) {
321-
m := map[Type]struct{}{}
322+
m := make(container.Set[Type])
322323
for _, key := range nameKeys {
323324
t := TypeFromKey(key)
324325
if t == TypeInvalid {
325326
invalidKeys = append(invalidKeys, key)
326-
} else if _, ok := m[t]; !ok {
327+
} else if m.Add(t) {
327328
res = append(res, t)
328-
m[t] = struct{}{}
329329
}
330330
}
331331
return res, invalidKeys

modules/assetfs/layered.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"sort"
1515
"time"
1616

17+
"code.gitea.io/gitea/modules/container"
1718
"code.gitea.io/gitea/modules/log"
1819
"code.gitea.io/gitea/modules/process"
1920
"code.gitea.io/gitea/modules/util"
@@ -130,22 +131,19 @@ func readDir(layer *Layer, name string) ([]fs.FileInfo, error) {
130131
// * false: only directories will be returned.
131132
// The returned files are sorted by name.
132133
func (l *LayeredFS) ListFiles(name string, fileMode ...bool) ([]string, error) {
133-
fileMap := map[string]bool{}
134+
fileSet := make(container.Set[string])
134135
for _, layer := range l.layers {
135136
infos, err := readDir(layer, name)
136137
if err != nil {
137138
return nil, err
138139
}
139140
for _, info := range infos {
140141
if shouldInclude(info, fileMode...) {
141-
fileMap[info.Name()] = true
142+
fileSet.Add(info.Name())
142143
}
143144
}
144145
}
145-
files := make([]string, 0, len(fileMap))
146-
for file := range fileMap {
147-
files = append(files, file)
148-
}
146+
files := fileSet.Values()
149147
sort.Strings(files)
150148
return files, nil
151149
}
@@ -161,7 +159,7 @@ func (l *LayeredFS) ListAllFiles(name string, fileMode ...bool) ([]string, error
161159
}
162160

163161
func listAllFiles(layers []*Layer, name string, fileMode ...bool) ([]string, error) {
164-
fileMap := map[string]bool{}
162+
fileSet := make(container.Set[string])
165163
var list func(dir string) error
166164
list = func(dir string) error {
167165
for _, layer := range layers {
@@ -172,7 +170,7 @@ func listAllFiles(layers []*Layer, name string, fileMode ...bool) ([]string, err
172170
for _, info := range infos {
173171
path := util.PathJoinRelX(dir, info.Name())
174172
if shouldInclude(info, fileMode...) {
175-
fileMap[path] = true
173+
fileSet.Add(path)
176174
}
177175
if info.IsDir() {
178176
if err = list(path); err != nil {
@@ -186,10 +184,7 @@ func listAllFiles(layers []*Layer, name string, fileMode ...bool) ([]string, err
186184
if err := list(name); err != nil {
187185
return nil, err
188186
}
189-
var files []string
190-
for file := range fileMap {
191-
files = append(files, file)
192-
}
187+
files := fileSet.Values()
193188
sort.Strings(files)
194189
return files, nil
195190
}

modules/git/log_name_status.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -374,27 +374,25 @@ heaploop:
374374
break heaploop
375375
}
376376
parentRemaining.Remove(current.CommitID)
377-
if current.Paths != nil {
378-
for i, found := range current.Paths {
379-
if !found {
380-
continue
377+
for i, found := range current.Paths {
378+
if !found {
379+
continue
380+
}
381+
changed[i] = false
382+
if results[i] == "" {
383+
results[i] = current.CommitID
384+
if err := repo.LastCommitCache.Put(headRef, path.Join(treepath, paths[i]), current.CommitID); err != nil {
385+
return nil, err
381386
}
382-
changed[i] = false
383-
if results[i] == "" {
384-
results[i] = current.CommitID
385-
if err := repo.LastCommitCache.Put(headRef, path.Join(treepath, paths[i]), current.CommitID); err != nil {
387+
delete(path2idx, paths[i])
388+
remaining--
389+
if results[0] == "" {
390+
results[0] = current.CommitID
391+
if err := repo.LastCommitCache.Put(headRef, treepath, current.CommitID); err != nil {
386392
return nil, err
387393
}
388-
delete(path2idx, paths[i])
394+
delete(path2idx, "")
389395
remaining--
390-
if results[0] == "" {
391-
results[0] = current.CommitID
392-
if err := repo.LastCommitCache.Put(headRef, treepath, current.CommitID); err != nil {
393-
return nil, err
394-
}
395-
delete(path2idx, "")
396-
remaining--
397-
}
398396
}
399397
}
400398
}

modules/setting/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func loadServiceFrom(rootCfg ConfigProvider) {
223223
Service.UserDeleteWithCommentsMaxTime = sec.Key("USER_DELETE_WITH_COMMENTS_MAX_TIME").MustDuration(0)
224224
sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https")
225225
Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",")
226-
schemes := make([]string, len(Service.ValidSiteURLSchemes))
226+
schemes := make([]string, 0, len(Service.ValidSiteURLSchemes))
227227
for _, scheme := range Service.ValidSiteURLSchemes {
228228
scheme = strings.ToLower(strings.TrimSpace(scheme))
229229
if scheme != "" {

0 commit comments

Comments
 (0)