Skip to content

Commit 90b24e8

Browse files
committed
Merge branch 'main' into lunny/fix_demilestoned_webhook
2 parents cdd47c7 + 1a7591d commit 90b24e8

File tree

416 files changed

+3997
-3339
lines changed

Some content is hidden

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

416 files changed

+3997
-3339
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.23-alpine3.20 AS build-env
2+
FROM docker.io/library/golang:1.23-alpine3.21 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -41,7 +41,7 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
4141
/go/src/code.gitea.io/gitea/environment-to-ini
4242
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4343

44-
FROM docker.io/library/alpine:3.20
44+
FROM docker.io/library/alpine:3.21
4545
LABEL maintainer="[email protected]"
4646

4747
EXPOSE 22 3000
@@ -78,7 +78,7 @@ ENV GITEA_CUSTOM=/data/gitea
7878
VOLUME ["/data"]
7979

8080
ENTRYPOINT ["/usr/bin/entrypoint"]
81-
CMD ["/bin/s6-svscan", "/etc/s6"]
81+
CMD ["/usr/bin/s6-svscan", "/etc/s6"]
8282

8383
COPY --from=build-env /tmp/local /
8484
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.23-alpine3.20 AS build-env
2+
FROM docker.io/library/golang:1.23-alpine3.21 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -39,7 +39,7 @@ RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
3939
/go/src/code.gitea.io/gitea/environment-to-ini
4040
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4141

42-
FROM docker.io/library/alpine:3.20
42+
FROM docker.io/library/alpine:3.21
4343
LABEL maintainer="[email protected]"
4444

4545
EXPOSE 2222 3000

models/actions/runner_token.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
repo_model "code.gitea.io/gitea/models/repo"
1212
user_model "code.gitea.io/gitea/models/user"
13+
"code.gitea.io/gitea/modules/base"
1314
"code.gitea.io/gitea/modules/timeutil"
1415
"code.gitea.io/gitea/modules/util"
1516
)
@@ -51,7 +52,7 @@ func GetRunnerToken(ctx context.Context, token string) (*ActionRunnerToken, erro
5152
if err != nil {
5253
return nil, err
5354
} else if !has {
54-
return nil, fmt.Errorf("runner token %q: %w", token, util.ErrNotExist)
55+
return nil, fmt.Errorf(`runner token "%s...": %w`, base.TruncateString(token, 3), util.ErrNotExist)
5556
}
5657
return &runnerToken, nil
5758
}
@@ -68,19 +69,15 @@ func UpdateRunnerToken(ctx context.Context, r *ActionRunnerToken, cols ...string
6869
return err
6970
}
7071

71-
// NewRunnerToken creates a new active runner token and invalidate all old tokens
72+
// NewRunnerTokenWithValue creates a new active runner token and invalidate all old tokens
7273
// ownerID will be ignored and treated as 0 if repoID is non-zero.
73-
func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error) {
74+
func NewRunnerTokenWithValue(ctx context.Context, ownerID, repoID int64, token string) (*ActionRunnerToken, error) {
7475
if ownerID != 0 && repoID != 0 {
7576
// It's trying to create a runner token that belongs to a repository, but OwnerID has been set accidentally.
7677
// Remove OwnerID to avoid confusion; it's not worth returning an error here.
7778
ownerID = 0
7879
}
7980

80-
token, err := util.CryptoRandomString(40)
81-
if err != nil {
82-
return nil, err
83-
}
8481
runnerToken := &ActionRunnerToken{
8582
OwnerID: ownerID,
8683
RepoID: repoID,
@@ -95,11 +92,19 @@ func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerTo
9592
return err
9693
}
9794

98-
_, err = db.GetEngine(ctx).Insert(runnerToken)
95+
_, err := db.GetEngine(ctx).Insert(runnerToken)
9996
return err
10097
})
10198
}
10299

