Skip to content

Commit b241773

Browse files
authored
Merge branch 'main' into lunny/fix_doctor_bug
2 parents 675ba42 + 8a6df00 commit b241773

File tree

125 files changed

+2528
-1658
lines changed

Some content is hidden

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

125 files changed

+2528
-1658
lines changed

.github/workflows/release-nightly.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
aws s3 sync dist/release s3://${{ secrets.AWS_S3_BUCKET }}/gitea/${{ steps.clean_name.outputs.branch }} --no-progress
6060
nightly-docker-rootful:
6161
runs-on: namespace-profile-gitea-release-docker
62+
permissions:
63+
packages: write # to publish to ghcr.io
6264
steps:
6365
- uses: actions/checkout@v4
6466
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -85,6 +87,12 @@ jobs:
8587
with:
8688
username: ${{ secrets.DOCKERHUB_USERNAME }}
8789
password: ${{ secrets.DOCKERHUB_TOKEN }}
90+
- name: Login to GHCR using PAT
91+
uses: docker/login-action@v3
92+
with:
93+
registry: ghcr.io
94+
username: ${{ github.repository_owner }}
95+
password: ${{ secrets.GITHUB_TOKEN }}
8896
- name: fetch go modules
8997
run: make vendor
9098
- name: build rootful docker image
@@ -93,9 +101,13 @@ jobs:
93101
context: .
94102
platforms: linux/amd64,linux/arm64
95103
push: true
96-
tags: gitea/gitea:${{ steps.clean_name.outputs.branch }}
104+
tags: |-
105+
gitea/gitea:${{ steps.clean_name.outputs.branch }}
106+
ghcr.io/go-gitea/gitea:${{ steps.clean_name.outputs.branch }}
97107
nightly-docker-rootless:
98108
runs-on: namespace-profile-gitea-release-docker
109+
permissions:
110+
packages: write # to publish to ghcr.io
99111
steps:
100112
- uses: actions/checkout@v4
101113
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -122,6 +134,12 @@ jobs:
122134
with:
123135
username: ${{ secrets.DOCKERHUB_USERNAME }}
124136
password: ${{ secrets.DOCKERHUB_TOKEN }}
137+
- name: Login to GHCR using PAT
138+
uses: docker/login-action@v3
139+
with:
140+
registry: ghcr.io
141+
username: ${{ github.repository_owner }}
142+
password: ${{ secrets.GITHUB_TOKEN }}
125143
- name: fetch go modules
126144
run: make vendor
127145
- name: build rootless docker image
@@ -131,4 +149,6 @@ jobs:
131149
platforms: linux/amd64,linux/arm64
132150
push: true
133151
file: Dockerfile.rootless
134-
tags: gitea/gitea:${{ steps.clean_name.outputs.branch }}-rootless
152+
tags: |-
153+
gitea/gitea:${{ steps.clean_name.outputs.branch }}-rootless
154+
ghcr.io/go-gitea/gitea:${{ steps.clean_name.outputs.branch }}-rootless

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ jobs:
6969
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
7070
docker-rootful:
7171
runs-on: namespace-profile-gitea-release-docker
72+
permissions:
73+
packages: write # to publish to ghcr.io
7274
steps:
7375
- uses: actions/checkout@v4
7476
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -79,7 +81,9 @@ jobs:
7981
- uses: docker/metadata-action@v5
8082
id: meta
8183
with:
82-
images: gitea/gitea
84+
images: |-
85+
gitea/gitea
86+
ghcr.io/go-gitea/gitea
8387
flavor: |
8488
latest=false
8589
# 1.2.3-rc0
@@ -90,6 +94,12 @@ jobs:
9094
with:
9195
username: ${{ secrets.DOCKERHUB_USERNAME }}
9296
password: ${{ secrets.DOCKERHUB_TOKEN }}
97+
- name: Login to GHCR using PAT
98+
uses: docker/login-action@v3
99+
with:
100+
registry: ghcr.io
101+
username: ${{ github.repository_owner }}
102+
password: ${{ secrets.GITHUB_TOKEN }}
93103
- name: build rootful docker image
94104
uses: docker/build-push-action@v5
95105
with:
@@ -100,6 +110,8 @@ jobs:
100110
labels: ${{ steps.meta.outputs.labels }}
101111
docker-rootless:
102112
runs-on: namespace-profile-gitea-release-docker
113+
permissions:
114+
packages: write # to publish to ghcr.io
103115
steps:
104116
- uses: actions/checkout@v4
105117
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -110,7 +122,9 @@ jobs:
110122
- uses: docker/metadata-action@v5
111123
id: meta
112124
with:
113-
images: gitea/gitea
125+
images: |-
126+
gitea/gitea
127+
ghcr.io/go-gitea/gitea
114128
# each tag below will have the suffix of -rootless
115129
flavor: |
116130
latest=false
@@ -123,6 +137,12 @@ jobs:
123137
with:
124138
username: ${{ secrets.DOCKERHUB_USERNAME }}
125139
password: ${{ secrets.DOCKERHUB_TOKEN }}
140+
- name: Login to GHCR using PAT
141+
uses: docker/login-action@v3
142+
with:
143+
registry: ghcr.io
144+
username: ${{ github.repository_owner }}
145+
password: ${{ secrets.GITHUB_TOKEN }}
126146
- name: build rootless docker image
127147
uses: docker/build-push-action@v5
128148
with:

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ concurrency:
1414
jobs:
1515
binary:
1616
runs-on: namespace-profile-gitea-release-binary
17+
permissions:
18+
packages: write # to publish to ghcr.io
1719
steps:
1820
- uses: actions/checkout@v4
1921
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -71,6 +73,8 @@ jobs:
7173
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
7274
docker-rootful:
7375
runs-on: namespace-profile-gitea-release-docker
76+
permissions:
77+
packages: write # to publish to ghcr.io
7478
steps:
7579
- uses: actions/checkout@v4
7680
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -81,7 +85,9 @@ jobs:
8185
- uses: docker/metadata-action@v5
8286
id: meta
8387
with:
84-
images: gitea/gitea
88+
images: |-
89+
gitea/gitea
90+
ghcr.io/go-gitea/gitea
8591
# this will generate tags in the following format:
8692
# latest
8793
# 1
@@ -96,6 +102,12 @@ jobs:
96102
with:
97103
username: ${{ secrets.DOCKERHUB_USERNAME }}
98104
password: ${{ secrets.DOCKERHUB_TOKEN }}
105+
- name: Login to GHCR using PAT
106+
uses: docker/login-action@v3
107+
with:
108+
registry: ghcr.io
109+
username: ${{ github.repository_owner }}
110+
password: ${{ secrets.GITHUB_TOKEN }}
99111
- name: build rootful docker image
100112
uses: docker/build-push-action@v5
101113
with:
@@ -116,7 +128,9 @@ jobs:
116128
- uses: docker/metadata-action@v5
117129
id: meta
118130
with:
119-
images: gitea/gitea
131+
images: |-
132+
gitea/gitea
133+
ghcr.io/go-gitea/gitea
120134
# each tag below will have the suffix of -rootless
121135
flavor: |
122136
suffix=-rootless,onlatest=true
@@ -134,6 +148,12 @@ jobs:
134148
with:
135149
username: ${{ secrets.DOCKERHUB_USERNAME }}
136150
password: ${{ secrets.DOCKERHUB_TOKEN }}
151+
- name: Login to GHCR using PAT
152+
uses: docker/login-action@v3
153+
with:
154+
registry: ghcr.io
155+
username: ${{ github.repository_owner }}
156+
password: ${{ secrets.GITHUB_TOKEN }}
137157
- name: build rootless docker image
138158
uses: docker/build-push-action@v5
139159
with:

