Skip to content

Commit 0788085

Browse files
authored
Merge branch 'main' into support-folder-open-state
2 parents ec3dcaf + d725b78 commit 0788085

Some content is hidden

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

52 files changed

+676
-425
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/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+
}

modules/indexer/issues/db/db.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package db
66
import (
77
"context"
88
"strings"
9+
"sync"
910

1011
"code.gitea.io/gitea/models/db"
1112
issue_model "code.gitea.io/gitea/models/issues"
@@ -18,7 +19,7 @@ import (
1819
"xorm.io/builder"
1920
)
2021

21-
var _ internal.Indexer = &Indexer{}
22+
var _ internal.Indexer = (*Indexer)(nil)
2223

2324
// Indexer implements Indexer interface to use database's like search
2425
type Indexer struct {
@@ -29,11 +30,9 @@ func (i *Indexer) SupportedSearchModes() []indexer.SearchMode {
2930
return indexer.SearchModesExactWords()
3031
}
3132

32-
func NewIndexer() *Indexer {
33-
return &Indexer{
34-
Indexer: &inner_db.Indexer{},
35-
}
36-
}
33+
var GetIndexer = sync.OnceValue(func() *Indexer {
34+
return &Indexer{Indexer: &inner_db.Indexer{}}
35+
})
3736

3837
// Index dummy function
3938
func (i *Indexer) Index(_ context.Context, _ ...*internal.IndexerData) error {
@@ -122,7 +121,11 @@ func (i *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
122121
}, nil
123122
}
124123

125-
ids, total, err := issue_model.IssueIDs(ctx, opt, cond)
124+
return i.FindWithIssueOptions(ctx, opt, cond)
125+
}
126+
127+
func (i *Indexer) FindWithIssueOptions(ctx context.Context, opt *issue_model.IssuesOptions, otherConds ...builder.Cond) (*internal.SearchResult, error) {
128+
ids, total, err := issue_model.IssueIDs(ctx, opt, otherConds...)
126129
if err != nil {
127130
return nil, err
128131
}

modules/indexer/issues/db/options.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package db
66
import (
77
"context"
88
"fmt"
9+
"strings"
910

1011
"code.gitea.io/gitea/models/db"
1112
issue_model "code.gitea.io/gitea/models/issues"
@@ -34,7 +35,11 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
3435
case internal.SortByDeadlineAsc:
3536
sortType = "nearduedate"
3637
default:
37-
sortType = "newest"
38+
if strings.HasPrefix(string(options.SortBy), issue_model.ScopeSortPrefix) {
39+
sortType = string(options.SortBy)
40+
} else {
41+
sortType = "newest"
42+
}
3843
}
3944

4045
// See the comment of issues_model.SearchOptions for the reason why we need to convert
@@ -68,7 +73,6 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
6873
ExcludedLabelNames: nil,
6974
IncludeMilestones: nil,
7075
SortType: sortType,
71-
IssueIDs: nil,
7276
UpdatedAfterUnix: options.UpdatedAfterUnix.Value(),
7377
UpdatedBeforeUnix: options.UpdatedBeforeUnix.Value(),
7478
PriorityRepoID: 0,

modules/indexer/issues/dboptions.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
package issues
55

66
import (
7+
"strings"
8+
79
"code.gitea.io/gitea/models/db"
810
issues_model "code.gitea.io/gitea/models/issues"
11+
"code.gitea.io/gitea/modules/indexer/issues/internal"
912
"code.gitea.io/gitea/modules/optional"
13+
"code.gitea.io/gitea/modules/setting"
1014
)
1115

1216
func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOptions {
17+
if opts.IssueIDs != nil {
18+
setting.PanicInDevOrTesting("Indexer SearchOptions doesn't support IssueIDs")
19+
}
1320
searchOpt := &SearchOptions{
1421
Keyword: keyword,
1522
RepoIDs: opts.RepoIDs,
@@ -95,7 +102,11 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
95102
// Unsupported sort type for search
96103
fallthrough
97104
default:
98-
searchOpt.SortBy = SortByUpdatedDesc
105+
if strings.HasPrefix(opts.SortType, issues_model.ScopeSortPrefix) {
106+
searchOpt.SortBy = internal.SortBy(opts.SortType)
107+
} else {
108+
searchOpt.SortBy = SortByUpdatedDesc
109+
}
99110
}
100111

101112
return searchOpt

0 commit comments

Comments
 (0)