Skip to content

Commit 219d4d4

Browse files
authored
Merge branch 'main' into patch-1
2 parents 1393328 + 8f2e287 commit 219d4d4

File tree

31 files changed

+380
-256
lines changed

31 files changed

+380
-256
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.20-bullseye",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.21-bullseye",
44
"features": {
55
// installs nodejs into container
66
"ghcr.io/devcontainers/features/node:1": {

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ Translations are done through Crowdin. If you want to translate to a new languag
110110

111111
You can also just create an issue for adding a language or ask on discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty but we hope to fill it as questions pop up.
112112

113-
https://docs.gitea.io/en-us/contributing/translation-guidelines/
113+
https://docs.gitea.com/contributing/localization
114114

115115
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
116116

117117
## Further information
118118

119-
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.io/en-us/).
119+
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.com/).
120120
If you have questions that are not covered by the documentation, you can get in contact with us on our [Discord server](https://discord.gg/Gitea) or create a post in the [discourse forum](https://discourse.gitea.io/).
121121

122122
We maintain a list of Gitea-related projects at [gitea/awesome-gitea](https://gitea.com/gitea/awesome-gitea).
@@ -151,7 +151,6 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
151151
<a href="https://opencollective.com/gitea/sponsor/7/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/7/avatar.svg"></a>
152152
<a href="https://opencollective.com/gitea/sponsor/8/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/8/avatar.svg"></a>
153153
<a href="https://opencollective.com/gitea/sponsor/9/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/9/avatar.svg"></a>
154-
<a href="https://cynkra.com/" target="_blank"><img src="https://images.opencollective.com/cynkra/logo/square/64/192.png"></a>
155154

156155
## FAQ
157156

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
;; Do not copy the whole file as-is, as it contains some invalid sections for illustrative purposes.
55
;; If you don't know what a setting is you should not set it.
66
;;
7-
;; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
7+
;; see https://docs.gitea.com/administration/config-cheat-sheet for additional documentation.
88

99

1010
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -454,7 +454,7 @@ INTERNAL_TOKEN=
454454
;REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128
455455
;;
456456
;; The minimum password length for new Users
457-
;MIN_PASSWORD_LENGTH = 6
457+
;MIN_PASSWORD_LENGTH = 8
458458
;;
459459
;; Set to true to allow users to import local server paths
460460
;IMPORT_LOCAL_PATHS = false

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ And the following unique queues:
559559
- `scrypt`: `scrypt$65536$16$2$50`
560560
- Adjusting the algorithm parameters using this functionality is done at your own risk.
561561
- `CSRF_COOKIE_HTTP_ONLY`: **true**: Set false to allow JavaScript to read CSRF cookie.
562-
- `MIN_PASSWORD_LENGTH`: **6**: Minimum password length for new users.
562+
- `MIN_PASSWORD_LENGTH`: **8**: Minimum password length for new users.
563563
- `PASSWORD_COMPLEXITY`: **off**: Comma separated list of character classes required to pass minimum complexity. If left empty or no valid values are specified, checking is disabled (off):
564564
- lower - use one or more lower latin characters
565565
- upper - use one or more upper latin characters

modules/setting/security.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func loadSecurityFrom(rootCfg ConfigProvider) {
124124
ReverseProxyTrustedProxies = []string{"127.0.0.0/8", "::1/128"}
125125
}
126126

127-
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
127+
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(8)
128128
ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
129129
DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(true)
130130
DisableWebhooks = sec.Key("DISABLE_WEBHOOKS").MustBool(false)

modules/storage/minio.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
9191
}
9292

9393
// Check to see if we already own this bucket
94-
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
95-
if errBucketExists != nil {
94+
exists, err := minioClient.BucketExists(ctx, config.Bucket)
95+
if err != nil {
9696
return nil, convertMinioErr(err)
9797
}
9898

modules/structs/secret.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@ package structs
55

66
import "time"
77

8-
// User represents a secret
8+
// Secret represents a secret
99
// swagger:model
1010
type Secret struct {
1111
// the secret's name
1212
Name string `json:"name"`
1313
// swagger:strfmt date-time
1414
Created time.Time `json:"created_at"`
1515
}
16+
17+
// CreateSecretOption options when creating secret
18+
// swagger:model
19+
type CreateSecretOption struct {
20+
// Name of the secret to create
21+
//
22+
// required: true
23+
// unique: true
24+
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
25+
// Data of the secret to create
26+
Data string `json:"data" binding:"Required"`
27+
}

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,6 +3503,7 @@ workflow.disable = Disable Workflow
35033503
workflow.disable_success = Workflow '%s' disabled successfully.
35043504
workflow.enable = Enable Workflow
35053505
workflow.enable_success = Workflow '%s' enabled successfully.
3506+
workflow.disabled = Workflow is disabled.
35063507
35073508
need_approval_desc = Need approval to run workflows for fork pull request.
35083509

routers/api/v1/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,7 @@ func Routes() *web.Route {
13011301
})
13021302
m.Group("/actions/secrets", func() {
13031303
m.Get("", reqToken(), reqOrgOwnership(), org.ListActionsSecrets)
1304+
m.Post("", reqToken(), reqOrgOwnership(), bind(api.CreateSecretOption{}), org.CreateOrgSecret)
13041305
})
13051306
m.Group("/public_members", func() {
13061307
m.Get("", org.ListPublicMembers)

routers/api/v1/org/action.go

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ package org
66
import (
77
"net/http"
88

9-
"code.gitea.io/gitea/models/secret"
9+
secret_model "code.gitea.io/gitea/models/secret"
1010
"code.gitea.io/gitea/modules/context"
1111
api "code.gitea.io/gitea/modules/structs"
12+
"code.gitea.io/gitea/modules/web"
1213
"code.gitea.io/gitea/routers/api/v1/utils"
14+
"code.gitea.io/gitea/routers/web/shared/actions"
15+
"code.gitea.io/gitea/services/convert"
1316
)
1417

1518
// ListActionsSecrets list an organization's actions secrets
@@ -42,18 +45,18 @@ func ListActionsSecrets(ctx *context.APIContext) {
4245

4346
// listActionsSecrets list an organization's actions secrets
4447
func listActionsSecrets(ctx *context.APIContext) {
45-
opts := &secret.FindSecretsOptions{
48+
opts := &secret_model.FindSecretsOptions{
4649
OwnerID: ctx.Org.Organization.ID,
4750
ListOptions: utils.GetListOptions(ctx),
4851
}
4952

50-
count, err := secret.CountSecrets(ctx, opts)
53+
count, err := secret_model.CountSecrets(ctx, opts)
5154
if err != nil {
5255
ctx.InternalServerError(err)
5356
return
5457
}
5558

56-
secrets, err := secret.FindSecrets(ctx, *opts)
59+
secrets, err := secret_model.FindSecrets(ctx, *opts)
5760
if err != nil {
5861
ctx.InternalServerError(err)
5962
return
@@ -70,3 +73,43 @@ func listActionsSecrets(ctx *context.APIContext) {
7073
ctx.SetTotalCountHeader(count)
7174
ctx.JSON(http.StatusOK, apiSecrets)
7275
}
76+
77+
// CreateOrgSecret create one secret of the organization
78+
func CreateOrgSecret(ctx *context.APIContext) {
79+
// swagger:operation POST /orgs/{org}/actions/secrets organization createOrgSecret
80+
// ---
81+
// summary: Create a secret in an organization
82+
// consumes:
83+
// - application/json
84+
// produces:
85+
// - application/json
86+
// parameters:
87+
// - name: org
88+
// in: path
89+
// description: name of organization
90+
// type: string
91+
// required: true
92+
// - name: body
93+
// in: body
94+
// schema:
95+
// "$ref": "#/definitions/CreateSecretOption"
96+
// responses:
97+
// "201":
98+
// "$ref": "#/responses/Secret"
99+
// "400":
100+
// "$ref": "#/responses/error"
101+
// "404":
102+
// "$ref": "#/responses/notFound"
103+
// "403":
104+
// "$ref": "#/responses/forbidden"
105+
opt := web.GetForm(ctx).(*api.CreateSecretOption)
106+
s, err := secret_model.InsertEncryptedSecret(
107+
ctx, ctx.Org.Organization.ID, 0, opt.Name, actions.ReserveLineBreakForTextarea(opt.Data),
108+
)
109+
if err != nil {
110+
ctx.Error(http.StatusInternalServerError, "InsertEncryptedSecret", err)
111+
return
112+
}
113+
114+
ctx.JSON(http.StatusCreated, convert.ToSecret(s))
115+
}

routers/api/v1/swagger/action.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ type swaggerResponseSecretList struct {
1111
// in:body
1212
Body []api.Secret `json:"body"`
1313
}
14+
15+
// Secret
16+
// swagger:response Secret
17+
type swaggerResponseSecret struct {
18+
// in:body
19+
Body api.Secret `json:"body"`
20+
}

routers/api/v1/swagger/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,7 @@ type swaggerParameterBodies struct {
187187

188188
// in:body
189189
UpdateRepoAvatarOptions api.UpdateRepoAvatarOption
190+
191+
// in:body
192+
CreateSecretOption api.CreateSecretOption
190193
}

routers/web/repo/actions/view.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,31 +259,35 @@ func ViewPost(ctx *context_module.Context) {
259259
ctx.JSON(http.StatusOK, resp)
260260
}
261261

262-
func RerunOne(ctx *context_module.Context) {
262+
// Rerun will rerun jobs in the given run
263+
// jobIndex = 0 means rerun all jobs
264+
func Rerun(ctx *context_module.Context) {
263265
runIndex := ctx.ParamsInt64("run")
264266
jobIndex := ctx.ParamsInt64("job")
265267

266-
job, _ := getRunJobs(ctx, runIndex, jobIndex)
267-
if ctx.Written() {
268+
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
269+
if err != nil {
270+
ctx.Error(http.StatusInternalServerError, err.Error())
268271
return
269272
}
270273

271-
if err := rerunJob(ctx, job); err != nil {
272-
ctx.Error(http.StatusInternalServerError, err.Error())
274+
// can not rerun job when workflow is disabled
275+
cfgUnit := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions)
276+
cfg := cfgUnit.ActionsConfig()
277+
if cfg.IsWorkflowDisabled(run.WorkflowID) {
278+
ctx.JSONError(ctx.Locale.Tr("actions.workflow.disabled"))
273279
return
274280
}
275281

276-
ctx.JSON(http.StatusOK, struct{}{})
277-
}
278-
279-
func RerunAll(ctx *context_module.Context) {
280-
runIndex := ctx.ParamsInt64("run")
281-
282-
_, jobs := getRunJobs(ctx, runIndex, 0)
282+
job, jobs := getRunJobs(ctx, runIndex, jobIndex)
283283
if ctx.Written() {
284284
return
285285
}
286286

287+
if jobIndex != 0 {
288+
jobs = []*actions_model.ActionRunJob{job}
289+
}
290+
287291
for _, j := range jobs {
288292
if err := rerunJob(ctx, j); err != nil {
289293
ctx.Error(http.StatusInternalServerError, err.Error())

routers/web/web.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,14 +1211,14 @@ func registerRoutes(m *web.Route) {
12111211
m.Combo("").
12121212
Get(actions.View).
12131213
Post(web.Bind(actions.ViewRequest{}), actions.ViewPost)
1214-
m.Post("/rerun", reqRepoActionsWriter, actions.RerunOne)
1214+
m.Post("/rerun", reqRepoActionsWriter, actions.Rerun)
12151215
m.Get("/logs", actions.Logs)
12161216
})
12171217
m.Post("/cancel", reqRepoActionsWriter, actions.Cancel)
12181218
m.Post("/approve", reqRepoActionsWriter, actions.Approve)
12191219
m.Post("/artifacts", actions.ArtifactsView)
12201220
m.Get("/artifacts/{artifact_name}", actions.ArtifactsDownloadView)
1221-
m.Post("/rerun", reqRepoActionsWriter, actions.RerunAll)
1221+
m.Post("/rerun", reqRepoActionsWriter, actions.Rerun)
12221222
})
12231223
}, reqRepoActionsReader, actions.MustEnableActions)
12241224

services/convert/secret.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package convert
5+
6+
import (
7+
secret_model "code.gitea.io/gitea/models/secret"
8+
api "code.gitea.io/gitea/modules/structs"
9+
)
10+
11+
// ToSecret converts Secret to API format
12+
func ToSecret(secret *secret_model.Secret) *api.Secret {
13+
result := &api.Secret{
14+
Name: secret.Name,
15+
}
16+
17+
return result
18+
}

templates/base/head_script.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ If you are customizing Gitea, please do not change this file.
44
If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
55
*/}}
66
<script>
7+
{{/* before our JS code gets loaded, use arrays to store errors, then the arrays will be switched to our error handler later */}}
78
window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
9+
window.addEventListener('unhandledrejection', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
810
window.config = {
911
appUrl: '{{AppUrl}}',
1012
appSubUrl: '{{AppSubUrl}}',

0 commit comments

Comments
 (0)