models/fixtures/webhook.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
-
22
id: 1
33
repo_id: 1
4-
url: www.example.com/url1
4+
url: https://www.example.com/url1
55
content_type: 1 # json
66
events: '{"push_only":true,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":false}}'
77
is_active: true
88

99
-
1010
id: 2
1111
repo_id: 1
12-
url: www.example.com/url2
12+
url: https://www.example.com/url2
1313
content_type: 1 # json
1414
events: '{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}'
1515
is_active: false
@@ -18,15 +18,15 @@
1818
id: 3
1919
owner_id: 3
2020
repo_id: 3
21-
url: www.example.com/url3
21+
url: https://www.example.com/url3
2222
content_type: 1 # json
2323
events: '{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}'
2424
is_active: true
2525

2626
-
2727
id: 4
2828
repo_id: 2
29-
url: www.example.com/url4
29+
url: https://www.example.com/url4
3030
content_type: 1 # json
3131
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
3232
is_active: true
@@ -35,7 +35,7 @@
3535
id: 5
3636
repo_id: 0
3737
owner_id: 0
38-
url: www.example.com/url5
38+
url: https://www.example.com/url5
3939
content_type: 1 # json
4040
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
4141
is_active: true
@@ -45,7 +45,7 @@
4545
id: 6
4646
repo_id: 0
4747
owner_id: 0
48-
url: www.example.com/url6
48+
url: https://www.example.com/url6
4949
content_type: 1 # json
5050
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
5151
is_active: true

