Skip to content

Commit 6e5bcec

Browse files
authored
Merge branch 'main' into fix-project-icons
2 parents 809e24e + 0206882 commit 6e5bcec

File tree

88 files changed

+1280
-8291
lines changed

Some content is hidden

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

88 files changed

+1280
-8291
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ steps:
726726

727727
# TODO: We should probably build all dependencies into a test image
728728
- name: test-e2e
729-
image: mcr.microsoft.com/playwright:v1.29.2-focal
729+
image: mcr.microsoft.com/playwright:v1.31.2-focal
730730
commands:
731731
- curl -sLO https://go.dev/dl/go1.20.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz
732732
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ fund=false
33
update-notifier=false
44
package-lock=true
55
save-exact=true
6+
lockfile-version=3

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fmt:
273273

274274
.PHONY: fmt-check
275275
fmt-check: fmt
276-
@diff=$$(git diff $(GO_SOURCES) templates $(WEB_DIRS)); \
276+
@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
277277
if [ -n "$$diff" ]; then \
278278
echo "Please run 'make fmt' and commit the result:"; \
279279
echo "$${diff}"; \
@@ -309,7 +309,7 @@ $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
309309

310310
.PHONY: swagger-check
311311
swagger-check: generate-swagger
312-
@diff=$$(git diff '$(SWAGGER_SPEC)'); \
312+
@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
313313
if [ -n "$$diff" ]; then \
314314
echo "Please run 'make generate-swagger' and commit the result:"; \
315315
echo "$${diff}"; \
@@ -414,7 +414,7 @@ vendor: go.mod go.sum
414414

415415
.PHONY: tidy-check
416416
tidy-check: tidy
417-
@diff=$$(git diff go.mod go.sum $(GO_LICENSE_FILE)); \
417+
@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
418418
if [ -n "$$diff" ]; then \
419419
echo "Please run 'make tidy' and commit the result:"; \
420420
echo "$${diff}"; \
@@ -885,7 +885,7 @@ svg: node-check | node_modules
885885
.PHONY: svg-check
886886
svg-check: svg
887887
@git add $(SVG_DEST_DIR)
888-
@diff=$$(git diff --cached $(SVG_DEST_DIR)); \
888+
@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
889889
if [ -n "$$diff" ]; then \
890890
echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
891891
echo "$${diff}"; \
@@ -895,7 +895,7 @@ svg-check: svg
895895
.PHONY: lockfile-check
896896
lockfile-check:
897897
npm install --package-lock-only
898-
@diff=$$(git diff package-lock.json); \
898+
@diff=$$(git diff --color=always package-lock.json); \
899899
if [ -n "$$diff" ]; then \
900900
echo "package-lock.json is inconsistent with package.json"; \
901901
echo "Please run 'npm install --package-lock-only' and commit the result:"; \

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ var migrations = []Migration{
471471
NewMigration("Rename Webhook org_id to owner_id", v1_20.RenameWebhookOrgToOwner),
472472
// v246 -> v247
473473
NewMigration("Add missed column owner_id for project table", v1_20.AddNewColumnForProject),
474+
// v247 -> v248
475+
NewMigration("Fix incorrect project type", v1_20.FixIncorrectProjectType),
474476
}
475477

476478
// GetCurrentDBVersion returns the current db version

models/migrations/v1_20/v247.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_20 //nolint
5+
6+
import (
7+
"code.gitea.io/gitea/modules/log"
8+
9+
"xorm.io/xorm"
10+
)
11+
12+
// FixIncorrectProjectType: set individual project's type from 3(TypeOrganization) to 1(TypeIndividual)
13+
func FixIncorrectProjectType(x *xorm.Engine) error {
14+
type User struct {
15+
ID int64 `xorm:"pk autoincr"`
16+
Type int
17+
}
18+
19+
const (
20+
UserTypeIndividual int = 0
21+
22+
TypeIndividual uint8 = 1
23+
TypeOrganization uint8 = 3
24+
)
25+
26+
type Project struct {
27+
OwnerID int64 `xorm:"INDEX"`
28+
Type uint8
29+
Owner *User `xorm:"extends"`
30+
}
31+
32+
sess := x.NewSession()
33+
defer sess.Close()
34+
35+
if err := sess.Begin(); err != nil {
36+
return err
37+
}
38+
39+
count, err := sess.Table("project").
40+
Where("type = ? AND owner_id IN (SELECT id FROM `user` WHERE type = ?)", TypeOrganization, UserTypeIndividual).
41+
Update(&Project{
42+
Type: TypeIndividual,
43+
})
44+
if err != nil {
45+
return err
46+
}
47+
log.Debug("Updated %d projects to belong to a user instead of an organization", count)
48+
49+
return sess.Commit()
50+
}

