Skip to content

Commit 71a2a67

Browse files
committed
Merge branch 'main' into any-assignee
# Conflicts: # modules/indexer/issues/bleve/bleve.go
2 parents c71409c + 39fc2e7 commit 71a2a67

File tree

226 files changed

+3463
-2164
lines changed

Some content is hidden

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

226 files changed

+3463
-2164
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Gitea DevContainer",
3-
"image": "mcr.microsoft.com/devcontainers/go:1.23-bookworm",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.24-bookworm",
44
"features": {
55
// installs nodejs into container
66
"ghcr.io/devcontainers/features/node:1": {

.eslintrc.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104
'@vitest/no-disabled-tests': [0],
105105
'@vitest/no-done-callback': [0],
106106
'@vitest/no-duplicate-hooks': [0],
107-
'@vitest/no-focused-tests': [0],
107+
'@vitest/no-focused-tests': [2],
108108
'@vitest/no-hooks': [0],
109109
'@vitest/no-identical-title': [2],
110110
'@vitest/no-interpolation-in-snapshots': [0],
@@ -155,7 +155,7 @@ module.exports = {
155155
'eslint-plugin-vue-scoped-css',
156156
],
157157
extends: [
158-
'plugin:vue/vue3-recommended',
158+
'plugin:vue/recommended',
159159
'plugin:vue-scoped-css/vue3-recommended',
160160
],
161161
rules: {

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ COMMA := ,
2626
XGO_VERSION := go-1.24.x
2727

2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
29-
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.1.2
29+
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.1
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected].5
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected].7
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]

