Skip to content

Commit f35d360

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Protected tag is no internal server error (go-gitea#30962) [skip ci] Updated translations via Crowdin Restyle release list, fix branch dropdown (go-gitea#30837) fix: change npm scope registry (go-gitea#30964) Support using label names when changing issue labels (go-gitea#30943)
2 parents ad89474 + b1d8f13 commit f35d360

File tree

17 files changed

+245
-87
lines changed

17 files changed

+245
-87
lines changed

docs/content/usage/packages/npm.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The following examples use the `npm` tool with the scope `@test`.
3030
To register the package registry you need to configure a new package source.
3131

3232
```shell
33-
npm config set {scope}:registry https://gitea.example.com/api/packages/{owner}/npm/
33+
npm config set {scope}:registry=https://gitea.example.com/api/packages/{owner}/npm/
3434
npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{token}"
3535
```
3636

@@ -43,7 +43,7 @@ npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{t
4343
For example:
4444

4545
```shell
46-
npm config set @test:registry https://gitea.example.com/api/packages/testuser/npm/
46+
npm config set @test:registry=https://gitea.example.com/api/packages/testuser/npm/
4747
npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token"
4848
```
4949

docs/content/usage/packages/npm.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ menu:
3030
要注册软件包注册表,您需要配置一个新的软件包源。
3131

3232
```shell
33-
npm config set {scope}:registry https://gitea.example.com/api/packages/{owner}/npm/
33+
npm config set {scope}:registry=https://gitea.example.com/api/packages/{owner}/npm/
3434
npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{token}"
3535
```
3636

@@ -43,7 +43,7 @@ npm config set -- '//gitea.example.com/api/packages/{owner}/npm/:_authToken' "{t
4343
例如:
4444

4545
```shell
46-
npm config set @test:registry https://gitea.example.com/api/packages/testuser/npm/
46+
npm config set @test:registry=https://gitea.example.com/api/packages/testuser/npm/
4747
npm config set -- '//gitea.example.com/api/packages/testuser/npm/:_authToken' "personal_access_token"
4848
```
4949

models/fixtures/protected_tag.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-
2+
id: 1
3+
repo_id: 4
4+
name_pattern: /v.+/
5+
allowlist_user_i_ds: []
6+
allowlist_team_i_ds: []
7+
created_unix: 1715596037
8+
updated_unix: 1715596037
9+
-
10+
id: 2
11+
repo_id: 1
12+
name_pattern: v-*
13+
allowlist_user_i_ds: []
14+
allowlist_team_i_ds: []
15+
created_unix: 1715596037
16+
updated_unix: 1715596037
17+
-
18+
id: 3
19+
repo_id: 1
20+
name_pattern: v-1.1
21+
allowlist_user_i_ds: [2]
22+
allowlist_team_i_ds: []
23+
created_unix: 1715596037
24+
updated_unix: 1715596037

modules/structs/issue_label.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ type EditLabelOption struct {
4747

4848
// IssueLabelsOption a collection of labels
4949
type IssueLabelsOption struct {
50-
// list of label IDs
51-
Labels []int64 `json:"labels"`
50+
// Labels can be a list of integers representing label IDs
51+
// or a list of strings representing label names
52+
Labels []any `json:"labels"`
5253
}
5354

5455
// LabelTemplate info of a Label template

options/locale/locale_ja-JP.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ search=検索…
164164
type_tooltip=検索タイプ
165165
fuzzy=あいまい
166166
fuzzy_tooltip=検索語におおよそ一致する結果も含めます
167+
exact=完全一致
168+
exact_tooltip=検索語と完全に一致する結果だけを含めます
167169
repo_kind=リポジトリを検索...
168170
user_kind=ユーザーを検索...
169171
org_kind=組織を検索...
@@ -177,6 +179,8 @@ branch_kind=ブランチを検索...
177179
commit_kind=コミットを検索...
178180
runner_kind=ランナーを検索...
179181
no_results=一致する結果が見つかりませんでした
182+
issue_kind=イシューを検索...
183+
pull_kind=プルリクエストを検索...
180184
keyword_search_unavailable=キーワード検索は現在利用できません。 サイト管理者にお問い合わせください。
181185

182186
[aria]
@@ -883,6 +887,7 @@ repo_and_org_access=リポジトリと組織へのアクセス
883887
permissions_public_only=公開のみ
884888
permissions_access_all=すべて (公開、プライベート、限定)
885889
select_permissions=許可の選択
890+
permission_not_set=設定なし
886891
permission_no_access=アクセス不可
887892
permission_read=読み取り
888893
permission_write=読み取りと書き込み
@@ -2093,6 +2098,7 @@ settings.advanced_settings=拡張設定
20932098
settings.wiki_desc=Wikiを有効にする
20942099
settings.use_internal_wiki=ビルトインのWikiを使用する
20952100
settings.default_wiki_branch_name=デフォルトのWikiブランチ名
2101+
settings.default_wiki_everyone_access=サインインユーザーのデフォルトのアクセス権限:
20962102
settings.failed_to_change_default_wiki_branch=デフォルトのWikiブランチを変更できませんでした。
20972103
settings.use_external_wiki=外部のWikiを使用する
20982104
settings.external_wiki_url=外部WikiのURL
@@ -3486,6 +3492,7 @@ npm.install=npm を使用してパッケージをインストールするには
34863492
npm.install2=または package.json ファイルに追加します:
34873493
npm.dependencies=依存関係
34883494
npm.dependencies.development=開発用依存関係
3495+
npm.dependencies.bundle=バンドルされた依存関係
34893496
npm.dependencies.peer=Peer依存関係
34903497
npm.dependencies.optional=オプションの依存関係
34913498
npm.details.tag=タグ

routers/api/v1/repo/issue_label.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
package repo
66

77
import (
8+
"fmt"
89
"net/http"
10+
"reflect"
911

1012
issues_model "code.gitea.io/gitea/models/issues"
1113
api "code.gitea.io/gitea/modules/structs"
@@ -317,7 +319,32 @@ func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption)
317319
return nil, nil, err
318320
}
319321

320-
labels, err := issues_model.GetLabelsByIDs(ctx, form.Labels, "id", "repo_id", "org_id", "name", "exclusive")
322+
var (
323+
labelIDs []int64
324+
labelNames []string
325+
)
326+
for _, label := range form.Labels {
327+
rv := reflect.ValueOf(label)
328+
switch rv.Kind() {
329+
case reflect.Float64:
330+
labelIDs = append(labelIDs, int64(rv.Float()))
331+
case reflect.String:
332+
labelNames = append(labelNames, rv.String())
333+
}
334+
}
335+
if len(labelIDs) > 0 && len(labelNames) > 0 {
336+
ctx.Error(http.StatusBadRequest, "InvalidLabels", "labels should be an array of strings or integers")
337+
return nil, nil, fmt.Errorf("invalid labels")
338+
}
339+
if len(labelNames) > 0 {
340+
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, labelNames)
341+
if err != nil {
342+
ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
343+
return nil, nil, err
344+
}
345+
}
346+
347+
labels, err := issues_model.GetLabelsByIDs(ctx, labelIDs, "id", "repo_id", "org_id", "name", "exclusive")
321348
if err != nil {
322349
ctx.Error(http.StatusInternalServerError, "GetLabelsByIDs", err)
323350
return nil, nil, err

routers/api/v1/repo/release.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ func CreateRelease(ctx *context.APIContext) {
215215
// "$ref": "#/responses/notFound"
216216
// "409":
217217
// "$ref": "#/responses/error"
218+
// "422":
219+
// "$ref": "#/responses/validationError"
220+
218221
form := web.GetForm(ctx).(*api.CreateReleaseOption)
219222
if ctx.Repo.Repository.IsEmpty {
220223
ctx.Error(http.StatusUnprocessableEntity, "RepoIsEmpty", fmt.Errorf("repo is empty"))
@@ -246,6 +249,8 @@ func CreateRelease(ctx *context.APIContext) {
246249
if err := release_service.CreateRelease(ctx.Repo.GitRepo, rel, nil, ""); err != nil {
247250
if repo_model.IsErrReleaseAlreadyExist(err) {
248251
ctx.Error(http.StatusConflict, "ReleaseAlreadyExist", err)
252+
} else if models.IsErrProtectedTagName(err) {
253+
ctx.Error(http.StatusUnprocessableEntity, "ProtectedTagName", err)
249254
} else {
250255
ctx.Error(http.StatusInternalServerError, "CreateRelease", err)
251256
}
@@ -386,8 +391,8 @@ func DeleteRelease(ctx *context.APIContext) {
386391
// "$ref": "#/responses/empty"
387392
// "404":
388393
// "$ref": "#/responses/notFound"
389-
// "405":
390-
// "$ref": "#/responses/empty"
394+
// "422":
395+
// "$ref": "#/responses/validationError"
391396

392397
id := ctx.ParamsInt64(":id")
393398
rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id)
@@ -401,7 +406,7 @@ func DeleteRelease(ctx *context.APIContext) {
401406
}
402407
if err := release_service.DeleteReleaseByID(ctx, ctx.Repo.Repository, rel, ctx.Doer, false); err != nil {
403408
if models.IsErrProtectedTagName(err) {
404-
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
409+
ctx.Error(http.StatusUnprocessableEntity, "delTag", "user not allowed to delete protected tag")
405410
return
406411
}
407412
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)

routers/api/v1/repo/release_tags.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func DeleteReleaseByTag(ctx *context.APIContext) {
9292
// "$ref": "#/responses/empty"
9393
// "404":
9494
// "$ref": "#/responses/notFound"
95-
// "405":
96-
// "$ref": "#/responses/empty"
95+
// "422":
96+
// "$ref": "#/responses/validationError"
9797

9898
tag := ctx.Params(":tag")
9999

@@ -114,7 +114,7 @@ func DeleteReleaseByTag(ctx *context.APIContext) {
114114

115115
if err = releaseservice.DeleteReleaseByID(ctx, ctx.Repo.Repository, release, ctx.Doer, false); err != nil {
116116
if models.IsErrProtectedTagName(err) {
117-
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
117+
ctx.Error(http.StatusUnprocessableEntity, "delTag", "user not allowed to delete protected tag")
118118
return
119119
}
120120
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)

routers/api/v1/repo/tag.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ func CreateTag(ctx *context.APIContext) {
184184
// "$ref": "#/responses/empty"
185185
// "409":
186186
// "$ref": "#/responses/conflict"
187+
// "422":
188+
// "$ref": "#/responses/validationError"
187189
// "423":
188190
// "$ref": "#/responses/repoArchivedError"
189191
form := web.GetForm(ctx).(*api.CreateTagOption)
@@ -205,7 +207,7 @@ func CreateTag(ctx *context.APIContext) {
205207
return
206208
}
207209
if models.IsErrProtectedTagName(err) {
208-
ctx.Error(http.StatusMethodNotAllowed, "CreateNewTag", "user not allowed to create protected tag")
210+
ctx.Error(http.StatusUnprocessableEntity, "CreateNewTag", "user not allowed to create protected tag")
209211
return
210212
}
211213

@@ -253,6 +255,8 @@ func DeleteTag(ctx *context.APIContext) {
253255
// "$ref": "#/responses/empty"
254256
// "409":
255257
// "$ref": "#/responses/conflict"
258+
// "422":
259+
// "$ref": "#/responses/validationError"
256260
// "423":
257261
// "$ref": "#/responses/repoArchivedError"
258262
tagName := ctx.Params("*")
@@ -274,7 +278,7 @@ func DeleteTag(ctx *context.APIContext) {
274278

275279
if err = releaseservice.DeleteReleaseByID(ctx, ctx.Repo.Repository, tag, ctx.Doer, true); err != nil {
276280
if models.IsErrProtectedTagName(err) {
277-
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
281+
ctx.Error(http.StatusUnprocessableEntity, "delTag", "user not allowed to delete protected tag")
278282
return
279283
}
280284
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)

templates/repo/release/list.tmpl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
<ul id="release-list">
88
{{range $idx, $info := .Releases}}
99
{{$release := $info.Release}}
10-
<li class="ui grid">
11-
<div class="ui four wide column meta">
10+
<li class="release-entry">
11+
<div class="meta">
1212
<a class="muted" href="{{if not (and $release.Sha1 ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode))}}#{{else}}{{$.RepoLink}}/src/tag/{{$release.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "tw-mr-1"}}{{$release.TagName}}</a>
1313
{{if and $release.Sha1 ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
1414
<a class="muted tw-font-mono" href="{{$.RepoLink}}/src/commit/{{$release.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha $release.Sha1}}</a>
1515
{{template "repo/branch_dropdown" dict "root" $ "release" $release}}
1616
{{end}}
1717
</div>
18-
<div class="ui twelve wide column detail">
18+
<div class="ui segment detail">
1919
<div class="tw-flex tw-items-center tw-justify-between tw-flex-wrap tw-mb-2">
2020
<h4 class="release-list-title gt-word-break">
21-
{{if $.PageIsSingleTag}}{{$release.Title}}{{else}}<a href="{{$.RepoLink}}/releases/tag/{{$release.TagName | PathEscapeSegments}}">{{$release.Title}}</a>{{end}}
21+
{{if $.PageIsSingleTag}}{{$release.Title}}{{else}}<a class="muted" href="{{$.RepoLink}}/releases/tag/{{$release.TagName | PathEscapeSegments}}">{{$release.Title}}</a>{{end}}
2222
{{template "repo/commit_statuses" dict "Status" $info.CommitStatus "Statuses" $info.CommitStatuses "AdditionalClasses" "tw-flex"}}
2323
{{if $release.IsDraft}}
2424
<span class="ui yellow label">{{ctx.Locale.Tr "repo.release.draft"}}</span>
@@ -62,22 +62,22 @@
6262
</div>
6363
<div class="divider"></div>
6464
<details class="download" {{if eq $idx 0}}open{{end}}>
65-
<summary class="tw-my-4">
65+
<summary>
6666
{{ctx.Locale.Tr "repo.release.downloads"}}
6767
</summary>
6868
<ul class="list">
6969
{{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
7070
<li>
71-
<a class="archive-link" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong></a>
71+
<a class="archive-link" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "download-icon"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong></a>
7272
</li>
7373
<li>
74-
<a class="archive-link" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a>
74+
<a class="archive-link" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "download-icon"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a>
7575
</li>
7676
{{end}}
7777
{{range $release.Attachments}}
7878
<li>
7979
<a target="_blank" rel="nofollow" href="{{.DownloadURL}}" download>
80-
<strong>{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}</strong>
80+
<strong>{{svg "octicon-package" 16 "download-icon"}}{{.Name}}</strong>
8181
</a>
8282
<div>
8383
<span class="text grey">{{.Size | FileSize}}</span>
@@ -89,7 +89,6 @@
8989
{{end}}
9090
</ul>
9191
</details>
92-
<div class="dot"></div>
9392
</div>
9493
</li>
9594
{{end}}

templates/repo/tag/list.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
<tbody class="tag-list">
1717
{{range $idx, $release := .Releases}}
1818
<tr>
19-
<td class="tag">
20-
<h3 class="release-tag-name tw-mb-2">
19+
<td class="tag-list-row">
20+
<h3 class="tag-list-row-title tw-mb-2">
2121
{{if $canReadReleases}}
22-
<a class="tw-flex tw-items-center" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
22+
<a class="tag-list-row-link tw-flex tw-items-center" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
2323
{{else}}
24-
<a class="tw-flex tw-items-center" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
24+
<a class="tag-list-row-link tw-flex tw-items-center" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
2525
{{end}}
2626
</h3>
2727
<div class="download tw-flex tw-items-center">

templates/swagger/v1_json.tmpl

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)