Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed May 14, 2024
2 parents ad89474 + b1d8f13 commit f35d360
Show file tree
Hide file tree
Showing 17 changed files with 245 additions and 87 deletions.
4 changes: 2 additions & 2 deletions docs/content/usage/packages/npm.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following examples use the `npm` tool with the scope `@test`.
To register the package registry you need to configure a new package source.

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions docs/content/usage/packages/npm.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ menu:
要注册软件包注册表,您需要配置一个新的软件包源。

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

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

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

Expand Down
24 changes: 24 additions & 0 deletions models/fixtures/protected_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-
id: 1
repo_id: 4
name_pattern: /v.+/
allowlist_user_i_ds: []
allowlist_team_i_ds: []
created_unix: 1715596037
updated_unix: 1715596037
-
id: 2
repo_id: 1
name_pattern: v-*
allowlist_user_i_ds: []
allowlist_team_i_ds: []
created_unix: 1715596037
updated_unix: 1715596037
-
id: 3
repo_id: 1
name_pattern: v-1.1
allowlist_user_i_ds: [2]
allowlist_team_i_ds: []
created_unix: 1715596037
updated_unix: 1715596037
5 changes: 3 additions & 2 deletions modules/structs/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type EditLabelOption struct {

// IssueLabelsOption a collection of labels
type IssueLabelsOption struct {
// list of label IDs
Labels []int64 `json:"labels"`
// Labels can be a list of integers representing label IDs
// or a list of strings representing label names
Labels []any `json:"labels"`
}

// LabelTemplate info of a Label template
Expand Down
7 changes: 7 additions & 0 deletions options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ search=検索…
type_tooltip=検索タイプ
fuzzy=あいまい
fuzzy_tooltip=検索語におおよそ一致する結果も含めます
exact=完全一致
exact_tooltip=検索語と完全に一致する結果だけを含めます
repo_kind=リポジトリを検索...
user_kind=ユーザーを検索...
org_kind=組織を検索...
Expand All @@ -177,6 +179,8 @@ branch_kind=ブランチを検索...
commit_kind=コミットを検索...
runner_kind=ランナーを検索...
no_results=一致する結果が見つかりませんでした
issue_kind=イシューを検索...
pull_kind=プルリクエストを検索...
keyword_search_unavailable=キーワード検索は現在利用できません。 サイト管理者にお問い合わせください。

[aria]
Expand Down Expand Up @@ -883,6 +887,7 @@ repo_and_org_access=リポジトリと組織へのアクセス
permissions_public_only=公開のみ
permissions_access_all=すべて (公開、プライベート、限定)
select_permissions=許可の選択
permission_not_set=設定なし
permission_no_access=アクセス不可
permission_read=読み取り
permission_write=読み取りと書き込み
Expand Down Expand Up @@ -2093,6 +2098,7 @@ settings.advanced_settings=拡張設定
settings.wiki_desc=Wikiを有効にする
settings.use_internal_wiki=ビルトインのWikiを使用する
settings.default_wiki_branch_name=デフォルトのWikiブランチ名
settings.default_wiki_everyone_access=サインインユーザーのデフォルトのアクセス権限:
settings.failed_to_change_default_wiki_branch=デフォルトのWikiブランチを変更できませんでした。
settings.use_external_wiki=外部のWikiを使用する
settings.external_wiki_url=外部WikiのURL
Expand Down Expand Up @@ -3486,6 +3492,7 @@ npm.install=npm を使用してパッケージをインストールするには
npm.install2=または package.json ファイルに追加します:
npm.dependencies=依存関係
npm.dependencies.development=開発用依存関係
npm.dependencies.bundle=バンドルされた依存関係
npm.dependencies.peer=Peer依存関係
npm.dependencies.optional=オプションの依存関係
npm.details.tag=タグ
Expand Down
29 changes: 28 additions & 1 deletion routers/api/v1/repo/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package repo

import (
"fmt"
"net/http"
"reflect"

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

labels, err := issues_model.GetLabelsByIDs(ctx, form.Labels, "id", "repo_id", "org_id", "name", "exclusive")
var (
labelIDs []int64
labelNames []string
)
for _, label := range form.Labels {
rv := reflect.ValueOf(label)
switch rv.Kind() {
case reflect.Float64:
labelIDs = append(labelIDs, int64(rv.Float()))
case reflect.String:
labelNames = append(labelNames, rv.String())
}
}
if len(labelIDs) > 0 && len(labelNames) > 0 {
ctx.Error(http.StatusBadRequest, "InvalidLabels", "labels should be an array of strings or integers")
return nil, nil, fmt.Errorf("invalid labels")
}
if len(labelNames) > 0 {
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, labelNames)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
return nil, nil, err
}
}

