Skip to content

Commit a548fe7

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Added instance-level variables (go-gitea#28115) Revert "improve possible performance bottleneck (go-gitea#28547)" (go-gitea#28593) [skip ci] Updated licenses and gitignores Fix flex container width (go-gitea#28603) Fix the scroll behavior for emoji/mention list (go-gitea#28597) bump to use alpine3.19 (go-gitea#28594) Include heap pprof in diagnosis report to help debugging memory leaks (go-gitea#28596) Disable query token param in integration tests (go-gitea#28592) Fix wrong due date rendering in issue list page (go-gitea#28588) Fix `status_check_contexts` matching bug (go-gitea#28582) Fix 405 method not allowed CORS / OIDC (go-gitea#28583)
2 parents 9296ce0 + d0f24ff commit a548fe7

24 files changed

+137
-82
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
2+
FROM docker.io/library/golang:1.21-alpine3.19 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.18
44+
FROM docker.io/library/alpine:3.19
4545
LABEL maintainer="maintainers@gitea.io"
4646

4747
EXPOSE 22 3000

Dockerfile.rootless

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
2+
FROM docker.io/library/golang:1.21-alpine3.19 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.18
42+
FROM docker.io/library/alpine:3.19
4343
LABEL maintainer="maintainers@gitea.io"
4444

4545
EXPOSE 2222 3000

models/actions/variable.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func init() {
3131
}
3232

3333
func (v *ActionVariable) Validate() error {
34-
if v.OwnerID == 0 && v.RepoID == 0 {
35-
return errors.New("the variable is not bound to any scope")
34+
if v.OwnerID != 0 && v.RepoID != 0 {
35+
return errors.New("a variable should not be bound to an owner and a repository at the same time")
3636
}
3737
return nil
3838
}
@@ -58,12 +58,8 @@ type FindVariablesOpts struct {
5858

5959
func (opts FindVariablesOpts) ToConds() builder.Cond {
6060
cond := builder.NewCond()
61-
if opts.OwnerID > 0 {
62-
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
63-
}
64-
if opts.RepoID > 0 {
65-
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
66-
}
61+
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
62+
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
6763
return cond
6864
}
6965

models/issues/comment.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,14 @@ func DeleteComment(ctx context.Context, comment *Comment) error {
11611161
// UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id
11621162
func UpdateCommentsMigrationsByType(ctx context.Context, tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
11631163
_, err := db.GetEngine(ctx).Table("comment").
1164-
Join("INNER", "issue", "issue.id = comment.issue_id").
1165-
Join("INNER", "repository", "issue.repo_id = repository.id").
1166-
Where("repository.original_service_type = ?", tp).
1164+
Where(builder.In("issue_id",
1165+
builder.Select("issue.id").
1166+
From("issue").
1167+
InnerJoin("repository", "issue.repo_id = repository.id").
1168+
Where(builder.Eq{
1169+
"repository.original_service_type": tp,
1170+
}),
1171+
)).
11671172
And("comment.original_author_id = ?", originalAuthorID).
11681173
Update(map[string]any{
11691174
"poster_id": posterID,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Copyright (C) 2008 Micah J. Cowan
2+
3+
Copying and distribution of this file, with or without modification,
4+
are permitted in any medium without royalty provided the copyright
5+
notice and this notice are preserved.

options/license/HPND-Kevlin-Henney

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.
2+
3+
Permission to use, copy, modify, and distribute this software and its
4+
documentation for any purpose is hereby granted without fee, provided
5+
that this copyright and permissions notice appear in all copies and
6+
derivatives.
7+
8+
This software is supplied "as is" without express or implied warranty.
9+
10+
But that said, if there are any problems please get in touch.

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

routers/api/actions/runner/utils.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func getSecretsOfTask(ctx context.Context, task *actions_model.ActionTask) map[s
9494
func getVariablesOfTask(ctx context.Context, task *actions_model.ActionTask) map[string]string {
9595
variables := map[string]string{}
9696

97+
// Global
98+
globalVariables, err := db.Find[actions_model.ActionVariable](ctx, actions_model.FindVariablesOpts{})
99+
if err != nil {
100+
log.Error("find global variables: %v", err)
101+
}
102+
97103
// Org / User level
98104
ownerVariables, err := db.Find[actions_model.ActionVariable](ctx, actions_model.FindVariablesOpts{OwnerID: task.Job.Run.Repo.OwnerID})
99105
if err != nil {
@@ -106,8 +112,8 @@ func getVariablesOfTask(ctx context.Context, task *actions_model.ActionTask) map
106112
log.Error("find variables of repo: %d, error: %v", task.Job.Run.RepoID, err)
107113
}
108114

109-
// Level precedence: Repo > Org / User
110-
for _, v := range append(ownerVariables, repoVariables...) {
115+
// Level precedence: Repo > Org / User > Global
116+
for _, v := range append(globalVariables, append(ownerVariables, repoVariables...)...) {
111117
variables[v.Name] = v.Data
112118
}
113119

routers/web/admin/diagnosis.go

+7
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ func MonitorDiagnosis(ctx *context.Context) {
5858
return
5959
}
6060
_ = pprof.Lookup("goroutine").WriteTo(f, 1)
61+
62+
f, err = zipWriter.CreateHeader(&zip.FileHeader{Name: "heap.dat", Method: zip.Deflate, Modified: time.Now()})
63+
if err != nil {
64+
ctx.ServerError("Failed to create zip file", err)
65+
return
66+
}
67+
_ = pprof.Lookup("heap").WriteTo(f, 0)
6168
}

routers/web/repo/pull.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,15 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
653653
if pb != nil && pb.EnableStatusCheck {
654654
ctx.Data["is_context_required"] = func(context string) bool {
655655
for _, c := range pb.StatusCheckContexts {
656-
if gp, err := glob.Compile(c); err == nil && gp.Match(context) {
656+
if c == context {
657+
return true
658+
}
659+
if gp, err := glob.Compile(c); err != nil {
660+
// All newly created status_check_contexts are checked to ensure they are valid glob expressions before being stored in the database.
661+
// But some old status_check_context created before glob was introduced may be invalid glob expressions.
662+
// So log the error here for debugging.
663+
log.Error("compile glob %q: %v", c, err)
664+
} else if gp.Match(context) {
657665
return true
658666
}
659667
}

routers/web/repo/setting/variables.go

+18-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import (
1515
)
1616

1717
const (
18-
tplRepoVariables base.TplName = "repo/settings/actions"
19-
tplOrgVariables base.TplName = "org/settings/actions"
20-
tplUserVariables base.TplName = "user/settings/actions"
18+
tplRepoVariables base.TplName = "repo/settings/actions"
19+
tplOrgVariables base.TplName = "org/settings/actions"
20+
tplUserVariables base.TplName = "user/settings/actions"
21+
tplAdminVariables base.TplName = "admin/actions"
2122
)
2223

2324
type variablesCtx struct {
@@ -26,13 +27,15 @@ type variablesCtx struct {
2627
IsRepo bool
2728
IsOrg bool
2829
IsUser bool
30+
IsGlobal bool
2931
VariablesTemplate base.TplName
3032
RedirectLink string
3133
}
3234

3335
func getVariablesCtx(ctx *context.Context) (*variablesCtx, error) {
3436
if ctx.Data["PageIsRepoSettings"] == true {
3537
return &variablesCtx{
38+
OwnerID: 0,
3639
RepoID: ctx.Repo.Repository.ID,
3740
IsRepo: true,
3841
VariablesTemplate: tplRepoVariables,
@@ -48,6 +51,7 @@ func getVariablesCtx(ctx *context.Context) (*variablesCtx, error) {
4851
}
4952
return &variablesCtx{
5053
OwnerID: ctx.ContextUser.ID,
54+
RepoID: 0,
5155
IsOrg: true,
5256
VariablesTemplate: tplOrgVariables,
5357
RedirectLink: ctx.Org.OrgLink + "/settings/actions/variables",
@@ -57,12 +61,23 @@ func getVariablesCtx(ctx *context.Context) (*variablesCtx, error) {
5761
if ctx.Data["PageIsUserSettings"] == true {
5862
return &variablesCtx{
5963
OwnerID: ctx.Doer.ID,
64+
RepoID: 0,
6065
IsUser: true,
6166
VariablesTemplate: tplUserVariables,
6267
RedirectLink: setting.AppSubURL + "/user/settings/actions/variables",
6368
}, nil
6469
}
6570

71+
if ctx.Data["PageIsAdmin"] == true {
72+
return &variablesCtx{
73+
OwnerID: 0,
74+
RepoID: 0,
75+
IsGlobal: true,
76+
VariablesTemplate: tplAdminVariables,
77+
RedirectLink: setting.AppSubURL + "/admin/actions/variables",
78+
}, nil
79+
}
80+
6681
return nil, errors.New("unable to set Variables context")
6782
}
6883

routers/web/web.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func registerRoutes(m *web.Route) {
417417
m.Post("/packagist/{id}", web.Bind(forms.NewPackagistHookForm{}), repo_setting.PackagistHooksEditPost)
418418
}
419419

420-
addSettingVariablesRoutes := func() {
420+
addSettingsVariablesRoutes := func() {
421421
m.Group("/variables", func() {
422422
m.Get("", repo_setting.Variables)
423423
m.Post("/new", web.Bind(forms.EditVariableForm{}), repo_setting.VariableCreate)
@@ -532,9 +532,11 @@ func registerRoutes(m *web.Route) {
532532
// TODO manage redirection
533533
m.Post("/authorize", web.Bind(forms.AuthorizationForm{}), auth.AuthorizeOAuth)
534534
}, ignSignInAndCsrf, reqSignIn)
535+
m.Options("/login/oauth/userinfo", CorsHandler(), misc.DummyBadRequest)
535536
m.Get("/login/oauth/userinfo", ignSignInAndCsrf, auth.InfoOAuth)
536537
m.Options("/login/oauth/access_token", CorsHandler(), misc.DummyBadRequest)
537538
m.Post("/login/oauth/access_token", CorsHandler(), web.Bind(forms.AccessTokenForm{}), ignSignInAndCsrf, auth.AccessTokenOAuth)
539+
m.Options("/login/oauth/keys", CorsHandler(), misc.DummyBadRequest)
538540
m.Get("/login/oauth/keys", ignSignInAndCsrf, auth.OIDCKeys)
539541
m.Options("/login/oauth/introspect", CorsHandler(), misc.DummyBadRequest)
540542
m.Post("/login/oauth/introspect", CorsHandler(), web.Bind(forms.IntrospectTokenForm{}), ignSignInAndCsrf, auth.IntrospectOAuth)
@@ -616,7 +618,7 @@ func registerRoutes(m *web.Route) {
616618
m.Get("", user_setting.RedirectToDefaultSetting)
617619
addSettingsRunnersRoutes()
618620
addSettingsSecretsRoutes()
619-
addSettingVariablesRoutes()
621+
addSettingsVariablesRoutes()
620622
}, actions.MustEnableActions)
621623

622624
m.Get("/organization", user_setting.Organization)
@@ -761,6 +763,7 @@ func registerRoutes(m *web.Route) {
761763
m.Group("/actions", func() {
762764
m.Get("", admin.RedirectToDefaultSetting)
763765
addSettingsRunnersRoutes()
766+
addSettingsVariablesRoutes()
764767
})
765768
}, adminReq, ctxDataSet("EnableOAuth2", setting.OAuth2.Enable, "EnablePackages", setting.Packages.Enabled))
766769
// ***** END: Admin *****
@@ -903,7 +906,7 @@ func registerRoutes(m *web.Route) {
903906
m.Get("", org_setting.RedirectToDefaultSetting)
904907
addSettingsRunnersRoutes()
905908
addSettingsSecretsRoutes()
906-
addSettingVariablesRoutes()
909+
addSettingsVariablesRoutes()
907910
}, actions.MustEnableActions)
908911

909912
m.Methods("GET,POST", "/delete", org.SettingsDelete)
@@ -1082,7 +1085,7 @@ func registerRoutes(m *web.Route) {
10821085
m.Get("", repo_setting.RedirectToDefaultSetting)
10831086
addSettingsRunnersRoutes()
10841087
addSettingsSecretsRoutes()
1085-
addSettingVariablesRoutes()
1088+
addSettingsVariablesRoutes()
10861089
}, actions.MustEnableActions)
10871090
// the follow handler must be under "settings", otherwise this incomplete repo can't be accessed
10881091
m.Group("/migrate", func() {

templates/admin/actions.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
{{if eq .PageType "runners"}}
44
{{template "shared/actions/runner_list" .}}
55
{{end}}
6+
{{if eq .PageType "variables"}}
7+
{{template "shared/variables/variable_list" .}}
8+
{{end}}
69
</div>
710
{{template "admin/layout_footer" .}}

templates/admin/navbar.tmpl

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@
6060
{{end}}
6161
{{end}}
6262
{{if .EnableActions}}
63-
<details class="item toggleable-item" {{if .PageIsSharedSettingsRunners}}open{{end}}>
63+
<details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsVariables}}open{{end}}>
6464
<summary>{{ctx.Locale.Tr "actions.actions"}}</summary>
6565
<div class="menu">
6666
<a class="{{if .PageIsSharedSettingsRunners}}active {{end}}item" href="{{AppSubUrl}}/admin/actions/runners">
6767
{{ctx.Locale.Tr "actions.runners"}}
6868
</a>
69+
<a class="{{if .PageIsSharedSettingsVariables}}active {{end}}item" href="{{AppSubUrl}}/admin/actions/variables">
70+
{{ctx.Locale.Tr "actions.variables"}}
71+
</a>
6972
</div>
7073
</details>
7174
{{end}}

templates/shared/issuelist.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<span class="due-date flex-text-inline" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.due_date"}}">
115115
<span{{if .IsOverdue}} class="text red"{{end}}>
116116
{{svg "octicon-calendar" 14}}
117-
{{DateTime "short" .DeadlineUnix}}
117+
{{DateTime "short" (.DeadlineUnix.Format "2006-01-02")}}
118118
</span>
119119
</span>
120120
{{end}}

0 commit comments

Comments
 (0)