100+
func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error) {
101+
token, err := util.CryptoRandomString(40)
102+
if err != nil {
103+
return nil, err
104+
}
105+
return NewRunnerTokenWithValue(ctx, ownerID, repoID, token)
106+
}
107+
103108
// GetLatestRunnerToken returns the latest runner token
104109
func GetLatestRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error) {
105110
if ownerID != 0 && repoID != 0 {

models/auth/source_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"code.gitea.io/gitea/modules/json"
1414

1515
"github.com/stretchr/testify/assert"
16+
"github.com/stretchr/testify/require"
17+
"xorm.io/xorm"
1618
"xorm.io/xorm/schemas"
1719
)
1820

@@ -54,7 +56,8 @@ func TestDumpAuthSource(t *testing.T) {
5456

5557
sb := new(strings.Builder)
5658

57-
db.DumpTables([]*schemas.Table{authSourceSchema}, sb)
58-
59+
// TODO: this test is quite hacky, it should use a low-level "select" (without model processors) but not a database dump
60+
engine := db.GetEngine(db.DefaultContext).(*xorm.Engine)
61+
require.NoError(t, engine.DumpTables([]*schemas.Table{authSourceSchema}, sb))
5962
assert.Contains(t, sb.String(), `"Provider":"ConvertibleSourceName"`)
6063
}

models/db/collation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func CheckCollations(x *xorm.Engine) (*CheckCollationsResult, error) {
140140
}
141141

142142
func CheckCollationsDefaultEngine() (*CheckCollationsResult, error) {
143-
return CheckCollations(x)
143+
return CheckCollations(xormEngine)
144144
}
145145

146146
func alterDatabaseCollation(x *xorm.Engine, collation string) error {

models/db/context.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func GetEngine(ctx context.Context) Engine {
9494
if e := getExistingEngine(ctx); e != nil {
9595
return e
9696
}
97-
return x.Context(ctx)
97+
return xormEngine.Context(ctx)
9898
}
9999

100100
// getExistingEngine gets an existing db Engine/Statement from this context or returns nil
@@ -155,7 +155,7 @@ func TxContext(parentCtx context.Context) (*Context, Committer, error) {
155155
return newContext(parentCtx, sess), &halfCommitter{committer: sess}, nil
156156
}
157157

158-
sess := x.NewSession()
158+
sess := xormEngine.NewSession()
159159
if err := sess.Begin(); err != nil {
160160
_ = sess.Close()
161161
return nil, nil, err
@@ -179,7 +179,7 @@ func WithTx(parentCtx context.Context, f func(ctx context.Context) error) error
179179
}
180180

181181
func txWithNoCheck(parentCtx context.Context, f func(ctx context.Context) error) error {
182-
sess := x.NewSession()
182+
sess := xormEngine.NewSession()
183183
defer sess.Close()
184184
if err := sess.Begin(); err != nil {
185185
return err
@@ -322,7 +322,7 @@ func CountByBean(ctx context.Context, bean any) (int64, error) {
322322

323323
// TableName returns the table name according a bean object
324324
func TableName(bean any) string {
325-
return x.TableName(bean)
325+
return xormEngine.TableName(bean)
326326
}
327327

328328
// InTransaction returns true if the engine is in a transaction otherwise return false

models/db/convert.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ import (
1616

1717
// ConvertDatabaseTable converts database and tables from utf8 to utf8mb4 if it's mysql and set ROW_FORMAT=dynamic
1818
func ConvertDatabaseTable() error {
19-
if x.Dialect().URI().DBType != schemas.MYSQL {
19+
if xormEngine.Dialect().URI().DBType != schemas.MYSQL {
2020
return nil
2121
}
2222

23-
r, err := CheckCollations(x)
23+
r, err := CheckCollations(xormEngine)
2424
if err != nil {
2525
return err
2626
}
2727

28-
_, err = x.Exec(fmt.Sprintf("ALTER DATABASE `%s` CHARACTER SET utf8mb4 COLLATE %s", setting.Database.Name, r.ExpectedCollation))
28+
_, err = xormEngine.Exec(fmt.Sprintf("ALTER DATABASE `%s` CHARACTER SET utf8mb4 COLLATE %s", setting.Database.Name, r.ExpectedCollation))
2929
if err != nil {
3030
return err
3131
}
3232

33-
tables, err := x.DBMetas()
33+
tables, err := xormEngine.DBMetas()
3434
if err != nil {
3535
return err
3636
}
3737
for _, table := range tables {
38-
if _, err := x.Exec(fmt.Sprintf("ALTER TABLE `%s` ROW_FORMAT=dynamic", table.Name)); err != nil {
38+
if _, err := xormEngine.Exec(fmt.Sprintf("ALTER TABLE `%s` ROW_FORMAT=dynamic", table.Name)); err != nil {
3939
return err
4040
}
4141

42-
if _, err := x.Exec(fmt.Sprintf("ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8mb4 COLLATE %s", table.Name, r.ExpectedCollation)); err != nil {
42+
if _, err := xormEngine.Exec(fmt.Sprintf("ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8mb4 COLLATE %s", table.Name, r.ExpectedCollation)); err != nil {
4343
return err
4444
}
4545
}
@@ -49,11 +49,11 @@ func ConvertDatabaseTable() error {
4949

5050
// ConvertVarcharToNVarchar converts database and tables from varchar to nvarchar if it's mssql
5151
func ConvertVarcharToNVarchar() error {
52-
if x.Dialect().URI().DBType != schemas.MSSQL {
52+
if xormEngine.Dialect().URI().DBType != schemas.MSSQL {
5353
return nil
5454
}
5555

56-
sess := x.NewSession()
56+
sess := xormEngine.NewSession()
5757
defer sess.Close()
5858
res, err := sess.QuerySliceString(`SELECT 'ALTER TABLE ' + OBJECT_NAME(SC.object_id) + ' MODIFY SC.name NVARCHAR(' + CONVERT(VARCHAR(5),SC.max_length) + ')'
5959
FROM SYS.columns SC

0 commit comments

Comments
 (0)