labels, err := issues_model.GetLabelsByIDs(ctx, labelIDs, "id", "repo_id", "org_id", "name", "exclusive")
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByIDs", err)
return nil, nil, err
Expand Down
11 changes: 8 additions & 3 deletions routers/api/v1/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ func CreateRelease(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
// "409":
// "$ref": "#/responses/error"
// "422":
// "$ref": "#/responses/validationError"

form := web.GetForm(ctx).(*api.CreateReleaseOption)
if ctx.Repo.Repository.IsEmpty {
ctx.Error(http.StatusUnprocessableEntity, "RepoIsEmpty", fmt.Errorf("repo is empty"))
Expand Down Expand Up @@ -246,6 +249,8 @@ func CreateRelease(ctx *context.APIContext) {
if err := release_service.CreateRelease(ctx.Repo.GitRepo, rel, nil, ""); err != nil {
if repo_model.IsErrReleaseAlreadyExist(err) {
ctx.Error(http.StatusConflict, "ReleaseAlreadyExist", err)
} else if models.IsErrProtectedTagName(err) {
ctx.Error(http.StatusUnprocessableEntity, "ProtectedTagName", err)
} else {
ctx.Error(http.StatusInternalServerError, "CreateRelease", err)
}
Expand Down Expand Up @@ -386,8 +391,8 @@ func DeleteRelease(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
// "405":
// "$ref": "#/responses/empty"
// "422":
// "$ref": "#/responses/validationError"

id := ctx.ParamsInt64(":id")
rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id)
Expand All @@ -401,7 +406,7 @@ func DeleteRelease(ctx *context.APIContext) {
}
if err := release_service.DeleteReleaseByID(ctx, ctx.Repo.Repository, rel, ctx.Doer, false); err != nil {
if models.IsErrProtectedTagName(err) {
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
ctx.Error(http.StatusUnprocessableEntity, "delTag", "user not allowed to delete protected tag")
return
}
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)
Expand Down
6 changes: 3 additions & 3 deletions routers/api/v1/repo/release_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func DeleteReleaseByTag(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
// "405":
// "$ref": "#/responses/empty"
// "422":
// "$ref": "#/responses/validationError"

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

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

if err = releaseservice.DeleteReleaseByID(ctx, ctx.Repo.Repository, release, ctx.Doer, false); err != nil {
if models.IsErrProtectedTagName(err) {
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
ctx.Error(http.StatusUnprocessableEntity, "delTag", "user not allowed to delete protected tag")
return
}
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)
Expand Down
8 changes: 6 additions & 2 deletions routers/api/v1/repo/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ func CreateTag(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "409":
// "$ref": "#/responses/conflict"
// "422":
// "$ref": "#/responses/validationError"
// "423":
// "$ref": "#/responses/repoArchivedError"
form := web.GetForm(ctx).(*api.CreateTagOption)
Expand All @@ -205,7 +207,7 @@ func CreateTag(ctx *context.APIContext) {
return
}
if models.IsErrProtectedTagName(err) {
ctx.Error(http.StatusMethodNotAllowed, "CreateNewTag", "user not allowed to create protected tag")
ctx.Error(http.StatusUnprocessableEntity, "CreateNewTag", "user not allowed to create protected tag")
return
}

Expand Down Expand Up @@ -253,6 +255,8 @@ func DeleteTag(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "409":
// "$ref": "#/responses/conflict"
// "422":
// "$ref": "#/responses/validationError"
// "423":
// "$ref": "#/responses/repoArchivedError"
tagName := ctx.Params("*")
Expand All @@ -274,7 +278,7 @@ func DeleteTag(ctx *context.APIContext) {

if err = releaseservice.DeleteReleaseByID(ctx, ctx.Repo.Repository, tag, ctx.Doer, true); err != nil {
if models.IsErrProtectedTagName(err) {
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
ctx.Error(http.StatusUnprocessableEntity, "delTag", "user not allowed to delete protected tag")
return
}
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)
Expand Down
17 changes: 8 additions & 9 deletions templates/repo/release/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<ul id="release-list">
{{range $idx, $info := .Releases}}
{{$release := $info.Release}}
<li class="ui grid">
<div class="ui four wide column meta">
<li class="release-entry">
<div class="meta">
<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>
{{if and $release.Sha1 ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
<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>
{{template "repo/branch_dropdown" dict "root" $ "release" $release}}
{{end}}
</div>
<div class="ui twelve wide column detail">
<div class="ui segment detail">
<div class="tw-flex tw-items-center tw-justify-between tw-flex-wrap tw-mb-2">
<h4 class="release-list-title gt-word-break">
{{if $.PageIsSingleTag}}{{$release.Title}}{{else}}<a href="{{$.RepoLink}}/releases/tag/{{$release.TagName | PathEscapeSegments}}">{{$release.Title}}</a>{{end}}
{{if $.PageIsSingleTag}}{{$release.Title}}{{else}}<a class="muted" href="{{$.RepoLink}}/releases/tag/{{$release.TagName | PathEscapeSegments}}">{{$release.Title}}</a>{{end}}
{{template "repo/commit_statuses" dict "Status" $info.CommitStatus "Statuses" $info.CommitStatuses "AdditionalClasses" "tw-flex"}}
{{if $release.IsDraft}}
<span class="ui yellow label">{{ctx.Locale.Tr "repo.release.draft"}}</span>
Expand Down Expand Up @@ -62,22 +62,22 @@
</div>
<div class="divider"></div>
<details class="download" {{if eq $idx 0}}open{{end}}>
<summary class="tw-my-4">
<summary>
{{ctx.Locale.Tr "repo.release.downloads"}}
</summary>
<ul class="list">
{{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
<li>
<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>
<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>
</li>
<li>
<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>
<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>
</li>
{{end}}
{{range $release.Attachments}}
<li>
<a target="_blank" rel="nofollow" href="{{.DownloadURL}}" download>
<strong>{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}</strong>
<strong>{{svg "octicon-package" 16 "download-icon"}}{{.Name}}</strong>
</a>
<div>
<span class="text grey">{{.Size | FileSize}}</span>
Expand All @@ -89,7 +89,6 @@
{{end}}
</ul>
</details>
<div class="dot"></div>
</div>
</li>
{{end}}
Expand Down
8 changes: 4 additions & 4 deletions templates/repo/tag/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<tbody class="tag-list">
{{range $idx, $release := .Releases}}
<tr>
<td class="tag">
<h3 class="release-tag-name tw-mb-2">
<td class="tag-list-row">
<h3 class="tag-list-row-title tw-mb-2">
{{if $canReadReleases}}
<a class="tw-flex tw-items-center" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
<a class="tag-list-row-link tw-flex tw-items-center" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
{{else}}
<a class="tw-flex tw-items-center" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
<a class="tag-list-row-link tw-flex tw-items-center" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
{{end}}
</h3>
<div class="download tw-flex tw-items-center">
Expand Down
24 changes: 15 additions & 9 deletions templates/swagger/v1_json.tmpl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f35d360

Please sign in to comment.