Skip to content

Commit 2b169b9

Browse files
authored
Merge branch 'main' into lunny/remove_wiki_path_ref
2 parents 5b43cff + f04b9aa commit 2b169b9

Some content is hidden

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

71 files changed

+1408
-1213
lines changed

.github/workflows/pull-compliance.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ jobs:
3535
- uses: astral-sh/setup-uv@v6
3636
- run: uv python install 3.12
3737
- uses: pnpm/action-setup@v4
38-
- uses: actions/setup-node@v4
38+
- uses: actions/setup-node@v5
3939
with:
4040
node-version: 24
41-
cache: pnpm
42-
cache-dependency-path: pnpm-lock.yaml
4341
- run: make deps-py
4442
- run: make deps-frontend
4543
- run: make lint-templates
@@ -62,11 +60,9 @@ jobs:
6260
steps:
6361
- uses: actions/checkout@v4
6462
- uses: pnpm/action-setup@v4
65-
- uses: actions/setup-node@v4
63+
- uses: actions/setup-node@v5
6664
with:
6765
node-version: 24
68-
cache: pnpm
69-
cache-dependency-path: pnpm-lock.yaml
7066
- run: make deps-frontend
7167
- run: make lint-swagger
7268

@@ -134,11 +130,9 @@ jobs:
134130
steps:
135131
- uses: actions/checkout@v4
136132
- uses: pnpm/action-setup@v4
137-
- uses: actions/setup-node@v4
133+
- uses: actions/setup-node@v5
138134
with:
139135
node-version: 24
140-
cache: pnpm
141-
cache-dependency-path: pnpm-lock.yaml
142136
- run: make deps-frontend
143137
- run: make lint-frontend
144138
- run: make checks-frontend
@@ -184,11 +178,9 @@ jobs:
184178
steps:
185179
- uses: actions/checkout@v4
186180
- uses: pnpm/action-setup@v4
187-
- uses: actions/setup-node@v4
181+
- uses: actions/setup-node@v5
188182
with:
189183
node-version: 24
190-
cache: pnpm
191-
cache-dependency-path: pnpm-lock.yaml
192184
- run: make deps-frontend
193185
- run: make lint-md
194186

.github/workflows/pull-e2e-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ jobs:
2424
go-version-file: go.mod
2525
check-latest: true
2626
- uses: pnpm/action-setup@v4
27-
- uses: actions/setup-node@v4
27+
- uses: actions/setup-node@v5
2828
with:
2929
node-version: 24
30-
cache: pnpm
31-
cache-dependency-path: pnpm-lock.yaml
3230
- run: make deps-frontend frontend deps-backend
3331
- run: pnpm exec playwright install --with-deps
3432
- run: make test-e2e-sqlite

.github/workflows/release-nightly.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ jobs:
2121
go-version-file: go.mod
2222
check-latest: true
2323
- uses: pnpm/action-setup@v4
24-
- uses: actions/setup-node@v4
24+
- uses: actions/setup-node@v5
2525
with:
2626
node-version: 24
27-
cache: pnpm
28-
cache-dependency-path: pnpm-lock.yaml
2927
- run: make deps-frontend deps-backend
3028
# xgo build
3129
- run: make release

.github/workflows/release-tag-rc.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ jobs:
2222
go-version-file: go.mod
2323
check-latest: true
2424
- uses: pnpm/action-setup@v4
25-
- uses: actions/setup-node@v4
25+
- uses: actions/setup-node@v5
2626
with:
2727
node-version: 24
28-
cache: pnpm
29-
cache-dependency-path: pnpm-lock.yaml
3028
- run: make deps-frontend deps-backend
3129
# xgo build
3230
- run: make release

.github/workflows/release-tag-version.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ jobs:
2626
go-version-file: go.mod
2727
check-latest: true
2828
- uses: pnpm/action-setup@v4
29-
- uses: actions/setup-node@v4
29+
- uses: actions/setup-node@v5
3030
with:
3131
node-version: 24
32-
cache: pnpm
33-
cache-dependency-path: pnpm-lock.yaml
3432
- run: make deps-frontend deps-backend
3533
# xgo build
3634
- run: make release

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ XGO_VERSION := go-1.25.x
2727