models/project/project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func GetCardConfig() []CardConfig {
183183
// IsTypeValid checks if a project type is valid
184184
func IsTypeValid(p Type) bool {
185185
switch p {
186-
case TypeRepository, TypeOrganization:
186+
case TypeIndividual, TypeRepository, TypeOrganization:
187187
return true
188188
default:
189189
return false

models/project/project_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestIsProjectTypeValid(t *testing.T) {
2020
typ Type
2121
valid bool
2222
}{
23-
{TypeIndividual, false},
23+
{TypeIndividual, true},
2424
{TypeRepository, true},
2525
{TypeOrganization, true},
2626
{UnknownType, false},

modules/packages/npm/creator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func ParsePackage(r io.Reader) (*Package, error) {
223223
OptionalDependencies: meta.OptionalDependencies,
224224
Bin: meta.Bin,
225225
Readme: meta.Readme,
226+
Repository: meta.Repository,
226227
},
227228
}
228229

modules/packages/npm/creator_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ func TestParsePackage(t *testing.T) {
2626
packageDescription := "Test Description"
2727
data := "H4sIAAAAAAAA/ytITM5OTE/VL4DQelnF+XkMVAYGBgZmJiYK2MRBwNDcSIHB2NTMwNDQzMwAqA7IMDUxA9LUdgg2UFpcklgEdAql5kD8ogCnhwio5lJQUMpLzE1VslJQcihOzi9I1S9JLS7RhSYIJR2QgrLUouLM/DyQGkM9Az1D3YIiqExKanFyUWZBCVQ2BKhVwQVJDKwosbQkI78IJO/tZ+LsbRykxFXLNdA+HwWjYBSMgpENACgAbtAACAAA"
2828
integrity := "sha512-yA4FJsVhetynGfOC1jFf79BuS+jrHbm0fhh+aHzCQkOaOBXKf9oBnC4a6DnLLnEsHQDRLYd00cwj8sCXpC+wIg=="
29+
repository := Repository{
30+
Type: "gitea",
31+
URL: "http://localhost:3000/gitea/test.git",
32+
}
2933

3034
t.Run("InvalidUpload", func(t *testing.T) {
3135
p, err := ParsePackage(bytes.NewReader([]byte{0}))
@@ -242,6 +246,7 @@ func TestParsePackage(t *testing.T) {
242246
Dist: PackageDistribution{
243247
Integrity: integrity,
244248
},
249+
Repository: repository,
245250
},
246251
},
247252
},
@@ -272,5 +277,7 @@ func TestParsePackage(t *testing.T) {
272277
assert.Equal(t, "https://gitea.io/", p.Metadata.ProjectURL)
273278
assert.Contains(t, p.Metadata.Dependencies, "package")
274279
assert.Equal(t, "1.2.0", p.Metadata.Dependencies["package"])
280+
assert.Equal(t, repository.Type, p.Metadata.Repository.Type)
281+
assert.Equal(t, repository.URL, p.Metadata.Repository.URL)
275282
})
276283
}

modules/packages/npm/metadata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ type Metadata struct {
2121
OptionalDependencies map[string]string `json:"optional_dependencies,omitempty"`
2222
Bin map[string]string `json:"bin,omitempty"`
2323
Readme string `json:"readme,omitempty"`
24+
Repository Repository `json:"repository,omitempty"`
2425
}

0 commit comments

Comments
 (0)