Skip to content

Commit f38464a

Browse files
authored
Merge branch 'main' into lunny/move_db_tx
2 parents 312ba91 + 87362b4 commit f38464a

File tree

19 files changed

+1540
-1899
lines changed

19 files changed

+1540
-1899
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@ module.exports = {
831831
'sonarjs/no-inverted-boolean-check': [2],
832832
'sonarjs/no-nested-switch': [0],
833833
'sonarjs/no-nested-template-literals': [0],
834-
'sonarjs/no-one-iteration-loop': [2],
835834
'sonarjs/no-redundant-boolean': [2],
836835
'sonarjs/no-redundant-jump': [2],
837836
'sonarjs/no-same-line-conditional': [2],

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ RUN apk --no-cache add \
1818
&& npm install -g pnpm@10 \
1919
&& rm -rf /var/cache/apk/*
2020

21-
# workaround for node >= 22.18.0 on alpine 3.22. Remove when upgrading to alpine 3.23
22-
COPY --from=docker.io/node:22-alpine3.22 /usr/local/bin/node /usr/local/bin/node
23-
2421
# Setup repo
2522
COPY . ${GOPATH}/src/code.gitea.io/gitea
2623
WORKDIR ${GOPATH}/src/code.gitea.io/gitea

Dockerfile.rootless

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ RUN apk --no-cache add \
1818
&& npm install -g pnpm@10 \
1919
&& rm -rf /var/cache/apk/*
2020

21-
# workaround for node >= 22.18.0 on alpine 3.22. Remove when upgrading to alpine 3.23
22-
COPY --from=docker.io/node:22-alpine3.22 /usr/local/bin/node /usr/local/bin/node
23-
2421
# Setup repo
2522
COPY . ${GOPATH}/src/code.gitea.io/gitea
2623
WORKDIR ${GOPATH}/src/code.gitea.io/gitea

Makefile

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ STORED_VERSION_FILE := VERSION
9696
GITHUB_REF_TYPE ?= branch
9797
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
9898

99+
# Enable typescript support in Node.js before 22.18
100+
# TODO: Remove this once we can raise the minimum Node.js version to 22.18 (alpine >= 3.23)
101+
NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v 2>/dev/null | cut -c2- | tr '.' ' '))
102+
ifeq ($(shell test "$(NODE_VERSION)" -lt "022018000"; echo $$?),0)
103+
NODE_VARS := NODE_OPTIONS="--experimental-strip-types"
104+
else
105+
NODE_VARS :=
106+
endif
107+
99108
ifneq ($(GITHUB_REF_TYPE),branch)
100109
VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
101110
GITEA_VERSION ?= $(VERSION)
@@ -217,7 +226,6 @@ git-check:
217226
node-check:
218227
$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p'))
219228
$(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')))
220-
$(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
221229
$(eval PNPM_MISSING := $(shell hash pnpm > /dev/null 2>&1 || echo 1))
222230
@if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" ]; then \
223231
echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater to build. You can get it at https://nodejs.org/en/download/"; \
@@ -338,29 +346,29 @@ lint-backend-fix: lint-go-fix lint-go-gitea-vet lint-editorconfig ## lint backen
338346

339347
.PHONY: lint-js
340348
lint-js: node_modules ## lint js files
341-
pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES)
342-
pnpm exec vue-tsc
349+
$(NODE_VARS) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES)
350+
$(NODE_VARS) pnpm exec vue-tsc
343351

344352
.PHONY: lint-js-fix
345353
lint-js-fix: node_modules ## lint js files and fix issues
346-
pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix
347-
pnpm exec vue-tsc
354+
$(NODE_VARS) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix
355+
$(NODE_VARS) pnpm exec vue-tsc
348356

349357
.PHONY: lint-css
350358
lint-css: node_modules ## lint css files
351-
pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES)
359+
$(NODE_VARS) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES)
352360

353361
.PHONY: lint-css-fix
354362
lint-css-fix: node_modules ## lint css files and fix issues
355-
pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix
363+
$(NODE_VARS) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix
356364

357365
.PHONY: lint-swagger
358366
lint-swagger: node_modules ## lint swagger files
359-
pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC)
367+
$(NODE_VARS) pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC)
360368

361369
.PHONY: lint-md
362370
lint-md: node_modules ## lint markdown files
363-
pnpm exec markdownlint *.md
371+
$(NODE_VARS) pnpm exec markdownlint *.md
364372

365373
.PHONY: lint-spell
366374
lint-spell: ## lint spelling
@@ -421,7 +429,7 @@ watch: ## watch everything and continuously rebuild
421429
.PHONY: watch-frontend
422430
watch-frontend: node-check node_modules ## watch frontend files and continuously rebuild
423431
@rm -rf $(WEBPACK_DEST_ENTRIES)
424-
NODE_ENV=development pnpm exec webpack --watch --progress --disable-interpret
432+
NODE_ENV=development $(NODE_VARS) pnpm exec webpack --watch --progress --disable-interpret
425433

426434
.PHONY: watch-backend
427435
watch-backend: go-check ## watch backend files and continuously rebuild
@@ -437,7 +445,7 @@ test-backend: ## test backend files
437445

438446
.PHONY: test-frontend
439447
test-frontend: node_modules ## test frontend files
440-
pnpm exec vitest
448+
$(NODE_VARS) pnpm exec vitest
441449

442450
.PHONY: test-check
443451
test-check:
@@ -580,7 +588,7 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
580588

581589
.PHONY: playwright
582590
playwright: deps-frontend
583-
pnpm exec playwright install $(PLAYWRIGHT_FLAGS)
591+
$(NODE_VARS) pnpm exec playwright install $(PLAYWRIGHT_FLAGS)
584592

585593
.PHONY: test-e2e%
586594
test-e2e%: TEST_TYPE ?= e2e
@@ -844,7 +852,7 @@ deps-tools: ## install tool dependencies
844852
wait
845853

846854
node_modules: pnpm-lock.yaml
847-
pnpm install --frozen-lockfile
855+
$(NODE_VARS) pnpm install --frozen-lockfile
848856
@touch node_modules
849857

850858
.venv: uv.lock
@@ -856,16 +864,16 @@ update: update-js update-py ## update js and py dependencies
856864

857865
.PHONY: update-js
858866
update-js: node-check | node_modules ## update js dependencies
859-
pnpm exec updates -u -f package.json
867+
$(NODE_VARS) pnpm exec updates -u -f package.json
860868
rm -rf node_modules pnpm-lock.yaml
861-
pnpm install
862-
pnpm exec nolyfill install
863-
pnpm install
869+
$(NODE_VARS) pnpm install
870+
$(NODE_VARS) pnpm exec nolyfill install
871+
$(NODE_VARS) pnpm install
864872
@touch node_modules
865873

866874
.PHONY: update-py
867875
update-py: node-check | node_modules ## update py dependencies
868-
pnpm exec updates -u -f pyproject.toml
876+
$(NODE_VARS) pnpm exec updates -u -f pyproject.toml
869877
rm -rf .venv uv.lock
870878
uv sync
871879
@touch .venv
@@ -877,7 +885,7 @@ $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
877885
@$(MAKE) -s node-check node_modules
878886
@rm -rf $(WEBPACK_DEST_ENTRIES)
879887
@echo "Running webpack..."
880-
@BROWSERSLIST_IGNORE_OLD_DATA=true pnpm exec webpack --disable-interpret
888+
@BROWSERSLIST_IGNORE_OLD_DATA=true $(NODE_VARS) pnpm exec webpack --disable-interpret
881889
@touch $(WEBPACK_DEST)
882890

883891
.PHONY: svg
@@ -897,7 +905,7 @@ svg-check: svg
897905

898906
.PHONY: lockfile-check
899907
lockfile-check:
900-
pnpm install --frozen-lockfile
908+
$(NODE_VARS) pnpm install --frozen-lockfile
901909
@diff=$$(git diff --color=always pnpm-lock.yaml); \
902910
if [ -n "$$diff" ]; then \
903911
echo "pnpm-lock.yaml is inconsistent with package.json"; \

modules/packages/swift/metadata.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type ProgrammingLanguage struct {
8282
// https://schema.org/Person
8383
type Person struct {
8484
Type string `json:"@type,omitempty"`
85+
Name string `json:"name,omitempty"` // inherited from https://schema.org/Thing
8586
GivenName string `json:"givenName,omitempty"`
8687
MiddleName string `json:"middleName,omitempty"`
8788
FamilyName string `json:"familyName,omitempty"`
@@ -184,11 +185,17 @@ func ParsePackage(sr io.ReaderAt, size int64, mr io.Reader) (*Package, error) {
184185
p.Metadata.Description = ssc.Description
185186
p.Metadata.Keywords = ssc.Keywords
186187
p.Metadata.License = ssc.License
187-
p.Metadata.Author = Person{
188+
author := Person{
189+
Name: ssc.Author.Name,
188190
GivenName: ssc.Author.GivenName,
189191
MiddleName: ssc.Author.MiddleName,
190192
FamilyName: ssc.Author.FamilyName,
191193
}
194+
// If Name is not provided, generate it from individual name components
195+
if author.Name == "" {
196+
author.Name = author.String()
197+
}
198+
p.Metadata.Author = author
192199

193200
p.Metadata.RepositoryURL = ssc.CodeRepository
194201
if !validation.IsValidURL(p.Metadata.RepositoryURL) {

modules/packages/swift/metadata_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,49 @@ func TestParsePackage(t *testing.T) {
9797
assert.Equal(t, packageDescription, p.Metadata.Description)
9898
assert.ElementsMatch(t, []string{"swift", "package"}, p.Metadata.Keywords)
9999
assert.Equal(t, packageLicense, p.Metadata.License)
100+
assert.Equal(t, packageAuthor, p.Metadata.Author.Name)
100101
assert.Equal(t, packageAuthor, p.Metadata.Author.GivenName)
101102
assert.Equal(t, packageRepositoryURL, p.Metadata.RepositoryURL)
102103
assert.ElementsMatch(t, []string{packageRepositoryURL}, p.RepositoryURLs)
103104
})
105+
106+
t.Run("WithExplicitNameField", func(t *testing.T) {
107+
data := createArchive(map[string][]byte{
108+
"Package.swift": []byte("// swift-tools-version:5.7\n//\n// Package.swift"),
109+
})
110+
111+
authorName := "John Doe"
112+
p, err := ParsePackage(
113+
data,
114+
data.Size(),
115+
strings.NewReader(`{"name":"`+packageName+`","version":"`+packageVersion+`","description":"`+packageDescription+`","author":{"name":"`+authorName+`","givenName":"John","familyName":"Doe"}}`),
116+
)
117+
assert.NotNil(t, p)
118+
assert.NoError(t, err)
119+
120+
assert.Equal(t, authorName, p.Metadata.Author.Name)
121+
assert.Equal(t, "John", p.Metadata.Author.GivenName)
122+
assert.Equal(t, "Doe", p.Metadata.Author.FamilyName)
123+
})
124+
125+
t.Run("NameFieldGeneration", func(t *testing.T) {
126+
data := createArchive(map[string][]byte{
127+
"Package.swift": []byte("// swift-tools-version:5.7\n//\n// Package.swift"),
128+
})
129+
130+
// Test with only individual name components - Name should be auto-generated
131+
p, err := ParsePackage(
132+
data,
133+
data.Size(),
134+
strings.NewReader(`{"author":{"givenName":"John","middleName":"Q","familyName":"Doe"}}`),
135+
)
136+
assert.NotNil(t, p)
137+
assert.NoError(t, err)
138+
assert.Equal(t, "John Q Doe", p.Metadata.Author.Name)
139+
assert.Equal(t, "John", p.Metadata.Author.GivenName)
140+
assert.Equal(t, "Q", p.Metadata.Author.MiddleName)
141+
assert.Equal(t, "Doe", p.Metadata.Author.FamilyName)
142+
})
104143
}
105144

106145
func TestTrimmedVersionString(t *testing.T) {
@@ -142,3 +181,43 @@ func TestTrimmedVersionString(t *testing.T) {
142181
assert.Equal(t, c.Expected, TrimmedVersionString(c.Version))
143182
}
144183
}
184+
185+
func TestPersonNameString(t *testing.T) {
186+
cases := []struct {
187+
Name string
188+
Person Person
189+
Expected string
190+
}{
191+
{
192+
Name: "GivenNameOnly",
193+
Person: Person{GivenName: "John"},
194+
Expected: "John",
195+
},
196+
{
197+
Name: "GivenAndFamily",
198+
Person: Person{GivenName: "John", FamilyName: "Doe"},
199+
Expected: "John Doe",
200+
},
201+
{
202+
Name: "FullName",
203+
Person: Person{GivenName: "John", MiddleName: "Q", FamilyName: "Doe"},
204+
Expected: "John Q Doe",
205+
},
206+
{
207+
Name: "MiddleAndFamily",
208+
Person: Person{MiddleName: "Q", FamilyName: "Doe"},
209+
Expected: "Q Doe",
210+
},
211+
{
212+
Name: "Empty",
213+
Person: Person{},
214+
Expected: "",
215+
},
216+
}
217+
218+
for _, c := range cases {
219+
t.Run(c.Name, func(t *testing.T) {
220+
assert.Equal(t, c.Expected, c.Person.String())
221+
})
222+
}
223+
}

0 commit comments

Comments
 (0)