models/issues/issue_search.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"xorm.io/xorm"
2222
)
2323

24+
const ScopeSortPrefix = "scope-"
25+
2426
// IssuesOptions represents options of an issue.
2527
type IssuesOptions struct { //nolint
2628
Paginator *db.ListOptions
@@ -70,6 +72,17 @@ func (o *IssuesOptions) Copy(edit ...func(options *IssuesOptions)) *IssuesOption
7072
// applySorts sort an issues-related session based on the provided
7173
// sortType string
7274
func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) {
75+
// Since this sortType is dynamically created, it has to be treated specially.
76+
if strings.HasPrefix(sortType, ScopeSortPrefix) {
77+
scope := strings.TrimPrefix(sortType, ScopeSortPrefix)
78+
sess.Join("LEFT", "issue_label", "issue.id = issue_label.issue_id")
79+
// "exclusive_order=0" means "no order is set", so exclude it from the JOIN criteria and then "LEFT JOIN" result is also null
80+
sess.Join("LEFT", "label", "label.id = issue_label.label_id AND label.exclusive_order <> 0 AND label.name LIKE ?", scope+"/%")
81+
// Use COALESCE to make sure we sort NULL last regardless of backend DB (2147483647 == max int)
82+
sess.OrderBy("COALESCE(label.exclusive_order, 2147483647) ASC").Desc("issue.id")
83+
return
84+
}
85+
7386
switch sortType {
7487
case "oldest":
7588
sess.Asc("issue.created_unix").Asc("issue.id")

models/issues/label.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type Label struct {
8787
OrgID int64 `xorm:"INDEX"`
8888
Name string
8989
Exclusive bool
90+
ExclusiveOrder int `xorm:"DEFAULT 0"` // 0 means no exclusive order
9091
Description string
9192
Color string `xorm:"VARCHAR(7)"`
9293
NumIssues int
@@ -236,7 +237,7 @@ func UpdateLabel(ctx context.Context, l *Label) error {
236237
}
237238
l.Color = color
238239

239-
return updateLabelCols(ctx, l, "name", "description", "color", "exclusive", "archived_unix")
240+
return updateLabelCols(ctx, l, "name", "description", "color", "exclusive", "exclusive_order", "archived_unix")
240241
}
241242

242243
// DeleteLabel delete a label

models/migrations/migrations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ func prepareMigrationTasks() []*migration {
380380
newMigration(316, "Add description for secrets and variables", v1_24.AddDescriptionForSecretsAndVariables),
381381
newMigration(317, "Add new index for action for heatmap", v1_24.AddNewIndexForUserDashboard),
382382
newMigration(318, "Add anonymous_access_mode for repo_unit", v1_24.AddRepoUnitAnonymousAccessMode),
383+
newMigration(319, "Add ExclusiveOrder to Label table", v1_24.AddExclusiveOrderColumnToLabelTable),
383384
}
384385
return preparedMigrations
385386
}

models/migrations/v1_24/v319.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_24 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
func AddExclusiveOrderColumnToLabelTable(x *xorm.Engine) error {
11+
type Label struct {
12+
ExclusiveOrder int `xorm:"DEFAULT 0"`
13+
}
14+
15+
return x.Sync(new(Label))
16+
}

models/packages/descriptor.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
repo_model "code.gitea.io/gitea/models/repo"
1313
user_model "code.gitea.io/gitea/models/user"
14+
"code.gitea.io/gitea/modules/cache"
1415
"code.gitea.io/gitea/modules/json"
1516
"code.gitea.io/gitea/modules/packages/alpine"
1617
"code.gitea.io/gitea/modules/packages/arch"
@@ -102,22 +103,26 @@ func (pd *PackageDescriptor) CalculateBlobSize() int64 {
102103

103104
// GetPackageDescriptor gets the package description for a version
104105
func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDescriptor, error) {
105-
p, err := GetPackageByID(ctx, pv.PackageID)
106+
return getPackageDescriptor(ctx, pv, cache.NewEphemeralCache())
107+
}
108+
109+
func getPackageDescriptor(ctx context.Context, pv *PackageVersion, c *cache.EphemeralCache) (*PackageDescriptor, error) {
110+
p, err := cache.GetWithEphemeralCache(ctx, c, "package", pv.PackageID, GetPackageByID)
106111
if err != nil {
107112
return nil, err
108113
}
109-
o, err := user_model.GetUserByID(ctx, p.OwnerID)
114+
o, err := cache.GetWithEphemeralCache(ctx, c, "user", p.OwnerID, user_model.GetUserByID)
110115
if err != nil {
111116
return nil, err
112117
}
113118
var repository *repo_model.Repository
114119
if p.RepoID > 0 {
115-
repository, err = repo_model.GetRepositoryByID(ctx, p.RepoID)
120+
repository, err = cache.GetWithEphemeralCache(ctx, c, "repo", p.RepoID, repo_model.GetRepositoryByID)
116121
if err != nil && !repo_model.IsErrRepoNotExist(err) {
117122
return nil, err
118123
}
119124
}
120-
creator, err := user_model.GetUserByID(ctx, pv.CreatorID)
125+
creator, err := cache.GetWithEphemeralCache(ctx, c, "user", pv.CreatorID, user_model.GetUserByID)
121126
if err != nil {
122127
if errors.Is(err, util.ErrNotExist) {
123128
creator = user_model.NewGhostUser()
@@ -145,9 +150,13 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc
145150
return nil, err
146151
}
147152

148-
pfds, err := GetPackageFileDescriptors(ctx, pfs)
149-
if err != nil {
150-
return nil, err
153+
pfds := make([]*PackageFileDescriptor, 0, len(pfs))
154+
for _, pf := range pfs {
155+
pfd, err := getPackageFileDescriptor(ctx, pf, c)
156+
if err != nil {
157+
return nil, err
158+
}
159+
pfds = append(pfds, pfd)
151160
}
152161

153162
var metadata any
@@ -221,7 +230,11 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc
221230

222231
// GetPackageFileDescriptor gets a package file descriptor for a package file
223232
func GetPackageFileDescriptor(ctx context.Context, pf *PackageFile) (*PackageFileDescriptor, error) {
224-
pb, err := GetBlobByID(ctx, pf.BlobID)
233+
return getPackageFileDescriptor(ctx, pf, cache.NewEphemeralCache())
234+
}
235+
236+
func getPackageFileDescriptor(ctx context.Context, pf *PackageFile, c *cache.EphemeralCache) (*PackageFileDescriptor, error) {
237+
pb, err := cache.GetWithEphemeralCache(ctx, c, "package_file_blob", pf.BlobID, GetBlobByID)
225238
if err != nil {
226239
return nil, err
227240
}
@@ -251,9 +264,13 @@ func GetPackageFileDescriptors(ctx context.Context, pfs []*PackageFile) ([]*Pack
251264

252265
// GetPackageDescriptors gets the package descriptions for the versions
253266
func GetPackageDescriptors(ctx context.Context, pvs []*PackageVersion) ([]*PackageDescriptor, error) {
267+
return getPackageDescriptors(ctx, pvs, cache.NewEphemeralCache())
268+
}
269+
270+
func getPackageDescriptors(ctx context.Context, pvs []*PackageVersion, c *cache.EphemeralCache) ([]*PackageDescriptor, error) {
254271
pds := make([]*PackageDescriptor, 0, len(pvs))
255272
for _, pv := range pvs {
256-
pd, err := GetPackageDescriptor(ctx, pv)
273+
pd, err := getPackageDescriptor(ctx, pv, c)
257274
if err != nil {
258275
return nil, err
259276
}

0 commit comments

Comments
 (0)