Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* upstream/main:
  [skip ci] Updated translations via Crowdin
  Update JS deps (go-gitea#23853)
  Added close/open button to details page of milestone (go-gitea#23877)
  Check `IsActionsToken` for LFS authentication (go-gitea#23841)
  Prefill input values in oauth settings as intended (go-gitea#23829)
  Display image size for multiarch container images (go-gitea#23821)
  Use clippie module to copy to clipboard (go-gitea#23801)
  Remove assertion debug code for show/hide refactoring (go-gitea#23576)
  [skip ci] Updated translations via Crowdin
  Remove jQuery ready usage (go-gitea#23858)
  Fix JS error when changing PR's target branch (go-gitea#23862)
  Improve action log display with control chars (go-gitea#23820)
  Fix review conversation reply (go-gitea#23846)
  Improve home page template, fix Sort dropdown menu flash (go-gitea#23856)
  Make first section on home page full width (go-gitea#23854)
  [skip ci] Updated translations via Crowdin
  Fix incorrect CORS failure detection logic (go-gitea#23844)
  • Loading branch information
zjjhot committed Apr 3, 2023
2 parents 9ada9c1 + f020fc2 commit a6741d8
Show file tree
Hide file tree
Showing 36 changed files with 801 additions and 474 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ steps:

# TODO: We should probably build all dependencies into a test image
- name: test-e2e
image: mcr.microsoft.com/playwright:v1.31.2-focal
image: mcr.microsoft.com/playwright:v1.32.1-focal
commands:
- curl -sLO https://go.dev/dl/go1.20.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ rules:
jquery/no-parse-html: [2]
jquery/no-prop: [0]
jquery/no-proxy: [2]
jquery/no-ready: [0]
jquery/no-ready: [2]
jquery/no-serialize: [2]
jquery/no-show: [2]
jquery/no-size: [2]
Expand Down
1 change: 1 addition & 0 deletions .stylelintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ rules:
no-invalid-position-at-import-rule: null
no-irregular-whitespace: true
no-unknown-animations: null
no-unknown-custom-properties: null
number-max-precision: null
property-allowed-list: null
property-disallowed-list: null
Expand Down
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ var migrations = []Migration{
NewMigration("Add version column to action_runner table", v1_20.AddVersionToActionRunner),
// v249 -> v250
NewMigration("Improve Action table indices v3", v1_20.ImproveActionTableIndices),
// v250 -> v251
NewMigration("Change Container Metadata", v1_20.ChangeContainerMetadataMultiArch),
}

// GetCurrentDBVersion returns the current db version
Expand Down
135 changes: 135 additions & 0 deletions models/migrations/v1_20/v250.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_20 //nolint

import (
"strings"

"code.gitea.io/gitea/modules/json"

"xorm.io/xorm"
)

func ChangeContainerMetadataMultiArch(x *xorm.Engine) error {
sess := x.NewSession()
defer sess.Close()

if err := sess.Begin(); err != nil {
return err
}

type PackageVersion struct {
ID int64 `xorm:"pk"`
MetadataJSON string `xorm:"metadata_json"`
}

type PackageBlob struct{}

// Get all relevant packages (manifest list images have a container.manifest.reference property)

var pvs []*PackageVersion
err := sess.
Table("package_version").
Select("id, metadata_json").
Where("id IN (SELECT DISTINCT ref_id FROM package_property WHERE ref_type = 0 AND name = 'container.manifest.reference')").
Find(&pvs)
if err != nil {
return err
}

type MetadataOld struct {
Type string `json:"type"`
IsTagged bool `json:"is_tagged"`
Platform string `json:"platform,omitempty"`
Description string `json:"description,omitempty"`
Authors []string `json:"authors,omitempty"`
Licenses string `json:"license,omitempty"`
ProjectURL string `json:"project_url,omitempty"`
RepositoryURL string `json:"repository_url,omitempty"`
DocumentationURL string `json:"documentation_url,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
ImageLayers []string `json:"layer_creation,omitempty"`
MultiArch map[string]string `json:"multiarch,omitempty"`
}

type Manifest struct {
Platform string `json:"platform"`
Digest string `json:"digest"`
Size int64 `json:"size"`
}

type MetadataNew struct {
Type string `json:"type"`
IsTagged bool `json:"is_tagged"`
Platform string `json:"platform,omitempty"`
Description string `json:"description,omitempty"`
Authors []string `json:"authors,omitempty"`
Licenses string `json:"license,omitempty"`
ProjectURL string `json:"project_url,omitempty"`
RepositoryURL string `json:"repository_url,omitempty"`
DocumentationURL string `json:"documentation_url,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
ImageLayers []string `json:"layer_creation,omitempty"`
Manifests []*Manifest `json:"manifests,omitempty"`
}

for _, pv := range pvs {
var old *MetadataOld
if err := json.Unmarshal([]byte(pv.MetadataJSON), &old); err != nil {
return err
}

// Calculate the size of every contained manifest

manifests := make([]*Manifest, 0, len(old.MultiArch))
for platform, digest := range old.MultiArch {
size, err := sess.
Table("package_blob").
Join("INNER", "package_file", "package_blob.id = package_file.blob_id").
Join("INNER", "package_version pv", "pv.id = package_file.version_id").
Join("INNER", "package_version pv2", "pv2.package_id = pv.package_id").
Where("pv.lower_version = ? AND pv2.id = ?", strings.ToLower(digest), pv.ID).
SumInt(new(PackageBlob), "size")
if err != nil {
return err
}

manifests = append(manifests, &Manifest{
Platform: platform,
Digest: digest,
Size: size,
})
}

// Convert to new metadata format

new := &MetadataNew{
Type: old.Type,
IsTagged: old.IsTagged,
Platform: old.Platform,
Description: old.Description,
Authors: old.Authors,
Licenses: old.Licenses,
ProjectURL: old.ProjectURL,
RepositoryURL: old.RepositoryURL,
DocumentationURL: old.DocumentationURL,
Labels: old.Labels,
ImageLayers: old.ImageLayers,
Manifests: manifests,
}

metadataJSON, err := json.Marshal(new)
if err != nil {
return err
}

pv.MetadataJSON = string(metadataJSON)

if _, err := sess.ID(pv.ID).Update(pv); err != nil {
return err
}
}

return sess.Commit()
}
8 changes: 7 additions & 1 deletion modules/packages/container/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ type Metadata struct {
DocumentationURL string `json:"documentation_url,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
ImageLayers []string `json:"layer_creation,omitempty"`
MultiArch map[string]string `json:"multiarch,omitempty"`
Manifests []*Manifest `json:"manifests,omitempty"`
}

type Manifest struct {
Platform string `json:"platform"`
Digest string `json:"digest"`
Size int64 `json:"size"`
}

// ParseImageConfig parses the metadata of an image config
Expand Down
2 changes: 1 addition & 1 deletion modules/packages/container/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestParseImageConfig(t *testing.T) {
},
metadata.Labels,
)
assert.Empty(t, metadata.MultiArch)
assert.Empty(t, metadata.Manifests)

configHelm := `{"description":"` + description + `", "home": "` + projectURL + `", "sources": ["` + repositoryURL + `"], "maintainers":[{"name":"` + author + `"}]}`

Expand Down
10 changes: 5 additions & 5 deletions modules/public/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ func AssetsHandlerFunc(opts *Options) http.HandlerFunc {
return
}

var corsSent bool
if opts.CorsHandler != nil {
var corsSent bool
opts.CorsHandler(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
corsSent = true
})).ServeHTTP(resp, req)
}
// If CORS is not sent, the response must have been written by other handlers
if !corsSent {
return
// If CORS is not sent, the response must have been written by other handlers
if !corsSent {
return
}
}

file := req.URL.Path[len(opts.Prefix):]
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ issues.add_remove_labels=a ajouté %s et supprimé les étiquettes %s %s
issues.add_milestone_at=`a ajouté cela au jalon <b>%s</b> %s`
issues.add_project_at=`a ajouté au projet <b>%s</b> %s`
issues.change_milestone_at=`a modifié le jalon de <b>%s</b> à <b>%s</b> %s`
issues.change_project_at=`modification du projet de <b>%s</b> à <b>%s</b> %s`
issues.change_project_at=modification du projet de <b>%s</b> à <b>%s</b> %s
issues.remove_milestone_at=`a supprimé cela du jalon <b>%s</b> %s`
issues.remove_project_at=`supprimer du projet <b>%s</b> %s`
issues.deleted_milestone=`(supprimée)`
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_pl-PL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ issues.del_time=Usuń ten dziennik czasu
issues.add_time_short=Dodaj czas
issues.add_time_cancel=Anuluj
issues.add_time_history=`dodał(-a) spędzony czas %s`
issues.del_time_history=`usunął(-ęła) spędzony czas %s'
issues.del_time_history=usunął(-ęła) spędzony czas %s
issues.add_time_hours=Godziny
issues.add_time_minutes=Minuty
issues.add_time_sum_to_small=Czas nie został wprowadzony.
Expand Down
12 changes: 8 additions & 4 deletions options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2140,10 +2140,10 @@ settings.dismiss_stale_approvals_desc=Quando novos cometimentos que mudam o cont
settings.require_signed_commits=Exigir cometimentos assinados
settings.require_signed_commits_desc=Rejeitar envios para este ramo que não estejam assinados ou que não sejam validáveis.
settings.protect_branch_name_pattern=Padrão do nome do ramo protegido
settings.protect_protected_file_patterns=`Padrões de ficheiros protegidos (separados com ponto e vírgula ' ;'):`
settings.protect_protected_file_patterns_desc=`Não é permitido alterar imediatamente ficheiros protegidos, mesmo que o utilizador tenha autorização para adicionar, editar ou eliminar ficheiros neste ramo. Podem ser usados múltiplos padrões separados por ponto e vírgula (' ;'). See <a href="https://pkg.go.dev/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.`
settings.protect_unprotected_file_patterns=`Padrões de ficheiros desprotegidos (separados com ponto e vírgula ' ;'):`
settings.protect_unprotected_file_patterns_desc=`Ficheiros desprotegidos que é permitido alterar imediatamente se o utilizador tiver permissão de escrita, passando ao lado da restrição no envio. Podem ser usados múltiplos padrões separados por ponto e vírgula (' ;'). See <a href="https://pkg.go.dev/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.`
settings.protect_protected_file_patterns=Padrões de ficheiros protegidos (separados com ponto e vírgula ';'):
settings.protect_protected_file_patterns_desc=Ficheiros protegidos não podem ser modificados imediatamente, mesmo que o utilizador tenha direitos para adicionar, editar ou eliminar ficheiros neste ramo. Múltiplos padrões podem ser separados com ponto e vírgula (';'). Veja a documentação em <a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a> para ver a sintaxe. Exemplos: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.
settings.protect_unprotected_file_patterns=Padrões de ficheiros desprotegidos (separados com ponto e vírgula ';'):
settings.protect_unprotected_file_patterns_desc=Ficheiros desprotegidos que podem ser modificados imediatamente se o utilizador tiver direitos de escrita, contornando a restrição no envio. Múltiplos padrões podem ser separados com ponto e vírgula (';'). Veja a documentação em <a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a> para ver a sintaxe. Exemplos: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.
settings.add_protected_branch=Habilitar salvaguarda
settings.delete_protected_branch=Desabilitar salvaguarda
settings.update_protect_branch_success=A salvaguarda do ramo '%s' foi modificada.
Expand Down Expand Up @@ -2280,6 +2280,8 @@ diff.image.side_by_side=Lado a Lado
diff.image.swipe=Deslizar
diff.image.overlay=Sobrepor
diff.has_escaped=Esta linha tem caracteres unicode escondidos
diff.show_file_tree=Mostrar árvore de ficheiros
diff.hide_file_tree=Esconder árvore de ficheiros

releases.desc=Acompanhe as versões e as descargas do repositório.
release.releases=Lançamentos
Expand All @@ -2293,6 +2295,7 @@ release.compare=Comparar
release.edit=editar
release.ahead.commits=<strong>%d</strong> cometimentos
release.ahead.target=para %s desde este lançamento
tag.ahead.target=para o ramo %s desde esta etiqueta
release.source_code=Código fonte
release.new_subheader=Lançamentos organizam as versões do trabalho.
release.edit_subheader=Lançamentos organizam as versões do trabalho.
Expand Down Expand Up @@ -3364,6 +3367,7 @@ runners.status.idle=Parada
runners.status.active=Em funcionamento
runners.status.offline=Desconectada
runners.version=Versão
runners.reset_registration_token_success=O código de incrição do executor foi reposto com sucesso

runs.all_workflows=Todas as sequências de trabalho
runs.open_tab=%d abertas
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_tr-TR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ issues.add_remove_labels=%s ekleme ve %s kaldırma işlemlerini %s yaptı
issues.add_milestone_at=`%[2]s <b>%[1]s</b> kilometre taşına ekledi`
issues.add_project_at=`bunu %s projesine <b>%s</b> ekledi`
issues.change_milestone_at=`%s kilometre taşını <b>%s</b> iken <b>%s</b> olarak değiştirdi`
issues.change_project_at=`%s <b>%s</b> olan projeyi <b>%s</b> olarak değiştirdi
issues.change_project_at=%s <b>%s</b> olan projeyi <b>%s</b> olarak değiştirdi
issues.remove_milestone_at=`%[2]s <b>%[1]s</b> kilometre taşından kaldırdı`
issues.remove_project_at=`bunu %s projesinden <b>%s</b> kaldırdı`
issues.deleted_milestone=`(silindi)`
Expand Down
17 changes: 13 additions & 4 deletions options/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ release=版本发布
releases=版本发布
tag=Git标签
released_this=发布
tagged_this=已标记
file.title=%s 位于 %s
file_raw=原始文件
file_history=文件历史
Expand Down Expand Up @@ -1276,6 +1277,7 @@ issues.choose.blank=默认模板
issues.choose.blank_about=从默认模板创建一个工单。
issues.choose.ignore_invalid_templates=已忽略无效模板
issues.choose.invalid_templates=发现了 %v 个无效模板
issues.choose.invalid_config=问题配置包含错误:
issues.no_ref=分支/标记未指定
issues.create=创建工单
issues.new_label=创建标签
Expand Down Expand Up @@ -1489,6 +1491,9 @@ issues.due_date_invalid=到期日期无效或超出范围。请使用 'yyyy-mm-d
issues.dependency.title=依赖工单
issues.dependency.issue_no_dependencies=没有设置依赖项。
issues.dependency.pr_no_dependencies=没有设置依赖项。
issues.dependency.no_permission_1=您没有读取 %d 依赖关系的权限
issues.dependency.no_permission_n=您没有读取 %d 依赖关系的权限
issues.dependency.no_permission.can_remove=您没有读取此依赖关系的权限,但可以删除此依赖关系
issues.dependency.add=添加依赖工单...
issues.dependency.cancel=取消
issues.dependency.remove=删除
Expand Down Expand Up @@ -2135,10 +2140,10 @@ settings.dismiss_stale_approvals_desc=当新的提交更改合并请求内容被
settings.require_signed_commits=需要签名提交
settings.require_signed_commits_desc=拒绝推送未签名或无法验证的提交到分支
settings.protect_branch_name_pattern=受保护的分支名称模式
settings.protect_protected_file_patterns=`"受保护的文件模式 (使用分号 '\;' 分隔):" ;'):``
settings.protect_protected_file_patterns_desc=`即使用户有权添加、编辑或删除此分支中的文件,也不允许直接更改受保护的文件。 可以使用分号分隔多个模式(' ;'). See <a href="https://pkg.go.dev/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.`
settings.protect_unprotected_file_patterns=`不受保护的文件模式 (使用分号分隔 ' ;'):`
settings.protect_unprotected_file_patterns_desc=`如果用户有写入权限,则允许直接更改的不受保护的文件,以绕过推送限制。可以使用分号分隔多重模式 (' ;'). See <a href="https://pkg.go.dev/github.com/gobwas/glob#Compile">github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>.`
settings.protect_protected_file_patterns=受保护的文件模式(使用分号 ';' 分隔):
settings.protect_protected_file_patterns_desc=即使用户有权添加、编辑或删除此分支中的文件,也不允许直接更改受保护的文件。 可以使用分号 (';') 分隔多个模式。 见<a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a>文档了解模式语法。例如: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>
settings.protect_unprotected_file_patterns=不受保护的文件模式(使用分号 ';' 分隔):
settings.protect_unprotected_file_patterns_desc=如果用户有写权限,则允许直接更改的不受保护的文件,以绕过推送限制。可以使用分号分隔多个模式 (';')。 见 <a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a> 文档了解模式语法。例如: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>
settings.add_protected_branch=启用保护
settings.delete_protected_branch=禁用保护
settings.update_protect_branch_success=分支 "%s" 的分支保护已更新。
Expand Down Expand Up @@ -2275,6 +2280,8 @@ diff.image.side_by_side=双排
diff.image.swipe=滑动
diff.image.overlay=叠加
diff.has_escaped=这一行有隐藏的 Unicode 字符
diff.show_file_tree=显示文件树
diff.hide_file_tree=隐藏文件树

releases.desc=跟踪项目版本和下载。
release.releases=版本发布
Expand All @@ -2288,6 +2295,7 @@ release.compare=比较
release.edit=编辑
release.ahead.commits=<strong>%d</strong> 次提交
release.ahead.target=在此版本发布后被加入到 %s
tag.ahead.target=自此标签到 %s
release.source_code=源代码
release.new_subheader=版本发布组织项目的版本。
release.edit_subheader=版本发布组织项目的版本。
Expand Down Expand Up @@ -3359,6 +3367,7 @@ runners.status.idle=空闲
runners.status.active=激活
runners.status.offline=离线
runners.version=版本
runners.reset_registration_token_success=成功重置运行器注册令牌
runs.all_workflows=所有工作流
runs.open_tab=%d 开启中
Expand Down
Loading

0 comments on commit a6741d8

Please sign in to comment.