2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
30-
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8.0
30+
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.9.1
3131
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/[email protected]
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]

build/code-batch-process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func parseArgs() (mainOptions map[string]string, subCmd string, subArgs []string
181181
break
182182
}
183183
}
184-
return
184+
return mainOptions, subCmd, subArgs
185185
}
186186

187187
func showUsage() {

cmd/serv.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ func runServ(ctx context.Context, c *cli.Command) error {
229229
username := repoPathFields[0]
230230
reponame := strings.TrimSuffix(repoPathFields[1], ".git") // “the-repo-name" or "the-repo-name.wiki"
231231

232-
// LowerCase and trim the repoPath as that's how they are stored.
233-
// This should be done after splitting the repoPath into username and reponame
234-
// so that username and reponame are not affected.
235-
repoPath = strings.ToLower(strings.TrimSpace(repoPath))
236-
237232
if !repo.IsValidSSHAccessRepoName(reponame) {
238233
return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame)
239234
}
@@ -280,6 +275,11 @@ func runServ(ctx context.Context, c *cli.Command) error {
280275
return fail(ctx, extra.UserMsg, "ServCommand failed: %s", extra.Error)
281276
}
282277

278+
// LowerCase and trim the repoPath as that's how they are stored.
279+
// This should be done after splitting the repoPath into username and reponame
280+
// so that username and reponame are not affected.
281+
repoPath = strings.ToLower(results.OwnerName + "/" + results.RepoName + ".git")
282+
283283
// LFS SSH protocol
284284
if verb == git.CmdVerbLfsTransfer {
285285
token, err := getLFSAuthToken(ctx, lfsVerb, results)

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ require (
287287
gopkg.in/yaml.v2 v2.4.0 // indirect
288288
)
289289

290+
ignore (
291+
./.venv
292+
./node_modules
293+
)
294+
290295
replace github.com/jaytaylor/html2text => github.com/Necoro/html2text v0.0.0-20250804200300-7bf1ce1c7347
291296

292297
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1

models/asymkey/gpg_key_add.go

Lines changed: 71 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -72,96 +72,90 @@ func AddGPGKey(ctx context.Context, ownerID int64, content, token, signature str
7272
return nil, err
7373
}
7474

75-
ctx, committer, err := db.TxContext(ctx)
76-
if err != nil {
77-
return nil, err
78-
}
79-
defer committer.Close()
80-
81-
keys := make([]*GPGKey, 0, len(ekeys))
82-
83-
verified := false
84-
// Handle provided signature
85-
if signature != "" {
86-
signer, err := openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token), strings.NewReader(signature), nil)
87-
if err != nil {
88-
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\n"), strings.NewReader(signature), nil)
89-
}
90-
if err != nil {
91-
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature), nil)
92-
}
93-
if err != nil {
94-
log.Debug("AddGPGKey CheckArmoredDetachedSignature failed: %v", err)
95-
return nil, ErrGPGInvalidTokenSignature{
96-
ID: ekeys[0].PrimaryKey.KeyIdString(),
97-
Wrapped: err,
75+
return db.WithTx2(ctx, func(ctx context.Context) ([]*GPGKey, error) {
76+
keys := make([]*GPGKey, 0, len(ekeys))
77+
78+
verified := false
79+
// Handle provided signature
80+
if signature != "" {
81+
signer, err := openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token), strings.NewReader(signature), nil)
82+
if err != nil {
83+
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\n"), strings.NewReader(signature), nil)
9884
}
85+
if err != nil {
86+
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature), nil)
87+
}
88+
if err != nil {
89+
log.Debug("AddGPGKey CheckArmoredDetachedSignature failed: %v", err)
90+
return nil, ErrGPGInvalidTokenSignature{
91+
ID: ekeys[0].PrimaryKey.KeyIdString(),
92+
Wrapped: err,
93+
}
94+
}
95+
ekeys = []*openpgp.Entity{signer}
96+
verified = true
9997
}
100-
ekeys = []*openpgp.Entity{signer}
101-
verified = true
102-
}
103-
104-
if len(ekeys) > 1 {
105-
id2key := map[string]*openpgp.Entity{}
106-
newEKeys := make([]*openpgp.Entity, 0, len(ekeys))
107-
for _, ekey := range ekeys {
108-
id := ekey.PrimaryKey.KeyIdString()
109-
if original, has := id2key[id]; has {
110-
// Coalesce this with the other one
111-
for _, subkey := range ekey.Subkeys {
112-
if subkey.PublicKey == nil {
113-
continue
114-
}
115-
found := false
11698

117-
for _, originalSubkey := range original.Subkeys {
118-
if originalSubkey.PublicKey == nil {
99+
if len(ekeys) > 1 {
100+
id2key := map[string]*openpgp.Entity{}
101+
newEKeys := make([]*openpgp.Entity, 0, len(ekeys))
102+
for _, ekey := range ekeys {
103+
id := ekey.PrimaryKey.KeyIdString()
104+
if original, has := id2key[id]; has {
105+
// Coalesce this with the other one
106+
for _, subkey := range ekey.Subkeys {
107+
if subkey.PublicKey == nil {
119108
continue
120109
}
121-
if originalSubkey.PublicKey.KeyId == subkey.PublicKey.KeyId {
122-
found = true
123-
break
110+
found := false
111+
112+
for _, originalSubkey := range original.Subkeys {
113+
if originalSubkey.PublicKey == nil {
114+
continue
115+
}
116+
if originalSubkey.PublicKey.KeyId == subkey.PublicKey.KeyId {
117+
found = true
118+
break
119+
}
120+
}
121+
if !found {
122+
original.Subkeys = append(original.Subkeys, subkey)
124123
}
125124
}
126-
if !found {
127-
original.Subkeys = append(original.Subkeys, subkey)
128-
}
129-
}
130-
for name, identity := range ekey.Identities {
131-
if _, has := original.Identities[name]; has {
132-
continue
125+
for name, identity := range ekey.Identities {
126+
if _, has := original.Identities[name]; has {
127+
continue
128+
}
129+
original.Identities[name] = identity
133130
}
134-
original.Identities[name] = identity
131+
continue
135132
}
136-
continue
133+
id2key[id] = ekey
134+
newEKeys = append(newEKeys, ekey)
137135
}
138-
id2key[id] = ekey
139-
newEKeys = append(newEKeys, ekey)
140-
}
141-
ekeys = newEKeys
142-
}
143-
144-
for _, ekey := range ekeys {
145-
// Key ID cannot be duplicated.
146-
has, err := db.GetEngine(ctx).Where("key_id=?", ekey.PrimaryKey.KeyIdString()).
147-
Get(new(GPGKey))
148-
if err != nil {
149-
return nil, err
150-
} else if has {
151-
return nil, ErrGPGKeyIDAlreadyUsed{ekey.PrimaryKey.KeyIdString()}
136+
ekeys = newEKeys
152137
}
153138

154-
// Get DB session
139+
for _, ekey := range ekeys {
140+
// Key ID cannot be duplicated.
141+
has, err := db.GetEngine(ctx).Where("key_id=?", ekey.PrimaryKey.KeyIdString()).
142+
Get(new(GPGKey))
143+
if err != nil {
144+
return nil, err
145+
} else if has {
146+
return nil, ErrGPGKeyIDAlreadyUsed{ekey.PrimaryKey.KeyIdString()}
147+
}
155148

156-
key, err := parseGPGKey(ctx, ownerID, ekey, verified)
157-
if err != nil {
158-
return nil, err
159-
}
149+
key, err := parseGPGKey(ctx, ownerID, ekey, verified)
150+
if err != nil {
151+
return nil, err
152+
}
160153

161-
if err = addGPGKey(ctx, key, content); err != nil {
162-
return nil, err
154+
if err = addGPGKey(ctx, key, content); err != nil {
155+
return nil, err
156+
}
157+
keys = append(keys, key)
163158
}
164-
keys = append(keys, key)
165-
}
166-
return keys, committer.Commit()
159+
return keys, nil
160+
})
167161
}

0 commit comments

Comments
 (0)