models/actions/runner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type ActionRunner struct {
5757

5858
// Store labels defined in state file (default: .runner file) of `act_runner`
5959
AgentLabels []string `xorm:"TEXT"`
60+
// Store if this is a runner that only ever get one single job assigned
61+
Ephemeral bool `xorm:"ephemeral NOT NULL DEFAULT false"`
6062

6163
Created timeutil.TimeStamp `xorm:"created"`
6264
Updated timeutil.TimeStamp `xorm:"updated"`

models/actions/variable.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ package actions
66
import (
77
"context"
88
"strings"
9+
"unicode/utf8"
910

1011
"code.gitea.io/gitea/models/db"
1112
"code.gitea.io/gitea/modules/log"
1213
"code.gitea.io/gitea/modules/timeutil"
14+
"code.gitea.io/gitea/modules/util"
1315

1416
"xorm.io/builder"
1517
)
@@ -32,26 +34,39 @@ type ActionVariable struct {
3234
RepoID int64 `xorm:"INDEX UNIQUE(owner_repo_name)"`
3335
Name string `xorm:"UNIQUE(owner_repo_name) NOT NULL"`
3436
Data string `xorm:"LONGTEXT NOT NULL"`
37+
Description string `xorm:"TEXT"`
3538
CreatedUnix timeutil.TimeStamp `xorm:"created NOT NULL"`
3639
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
3740
}
3841

42+
const (
43+
VariableDataMaxLength = 65536
44+
VariableDescriptionMaxLength = 4096
45+
)
46+
3947
func init() {
4048
db.RegisterModel(new(ActionVariable))
4149
}
4250

43-
func InsertVariable(ctx context.Context, ownerID, repoID int64, name, data string) (*ActionVariable, error) {
51+
func InsertVariable(ctx context.Context, ownerID, repoID int64, name, data, description string) (*ActionVariable, error) {
4452
if ownerID != 0 && repoID != 0 {
4553
// It's trying to create a variable that belongs to a repository, but OwnerID has been set accidentally.
4654
// Remove OwnerID to avoid confusion; it's not worth returning an error here.
4755
ownerID = 0
4856
}
4957

58+
if utf8.RuneCountInString(data) > VariableDataMaxLength {
59+
return nil, util.NewInvalidArgumentErrorf("data too long")
60+
}
61+
62+
description = util.TruncateRunes(description, VariableDescriptionMaxLength)
63+
5064
variable := &ActionVariable{
51-
OwnerID: ownerID,
52-
RepoID: repoID,
53-
Name: strings.ToUpper(name),
54-
Data: data,
65+
OwnerID: ownerID,
66+
RepoID: repoID,
67+
Name: strings.ToUpper(name),
68+
Data: data,
69+
Description: description,
5570
}
5671
return variable, db.Insert(ctx, variable)
5772
}
@@ -96,6 +111,12 @@ func FindVariables(ctx context.Context, opts FindVariablesOpts) ([]*ActionVariab
96111
}
97112

98113
func UpdateVariableCols(ctx context.Context, variable *ActionVariable, cols ...string) (bool, error) {
114+
if utf8.RuneCountInString(variable.Data) > VariableDataMaxLength {
115+
return false, util.NewInvalidArgumentErrorf("data too long")
116+
}
117+
118+
variable.Description = util.TruncateRunes(variable.Description, VariableDescriptionMaxLength)
119+
99120
variable.Name = strings.ToUpper(variable.Name)
100121
count, err := db.GetEngine(ctx).
101122
ID(variable.ID).

models/git/commit_status.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,8 @@ func NewCommitStatus(ctx context.Context, opts NewCommitStatusOptions) error {
453453
return fmt.Errorf("NewCommitStatus[nil, %s]: no repository specified", opts.SHA)
454454
}
455455

456-
repoPath := opts.Repo.RepoPath()
457456
if opts.Creator == nil {
458-
return fmt.Errorf("NewCommitStatus[%s, %s]: no user specified", repoPath, opts.SHA)
457+
return fmt.Errorf("NewCommitStatus[%s, %s]: no user specified", opts.Repo.FullName(), opts.SHA)
459458
}
460459

461460
ctx, committer, err := db.TxContext(ctx)
@@ -477,13 +476,13 @@ func NewCommitStatus(ctx context.Context, opts NewCommitStatusOptions) error {
477476
opts.CommitStatus.CreatorID = opts.Creator.ID
478477
opts.CommitStatus.RepoID = opts.Repo.ID
479478
opts.CommitStatus.Index = idx
480-
log.Debug("NewCommitStatus[%s, %s]: %d", repoPath, opts.SHA, opts.CommitStatus.Index)
479+
log.Debug("NewCommitStatus[%s, %s]: %d", opts.Repo.FullName(), opts.SHA, opts.CommitStatus.Index)
481480

482481
opts.CommitStatus.ContextHash = hashCommitStatusContext(opts.CommitStatus.Context)
483482

484483
// Insert new CommitStatus
485484
if _, err = db.GetEngine(ctx).Insert(opts.CommitStatus); err != nil {
486-
return fmt.Errorf("insert CommitStatus[%s, %s]: %w", repoPath, opts.SHA, err)
485+
return fmt.Errorf("insert CommitStatus[%s, %s]: %w", opts.Repo.FullName(), opts.SHA, err)
487486
}
488487

489488
return committer.Commit()

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ func prepareMigrationTasks() []*migration {
375375
newMigration(312, "Add DeleteBranchAfterMerge to AutoMerge", v1_24.AddDeleteBranchAfterMergeForAutoMerge),
376376
newMigration(313, "Move PinOrder from issue table to a new table issue_pin", v1_24.MovePinOrderToTableIssuePin),
377377
newMigration(314, "Update OwnerID as zero for repository level action tables", v1_24.UpdateOwnerIDOfRepoLevelActionsTables),
378+
newMigration(315, "Add Ephemeral to ActionRunner", v1_24.AddEphemeralToActionRunner),
379+
newMigration(316, "Add description for secrets and variables", v1_24.AddDescriptionForSecretsAndVariables),
378380
}
379381
return preparedMigrations
380382
}

models/migrations/v1_24/v315.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 AddEphemeralToActionRunner(x *xorm.Engine) error {
11+
type ActionRunner struct {
12+
Ephemeral bool `xorm:"ephemeral NOT NULL DEFAULT false"`
13+
}
14+
15+
return x.Sync(new(ActionRunner))
16+
}

models/migrations/v1_24/v316.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 AddDescriptionForSecretsAndVariables(x *xorm.Engine) error {
11+
type Secret struct {
12+
Description string `xorm:"TEXT"`
13+
}
14+
15+
type ActionVariable struct {
16+
Description string `xorm:"TEXT"`
17+
}
18+
19+
return x.Sync(new(Secret), new(ActionVariable))
20+
}

models/secret/secret.go

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ type Secret struct {
4040
RepoID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL DEFAULT 0"`
4141
Name string `xorm:"UNIQUE(owner_repo_name) NOT NULL"`
4242
Data string `xorm:"LONGTEXT"` // encrypted data
43+
Description string `xorm:"TEXT"`
4344
CreatedUnix timeutil.TimeStamp `xorm:"created NOT NULL"`
4445
}
4546

47+
const (
48+
SecretDataMaxLength = 65536
49+
SecretDescriptionMaxLength = 4096
50+
)
51+
4652
// ErrSecretNotFound represents a "secret not found" error.
4753
type ErrSecretNotFound struct {
4854
Name string
@@ -57,7 +63,7 @@ func (err ErrSecretNotFound) Unwrap() error {
5763
}
5864

5965
// InsertEncryptedSecret Creates, encrypts, and validates a new secret with yet unencrypted data and insert into database
60-
func InsertEncryptedSecret(ctx context.Context, ownerID, repoID int64, name, data string) (*Secret, error) {
66+
func InsertEncryptedSecret(ctx context.Context, ownerID, repoID int64, name, data, description string) (*Secret, error) {
6167
if ownerID != 0 && repoID != 0 {
6268
// It's trying to create a secret that belongs to a repository, but OwnerID has been set accidentally.
6369
// Remove OwnerID to avoid confusion; it's not worth returning an error here.
@@ -67,15 +73,23 @@ func InsertEncryptedSecret(ctx context.Context, ownerID, repoID int64, name, dat
6773
return nil, fmt.Errorf("%w: ownerID and repoID cannot be both zero, global secrets are not supported", util.ErrInvalidArgument)
6874
}
6975

76+
if len(data) > SecretDataMaxLength {
77+
return nil, util.NewInvalidArgumentErrorf("data too long")
78+
}
79+
80+
description = util.TruncateRunes(description, SecretDescriptionMaxLength)
81+
7082
encrypted, err := secret_module.EncryptSecret(setting.SecretKey, data)
7183
if err != nil {
7284
return nil, err
7385
}
86+
7487
secret := &Secret{
75-
OwnerID: ownerID,
76-
RepoID: repoID,
77-
Name: strings.ToUpper(name),
78-
Data: encrypted,
88+
OwnerID: ownerID,
89+
RepoID: repoID,
90+
Name: strings.ToUpper(name),
91+
Data: encrypted,
92+
Description: description,
7993
}
8094
return secret, db.Insert(ctx, secret)
8195
}
@@ -114,16 +128,23 @@ func (opts FindSecretsOptions) ToConds() builder.Cond {
114128
}
115129

116130
// UpdateSecret changes org or user reop secret.
117-
func UpdateSecret(ctx context.Context, secretID int64, data string) error {
131+
func UpdateSecret(ctx context.Context, secretID int64, data, description string) error {
132+
if len(data) > SecretDataMaxLength {
133+
return util.NewInvalidArgumentErrorf("data too long")
134+
}
135+
136+
description = util.TruncateRunes(description, SecretDescriptionMaxLength)
137+
118138
encrypted, err := secret_module.EncryptSecret(setting.SecretKey, data)
119139
if err != nil {
120140
return err
121141
}
122142

123143
s := &Secret{
124-
Data: encrypted,
144+
Data: encrypted,
145+
Description: description,
125146
}
126-
affected, err := db.GetEngine(ctx).ID(secretID).Cols("data").Update(s)
147+
affected, err := db.GetEngine(ctx).ID(secretID).Cols("data", "description").Update(s)
127148
if affected != 1 {
128149
return ErrSecretNotFound{}
129150
}

0 commit comments

Comments
 (0)