Skip to content

Commit ef8079a

Browse files
authored
Merge branch 'main' into lunny/trunk_action_content
2 parents c5f735a + 166ec1b commit ef8079a

File tree

47 files changed

+1849
-145
lines changed

Some content is hidden

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

47 files changed

+1849
-145
lines changed

cmd/admin_user_create.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ var microcmdUserCreate = &cli.Command{
8181
Name: "restricted",
8282
Usage: "Make a restricted user account",
8383
},
84+
&cli.StringFlag{
85+
Name: "fullname",
86+
Usage: `The full, human-readable name of the user`,
87+
},
8488
},
8589
}
8690

@@ -191,6 +195,7 @@ func runCreateUser(c *cli.Context) error {
191195
Passwd: password,
192196
MustChangePassword: mustChangePassword,
193197
Visibility: visibility,
198+
FullName: c.String("fullname"),
194199
}
195200

196201
overwriteDefault := &user_model.CreateUserOverwriteOptions{

cmd/admin_user_create_test.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ func TestAdminUserCreate(t *testing.T) {
5050
assert.Equal(t, check{IsAdmin: false, MustChangePassword: false}, createCheck("u5", "--must-change-password=false"))
5151
})
5252

53-
createUser := func(name, args string) error {
54-
return app.Run(strings.Fields(fmt.Sprintf("./gitea admin user create --username %s --email %s@gitea.local %s", name, name, args)))
53+
createUser := func(name string, args ...string) error {
54+
return app.Run(append([]string{"./gitea", "admin", "user", "create", "--username", name, "--email", name + "@gitea.local"}, args...))
5555
}
5656

5757
t.Run("UserType", func(t *testing.T) {
5858
reset()
59-
assert.ErrorContains(t, createUser("u", "--user-type invalid"), "invalid user type")
60-
assert.ErrorContains(t, createUser("u", "--user-type bot --password 123"), "can only be set for individual users")
61-
assert.ErrorContains(t, createUser("u", "--user-type bot --must-change-password"), "can only be set for individual users")
59+
assert.ErrorContains(t, createUser("u", "--user-type", "invalid"), "invalid user type")
60+
assert.ErrorContains(t, createUser("u", "--user-type", "bot", "--password", "123"), "can only be set for individual users")
61+
assert.ErrorContains(t, createUser("u", "--user-type", "bot", "--must-change-password"), "can only be set for individual users")
6262

63-
assert.NoError(t, createUser("u", "--user-type bot"))
63+
assert.NoError(t, createUser("u", "--user-type", "bot"))
6464
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{LowerName: "u"})
6565
assert.Equal(t, user_model.UserTypeBot, u.Type)
6666
assert.Empty(t, u.Passwd)
@@ -75,7 +75,7 @@ func TestAdminUserCreate(t *testing.T) {
7575

7676
// using "--access-token" only means "all" access
7777
reset()
78-
assert.NoError(t, createUser("u", "--random-password --access-token"))
78+
assert.NoError(t, createUser("u", "--random-password", "--access-token"))
7979
assert.Equal(t, 1, unittest.GetCount(t, &user_model.User{}))
8080
assert.Equal(t, 1, unittest.GetCount(t, &auth_model.AccessToken{}))
8181
accessToken := unittest.AssertExistsAndLoadBean(t, &auth_model.AccessToken{Name: "gitea-admin"})
@@ -85,7 +85,7 @@ func TestAdminUserCreate(t *testing.T) {
8585

8686
// using "--access-token" with name & scopes
8787
reset()
88-
assert.NoError(t, createUser("u", "--random-password --access-token --access-token-name new-token-name --access-token-scopes read:issue,read:user"))
88+
assert.NoError(t, createUser("u", "--random-password", "--access-token", "--access-token-name", "new-token-name", "--access-token-scopes", "read:issue,read:user"))
8989
assert.Equal(t, 1, unittest.GetCount(t, &user_model.User{}))
9090
assert.Equal(t, 1, unittest.GetCount(t, &auth_model.AccessToken{}))
9191
accessToken = unittest.AssertExistsAndLoadBean(t, &auth_model.AccessToken{Name: "new-token-name"})
@@ -98,23 +98,38 @@ func TestAdminUserCreate(t *testing.T) {
9898

9999
// using "--access-token-name" without "--access-token"
100100
reset()
101-
err = createUser("u", "--random-password --access-token-name new-token-name")
101+
err = createUser("u", "--random-password", "--access-token-name", "new-token-name")
102102
assert.Equal(t, 0, unittest.GetCount(t, &user_model.User{}))
103103
assert.Equal(t, 0, unittest.GetCount(t, &auth_model.AccessToken{}))
104104
assert.ErrorContains(t, err, "access-token-name and access-token-scopes flags are only valid when access-token flag is set")
105105

106106
// using "--access-token-scopes" without "--access-token"
107107
reset()
108-
err = createUser("u", "--random-password --access-token-scopes read:issue")
108+
err = createUser("u", "--random-password", "--access-token-scopes", "read:issue")
109109
assert.Equal(t, 0, unittest.GetCount(t, &user_model.User{}))
110110
assert.Equal(t, 0, unittest.GetCount(t, &auth_model.AccessToken{}))
111111
assert.ErrorContains(t, err, "access-token-name and access-token-scopes flags are only valid when access-token flag is set")
112112

113113
// empty permission
114114
reset()
115-
err = createUser("u", "--random-password --access-token --access-token-scopes public-only")
115+
err = createUser("u", "--random-password", "--access-token", "--access-token-scopes", "public-only")
116116
assert.Equal(t, 0, unittest.GetCount(t, &user_model.User{}))
117117
assert.Equal(t, 0, unittest.GetCount(t, &auth_model.AccessToken{}))
118118
assert.ErrorContains(t, err, "access token does not have any permission")
119119
})
120+
121+
t.Run("UserFields", func(t *testing.T) {
122+
reset()
123+
assert.NoError(t, createUser("u-FullNameWithSpace", "--random-password", "--fullname", "First O'Middle Last"))
124+
unittest.AssertExistsAndLoadBean(t, &user_model.User{
125+
Name: "u-FullNameWithSpace",
126+
LowerName: "u-fullnamewithspace",
127+
FullName: "First O'Middle Last",
128+
129+
})
130+
131+
assert.NoError(t, createUser("u-FullNameEmpty", "--random-password", "--fullname", ""))
132+
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{LowerName: "u-fullnameempty"})
133+
assert.Empty(t, u.FullName)
134+
})
120135
}

models/actions/runner.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/models/shared/types"
1515
user_model "code.gitea.io/gitea/models/user"
1616
"code.gitea.io/gitea/modules/optional"
17+
"code.gitea.io/gitea/modules/setting"
1718
"code.gitea.io/gitea/modules/timeutil"
1819
"code.gitea.io/gitea/modules/translation"
1920
"code.gitea.io/gitea/modules/util"
@@ -123,8 +124,15 @@ func (r *ActionRunner) IsOnline() bool {
123124
return false
124125
}
125126

126-
// Editable checks if the runner is editable by the user
127-
func (r *ActionRunner) Editable(ownerID, repoID int64) bool {
127+
// EditableInContext checks if the runner is editable by the "context" owner/repo
128+
// ownerID == 0 and repoID == 0 means "admin" context, any runner including global runners could be edited
129+
// ownerID == 0 and repoID != 0 means "repo" context, any runner belonging to the given repo could be edited
130+
// ownerID != 0 and repoID == 0 means "owner(org/user)" context, any runner belonging to the given user/org could be edited
131+
// ownerID != 0 and repoID != 0 means "owner" OR "repo" context, legacy behavior, but we should forbid using it
132+
func (r *ActionRunner) EditableInContext(ownerID, repoID int64) bool {
133+
if ownerID != 0 && repoID != 0 {
134+
setting.PanicInDevOrTesting("ownerID and repoID should not be both set")
135+
}
128136
if ownerID == 0 && repoID == 0 {
129137
return true
130138
}
@@ -168,6 +176,12 @@ func init() {
168176
db.RegisterModel(&ActionRunner{})
169177
}
170178

179+
// FindRunnerOptions
180+
// ownerID == 0 and repoID == 0 means any runner including global runners
181+
// repoID != 0 and WithAvailable == false means any runner for the given repo
182+
// repoID != 0 and WithAvailable == true means any runner for the given repo, parent user/org, and global runners
183+
// ownerID != 0 and repoID == 0 and WithAvailable == false means any runner for the given user/org
184+
// ownerID != 0 and repoID == 0 and WithAvailable == true means any runner for the given user/org and global runners
171185
type FindRunnerOptions struct {
172186
db.ListOptions
173187
IDs []int64

models/fixtures/action_runner.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-
2+
id: 34346
3+
name: runner_to_be_deleted-user
4+
uuid: 3EF231BD-FBB7-4E4B-9602-E6F28363EF18
5+
token_hash: 3EF231BD-FBB7-4E4B-9602-E6F28363EF18
6+
version: "1.0.0"
7+
owner_id: 1
8+
repo_id: 0
9+
description: "This runner is going to be deleted"
10+
agent_labels: '["runner_to_be_deleted","linux"]'
11+
-
12+
id: 34347
13+
name: runner_to_be_deleted-org
14+
uuid: 3EF231BD-FBB7-4E4B-9602-E6F28363EF19
15+
token_hash: 3EF231BD-FBB7-4E4B-9602-E6F28363EF19
16+
version: "1.0.0"
17+
owner_id: 3
18+
repo_id: 0
19+
description: "This runner is going to be deleted"
20+
agent_labels: '["runner_to_be_deleted","linux"]'
21+
-
22+
id: 34348
23+
name: runner_to_be_deleted-repo1
24+
uuid: 3EF231BD-FBB7-4E4B-9602-E6F28363EF20
25+
token_hash: 3EF231BD-FBB7-4E4B-9602-E6F28363EF20
26+
version: "1.0.0"
27+
owner_id: 0
28+
repo_id: 1
29+
description: "This runner is going to be deleted"
30+
agent_labels: '["runner_to_be_deleted","linux"]'
31+
-
32+
id: 34349
33+
name: runner_to_be_deleted
34+
uuid: 3EF231BD-FBB7-4E4B-9602-E6F28363EF17
35+
token_hash: 3EF231BD-FBB7-4E4B-9602-E6F28363EF17
36+
version: "1.0.0"
37+
owner_id: 0
38+
repo_id: 0
39+
description: "This runner is going to be deleted"
40+
agent_labels: '["runner_to_be_deleted","linux"]'

models/packages/package_version.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,7 @@ func (opts *PackageSearchOptions) configureOrderBy(e db.Engine) {
279279
default:
280280
e.Desc("package_version.created_unix")
281281
}
282-
283-
// Sort by id for stable order with duplicates in the other field
284-
e.Asc("package_version.id")
282+
e.Desc("package_version.id") // Sort by id for stable order with duplicates in the other field
285283
}
286284

287285
// SearchVersions gets all versions of packages matching the search options

modules/markup/markdown/markdown.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,15 @@ func (r *GlodmarkRender) highlightingRenderer(w util.BufWriter, c highlighting.C
8686
preClasses += " is-loading"
8787
}
8888

89-
err := r.ctx.RenderInternal.FormatWithSafeAttrs(w, `<pre class="%s">`, preClasses)
90-
if err != nil {
91-
return
92-
}
93-
9489
// include language-x class as part of commonmark spec, "chroma" class is used to highlight the code
9590
// the "display" class is used by "js/markup/math.ts" to render the code element as a block
9691
// the "math.ts" strictly depends on the structure: <pre class="code-block is-loading"><code class="language-math display">...</code></pre>
97-
err = r.ctx.RenderInternal.FormatWithSafeAttrs(w, `<code class="chroma language-%s display">`, languageStr)
92+
err := r.ctx.RenderInternal.FormatWithSafeAttrs(w, `<div class="code-block-container code-overflow-scroll"><pre class="%s"><code class="chroma language-%s display">`, preClasses, languageStr)
9893
if err != nil {
9994
return
10095
}
10196
} else {
102-
_, err := w.WriteString("</code></pre>")
97+
_, err := w.WriteString("</code></pre></div>")
10398
if err != nil {
10499
return
105100
}

modules/structs/repo_actions.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,26 @@ type ActionWorkflowJob struct {
133133
// swagger:strfmt date-time
134134
CompletedAt time.Time `json:"completed_at,omitempty"`
135135
}
136+
137+
// ActionRunnerLabel represents a Runner Label
138+
type ActionRunnerLabel struct {
139+
ID int64 `json:"id"`
140+
Name string `json:"name"`
141+
Type string `json:"type"`
142+
}
143+
144+
// ActionRunner represents a Runner
145+
type ActionRunner struct {
146+
ID int64 `json:"id"`
147+
Name string `json:"name"`
148+
Status string `json:"status"`
149+
Busy bool `json:"busy"`
150+
Ephemeral bool `json:"ephemeral"`
151+
Labels []*ActionRunnerLabel `json:"labels"`
152+
}
153+
154+
// ActionRunnersResponse returns Runners
155+
type ActionRunnersResponse struct {
156+
Entries []*ActionRunner `json:"runners"`
157+
TotalCount int64 `json:"total_count"`
158+
}

options/locale/locale_ja-JP.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ files=ファイル
117117

118118
error=エラー
119119
error404=アクセスしようとしたページは<strong>存在しない</strong>か、閲覧が<strong>許可されていません</strong>。
120+
error503=サーバーはリクエストを完了できませんでした。 後でもう一度お試しください。
120121
go_back=戻る
121122
invalid_data=無効なデータ: %v
122123

@@ -730,6 +731,8 @@ public_profile=公開プロフィール
730731
biography_placeholder=自己紹介してください!(Markdownを使うことができます)
731732
location_placeholder=おおよその場所を他の人と共有
732733
profile_desc=あなたのプロフィールが他のユーザーにどのように表示されるかを制御します。あなたのプライマリメールアドレスは、通知、パスワードの回復、WebベースのGit操作に使用されます。
734+
password_username_disabled=ユーザー名の変更は許可されていません。詳細はサイト管理者にお問い合わせください。
735+
password_full_name_disabled=フルネームの変更は許可されていません。詳細はサイト管理者にお問い合わせください。
733736
full_name=フルネーム
734737
website=Webサイト
735738
location=場所
@@ -924,6 +927,9 @@ permission_not_set=設定なし
924927
permission_no_access=アクセス不可
925928
permission_read=読み取り
926929
permission_write=読み取りと書き込み
930+
permission_anonymous_read=匿名の読み込み
931+
permission_everyone_read=全員の読み込み
932+
permission_everyone_write=全員の書き込み
927933
access_token_desc=選択したトークン権限に応じて、関連する<a %s>API</a>ルートのみに許可が制限されます。 詳細は<a %s>ドキュメント</a>を参照してください。
928934
at_least_one_permission=トークンを作成するには、少なくともひとつの許可を選択する必要があります
929935
permissions_list=許可:
@@ -1136,6 +1142,7 @@ transfer.no_permission_to_reject=この移転を拒否する権限がありま
11361142

11371143
desc.private=プライベート
11381144
desc.public=公開
1145+
desc.public_access=公開アクセス
11391146
desc.template=テンプレート
11401147
desc.internal=内部
11411148
desc.archived=アーカイブ
@@ -1544,6 +1551,7 @@ issues.filter_project=プロジェクト
15441551
issues.filter_project_all=すべてのプロジェクト
15451552
issues.filter_project_none=プロジェクトなし
15461553
issues.filter_assignee=担当者
1554+
issues.filter_assignee_no_assignee=担当者なし
15471555
issues.filter_assignee_any_assignee=担当者あり
15481556
issues.filter_poster=作成者
15491557
issues.filter_user_placeholder=ユーザーを検索
@@ -1647,6 +1655,8 @@ issues.label_archived_filter=アーカイブされたラベルを表示
16471655
issues.label_archive_tooltip=アーカイブされたラベルは、ラベルによる検索時のサジェストからデフォルトで除外されます。
16481656
issues.label_exclusive_desc=ラベル名を <code>スコープ/アイテム</code> の形にすることで、他の <code>スコープ/</code> ラベルと排他的になります。
16491657
issues.label_exclusive_warning=イシューやプルリクエストのラベル編集では、競合するスコープ付きラベルは解除されます。
1658+
issues.label_exclusive_order=ソート順
1659+
issues.label_exclusive_order_tooltip=同じスコープ内の排他的なラベルは、この数値順にソートされます。
16501660
issues.label_count=ラベル %d件
16511661
issues.label_open_issues=オープン中のイシュー %d件
16521662
issues.label_edit=編集
@@ -2129,6 +2139,12 @@ contributors.contribution_type.deletions=削除
21292139
settings=設定
21302140
settings.desc=設定では、リポジトリの設定を管理することができます。
21312141
settings.options=リポジトリ
2142+
settings.public_access=公開アクセス
2143+
settings.public_access_desc=外部からの訪問者のアクセス権限について、このリポジトリのデフォルト設定を上書きします。
2144+
settings.public_access.docs.not_set=設定なし: 公開アクセス権限はありません。訪問者の権限は、リポジトリの公開範囲とメンバーの権限に従います。
2145+
settings.public_access.docs.anonymous_read=匿名の読み込み: ログインしていないユーザーは読み取り権限でユニットにアクセスできます。
2146+
settings.public_access.docs.everyone_read=全員の読み込み: すべてのログインユーザーは読み取り権限でユニットにアクセスできます。イシュー/プルリクエストユニットの読み取り権限は、ユーザーが新しいイシュー/プルリクエストを作成できることを意味します。
2147+
settings.public_access.docs.everyone_write=全員の書き込み: すべてのログインユーザーに書き込み権限があります。Wikiユニットのみがこの権限をサポートします。
21322148
settings.collaboration=共同作業者
21332149
settings.collaboration.admin=管理者
21342150
settings.collaboration.write=書き込み
@@ -2719,6 +2735,7 @@ branch.restore_success=ブランチ "%s" を復元しました。
27192735
branch.restore_failed=ブランチ "%s" の復元に失敗しました。
27202736
branch.protected_deletion_failed=ブランチ "%s" は保護されています。 削除できません。
27212737
branch.default_deletion_failed=ブランチ "%s" はデフォルトブランチです。 削除できません。
2738+
branch.default_branch_not_exist=デフォルトブランチ "%s" がありません。
27222739
branch.restore=ブランチ "%s" の復元
27232740
branch.download=ブランチ "%s" をダウンロード
27242741
branch.rename=ブランチ名 "%s" を変更

routers/api/packages/swift/swift.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,24 @@ func DownloadManifest(ctx *context.Context) {
290290
})
291291
}
292292

293-
// https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6
293+
// formFileOptionalReadCloser returns (nil, nil) if the formKey is not present.
294+
func formFileOptionalReadCloser(ctx *context.Context, formKey string) (io.ReadCloser, error) {
295+
multipartFile, _, err := ctx.Req.FormFile(formKey)
296+
if err != nil && !errors.Is(err, http.ErrMissingFile) {
297+
return nil, err
298+
}
299+
if multipartFile != nil {
300+
return multipartFile, nil
301+
}
302+
303+
content := ctx.Req.FormValue(formKey)
304+
if content == "" {
305+
return nil, nil
306+
}
307+
return io.NopCloser(strings.NewReader(content)), nil
308+
}
309+
310+
// UploadPackageFile refers to https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6
294311
func UploadPackageFile(ctx *context.Context) {
295312
packageScope := ctx.PathParam("scope")
296313
packageName := ctx.PathParam("name")
@@ -304,9 +321,9 @@ func UploadPackageFile(ctx *context.Context) {
304321

305322
packageVersion := v.Core().String()
306323

307-
file, _, err := ctx.Req.FormFile("source-archive")
308-
if err != nil {
309-
apiError(ctx, http.StatusBadRequest, err)
324+
file, err := formFileOptionalReadCloser(ctx, "source-archive")
325+
if file == nil || err != nil {
326+
apiError(ctx, http.StatusBadRequest, "unable to read source-archive file")
310327
return
311328
}
312329
defer file.Close()
@@ -318,10 +335,13 @@ func UploadPackageFile(ctx *context.Context) {
318335
}
319336
defer buf.Close()
320337

321-
var mr io.Reader
322-
metadata := ctx.Req.FormValue("metadata")
323-
if metadata != "" {
324-
mr = strings.NewReader(metadata)
338+
mr, err := formFileOptionalReadCloser(ctx, "metadata")
339+
if err != nil {
340+
apiError(ctx, http.StatusBadRequest, "unable to read metadata file")
341+
return
342+
}
343+
if mr != nil {
344+
defer mr.Close()
325345
}
326346

327347
pck, err := swift_module.ParsePackage(buf, buf.Size(), mr)

0 commit comments

Comments
 (0)