Skip to content

Commit a929bc8

Browse files
Merge branch 'main' into rspack
2 parents 4b5b53e + 7a474d1 commit a929bc8

File tree

13 files changed

+84
-23
lines changed

13 files changed

+84
-23
lines changed

cmd/dump.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ func runDump(ctx context.Context, cmd *cli.Command) error {
265265
excludes = append(excludes, setting.LFS.Storage.Path)
266266
excludes = append(excludes, setting.Attachment.Storage.Path)
267267
excludes = append(excludes, setting.Packages.Storage.Path)
268+
excludes = append(excludes, setting.RepoArchive.Storage.Path)
268269
excludes = append(excludes, setting.Log.RootPath)
269270
if err := dumper.AddRecursiveExclude("data", setting.AppDataPath, excludes); err != nil {
270271
fatal("Failed to include data directory: %v", err)

models/asymkey/gpg_key_commit_verification.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type CommitVerification struct {
2525
SigningUser *user_model.User // if Verified, then SigningUser is non-nil
2626
CommittingUser *user_model.User // if Verified, then CommittingUser is non-nil
2727
SigningEmail string
28-
SigningKey *GPGKey
28+
SigningKey *GPGKey // FIXME: need to refactor it to a new name like "SigningGPGKey", it is also used in some templates
2929
SigningSSHKey *PublicKey
3030
TrustStatus string
3131
}

models/asymkey/key_display.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package asymkey
5+
6+
import (
7+
"os"
8+
9+
"code.gitea.io/gitea/modules/git"
10+
"code.gitea.io/gitea/modules/log"
11+
"code.gitea.io/gitea/modules/setting"
12+
)
13+
14+
func GetDisplaySigningKey(key *git.SigningKey) string {
15+
if key == nil || key.Format == "" {
16+
return ""
17+
}
18+
19+
switch key.Format {
20+
case git.SigningKeyFormatOpenPGP:
21+
return key.KeyID
22+
case git.SigningKeyFormatSSH:
23+
content, err := os.ReadFile(key.KeyID)
24+
if err != nil {
25+
log.Error("Unable to read SSH key %s: %v", key.KeyID, err)
26+
return "(Unable to read SSH key)"
27+
}
28+
display, err := CalcFingerprint(string(content))
29+
if err != nil {
30+
log.Error("Unable to calculate fingerprint for SSH key %s: %v", key.KeyID, err)
31+
return "(Unable to calculate fingerprint for SSH key)"
32+
}
33+
return display
34+
}
35+
setting.PanicInDevOrTesting("Unknown signing key format: %s", key.Format)
36+
return "(Unknown key format)"
37+
}

modules/git/key.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33

44
package git
55

6+
import "code.gitea.io/gitea/modules/setting"
7+
68
// Based on https://git-scm.com/docs/git-config#Documentation/git-config.txt-gpgformat
79
const (
810
SigningKeyFormatOpenPGP = "openpgp" // for GPG keys, the expected default of git cli
911
SigningKeyFormatSSH = "ssh"
1012
)
1113

14+
// SigningKey represents an instance key info which will be used to sign git commits.
15+
// FIXME: need to refactor it to a new name, this name conflicts with the variable names for "asymkey.GPGKey" in many places.
1216
type SigningKey struct {
1317
KeyID string
1418
Format string
1519
}
20+
21+
func (s *SigningKey) String() string {
22+
// Do not expose KeyID
23+
// In case the key is a file path and the struct is rendered in a template, then the server path will be exposed.
24+
setting.PanicInDevOrTesting("don't call SigningKey.String() - it exposes the KeyID which might be a local file path")
25+
return "SigningKey:" + s.Format
26+
}

options/locale/locale_ga-IE.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,10 +3729,14 @@ swift.install=Cuir an pacáiste i do <code>chomhad Package.swift</code>:
37293729
swift.install2=agus reáchtáil an t-ordú seo a leanas:
37303730
vagrant.install=Chun bosca Vagrant a chur leis, reáchtáil an t-ordú seo a leanas:
37313731
settings.link=Nasc an pacáiste seo le stóras
3732+
settings.link.description=Má nascann tú pacáiste le stórlann, beidh an pacáiste le feiceáil i liosta pacáistí an stórlainne. Ní féidir ach stórlanna faoin úinéir céanna a nascadh. Má fhágtar an réimse folamh, bainfear an nasc.
37323733
settings.link.select=Roghnaigh Stóras
37333734
settings.link.button=Nuashonraigh Nasc Stórais
37343735
settings.link.success=D'éirigh le nasc an stórais a nuashonrú.
37353736
settings.link.error=Theip ar an nasc stóras a nuashonrú.
3737+
settings.link.repo_not_found=Níor aimsíodh an stóras %s.
3738+
settings.unlink.error=Theip ar nasc an stórais a bhaint.
3739+
settings.unlink.success=Baineadh an nasc chuig an stóras go rathúil.
37363740
settings.delete=Scrios pacáiste
37373741
settings.delete.description=Tá pacáiste a scriosadh buan agus ní féidir é a chur ar ais.
37383742
settings.delete.notice=Tá tú ar tí %s (%s) a scriosadh. Tá an oibríocht seo dochúlaithe, an bhfuil tú cinnte?

options/locale/locale_pt-PT.ini

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,7 +3599,7 @@ no_subscriptions=Sem subscrições
35993599
default_key=Assinado com a chave padrão
36003600
error.extract_sign=Falhou ao extrair a assinatura
36013601
error.generate_hash=Falhou ao gerar o <i>hash</i> do cometimento
3602-
error.no_committer_account=Não existe qualquer conta ligada ao endereço de email de quem cometeu
3602+
error.no_committer_account=Não existe qualquer conta vinculada ao endereço de email de quem cometeu
36033603
error.no_gpg_keys_found=Não foi encontrada uma chave conhecida para esta assinatura, na base de dados
36043604
error.not_signed_commit=Não é um cometimento assinado
36053605
error.failed_retrieval_gpg_keys=Falhou ao obter uma chave ligada à conta de quem cometeu
@@ -3617,7 +3617,7 @@ desc=Gerir pacotes do repositório.
36173617
empty=Ainda não há pacotes.
36183618
no_metadata=Sem metadados.
36193619
empty.documentation=Para obter mais informação sobre o registo de pacotes, veja <a target="_blank" rel="noopener noreferrer" href="%s">a documentação</a>.
3620-
empty.repo=Carregou um pacote mas este não é apresentado aqui? Vá às <a href="%[1]s">configurações do pacote</a> e ligue-o a este repositório.
3620+
empty.repo=Carregou um pacote mas este não é apresentado aqui? Vá às <a href="%[1]s">configurações do pacote</a> e vincule-o a este repositório.
36213621
registry.documentation=Para mais informação sobre o registo %s, veja <a target="_blank" rel="noopener noreferrer" href="%s">a documentação</a>.
36223622
filter.type=Tipo
36233623
filter.type.all=Todos
@@ -3729,10 +3729,14 @@ swift.install=Adicione o pacote no seu ficheiro <code>Package.swift</code>:
37293729
swift.install2=e execute o seguinte comando:
37303730
vagrant.install=Para adicionar uma máquina virtual Vagrant, execute o seguinte comando:
37313731
settings.link=Vincular este pacote a um repositório
3732+
settings.link.description=Se você vincular um pacote a um repositório, o pacote será listado na lista de pacotes do repositório. Apenas os repositórios do mesmo dono podem ser vinculados. Deixar o campo em branco irá remover o vínculo.
37323733
settings.link.select=Escolha o repositório
37333734
settings.link.button=Modificar vínculo ao repositório
3734-
settings.link.success=A ligação ao repositório foi modificada com sucesso.
3735+
settings.link.success=O vínculo ao repositório foi modificado com sucesso.
37353736
settings.link.error=Falhou a modificação do vínculo ao repositório.
3737+
settings.link.repo_not_found=O repositório %s não foi encontrado.
3738+
settings.unlink.error=Falhou a remoção do vínculo ao repositório.
3739+
settings.unlink.success=O vínculo ao repositório foi removido com sucesso.
37363740
settings.delete=Eliminar pacote
37373741
settings.delete.description=Eliminar o pacote é permanente e não pode ser desfeito.
37383742
settings.delete.notice=Está prestes a eliminar %s (%s). Esta operação é irreversível. Tem a certeza?

routers/web/repo/issue_view.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strconv"
1313

1414
activities_model "code.gitea.io/gitea/models/activities"
15+
asymkey_model "code.gitea.io/gitea/models/asymkey"
1516
"code.gitea.io/gitea/models/db"
1617
git_model "code.gitea.io/gitea/models/git"
1718
issues_model "code.gitea.io/gitea/models/issues"
@@ -494,7 +495,7 @@ func preparePullViewSigning(ctx *context.Context, issue *issues_model.Issue) {
494495
if ctx.Doer != nil {
495496
sign, key, _, err := asymkey_service.SignMerge(ctx, pull, ctx.Doer, pull.BaseRepo.RepoPath(), pull.BaseBranch, pull.GetGitHeadRefName())
496497
ctx.Data["WillSign"] = sign
497-
ctx.Data["SigningKey"] = key
498+
ctx.Data["SigningKeyMergeDisplay"] = asymkey_model.GetDisplaySigningKey(key)
498499
if err != nil {
499500
if asymkey_service.IsErrWontSign(err) {
500501
ctx.Data["WontSignReason"] = err.(*asymkey_service.ErrWontSign).Reason

services/context/repo.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"path"
1515
"strings"
1616

17+
asymkey_model "code.gitea.io/gitea/models/asymkey"
1718
"code.gitea.io/gitea/models/db"
1819
git_model "code.gitea.io/gitea/models/git"
1920
issues_model "code.gitea.io/gitea/models/issues"
@@ -99,7 +100,7 @@ type CommitFormOptions struct {
99100
UserCanPush bool
100101
RequireSigned bool
101102
WillSign bool
102-
SigningKey *git.SigningKey
103+
SigningKeyFormDisplay string
103104
WontSignReason string
104105
CanCreatePullRequest bool
105106
CanCreateBasePullRequest bool
@@ -139,7 +140,7 @@ func PrepareCommitFormOptions(ctx *Context, doer *user_model.User, targetRepo *r
139140
protectionRequireSigned = protectedBranch.RequireSignedCommits
140141
}
141142

142-
willSign, signKeyID, _, err := asymkey_service.SignCRUDAction(ctx, targetRepo.RepoPath(), doer, targetRepo.RepoPath(), refName.String())
143+
willSign, signKey, _, err := asymkey_service.SignCRUDAction(ctx, targetRepo.RepoPath(), doer, targetRepo.RepoPath(), refName.String())
143144
wontSignReason := ""
144145
if asymkey_service.IsErrWontSign(err) {
145146
wontSignReason = string(err.(*asymkey_service.ErrWontSign).Reason)
@@ -156,14 +157,14 @@ func PrepareCommitFormOptions(ctx *Context, doer *user_model.User, targetRepo *r
156157
canCreatePullRequest := targetRepo.UnitEnabled(ctx, unit_model.TypePullRequests) || canCreateBasePullRequest
157158

158159
opts := &CommitFormOptions{
159-
TargetRepo: targetRepo,
160-
WillSubmitToFork: submitToForkedRepo,
161-
CanCommitToBranch: canCommitToBranch,
162-
UserCanPush: canPushWithProtection,
163-
RequireSigned: protectionRequireSigned,
164-
WillSign: willSign,
165-
SigningKey: signKeyID,
166-
WontSignReason: wontSignReason,
160+
TargetRepo: targetRepo,
161+
WillSubmitToFork: submitToForkedRepo,
162+
CanCommitToBranch: canCommitToBranch,
163+
UserCanPush: canPushWithProtection,
164+
RequireSigned: protectionRequireSigned,
165+
WillSign: willSign,
166+
SigningKeyFormDisplay: asymkey_model.GetDisplaySigningKey(signKey),
167+
WontSignReason: wontSignReason,
167168

168169
CanCreatePullRequest: canCreatePullRequest,
169170
CanCreateBasePullRequest: canCreateBasePullRequest,

templates/repo/commit_sign_badge.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ so this template should be kept as small as possbile, DO NOT put large component
88
*/}}
99
{{- $commit := $.Commit -}}
1010
{{- $commitBaseLink := $.CommitBaseLink -}}
11-
{{- $verification := $.CommitSignVerification -}}
11+
{{- $verification := $.CommitSignVerification -}}{{- /* asymkey.CommitVerification */ -}}
1212

1313
{{- $extraClass := "" -}}
1414
{{- $verified := false -}}
@@ -50,7 +50,7 @@ so this template should be kept as small as possbile, DO NOT put large component
5050

5151
{{- if $verification.SigningSSHKey -}}
5252
{{- $msgSigningKey = print (ctx.Locale.Tr "repo.commits.ssh_key_fingerprint") ": " $verification.SigningSSHKey.Fingerprint -}}
53-
{{- else if $verification.SigningKey -}}
53+
{{- else if $verification.SigningKey -}}{{- /* asymkey.GPGKey */ -}}
5454
{{- $msgSigningKey = print (ctx.Locale.Tr "repo.commits.gpg_key_id") ": " $verification.SigningKey.PaddedKeyID -}}
5555
{{- end -}}
5656
{{- end -}}

templates/repo/editor/commit_form.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<div class="commit-form-wrapper">
22
{{ctx.AvatarUtils.Avatar .SignedUser 40 "commit-avatar"}}
33
<div class="commit-form avatar-content-left-arrow">
4-
<h3>{{- if .CommitFormOptions.WillSign}}
5-
<span title="{{ctx.Locale.Tr "repo.signing.will_sign" .CommitFormOptions.SigningKey}}">{{svg "octicon-lock" 24}}</span>
4+
<h3>
5+
{{- if .CommitFormOptions.WillSign}}
6+
<span data-tooltip-content="{{ctx.Locale.Tr "repo.signing.will_sign" .CommitFormOptions.SigningKeyFormDisplay}}">{{svg "octicon-lock" 24}}</span>
67
{{ctx.Locale.Tr "repo.editor.commit_signed_changes"}}
78
{{- else}}
89
<span title="{{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .CommitFormOptions.WontSignReason)}}">{{svg "octicon-unlock" 24}}</span>
910
{{ctx.Locale.Tr "repo.editor.commit_changes"}}
10-
{{- end}}</h3>
11+
{{- end}}
12+
</h3>
1113
<div class="field">
1214
<input name="commit_summary" maxlength="100" placeholder="{{if .PageIsDelete}}{{ctx.Locale.Tr "repo.editor.delete" .TreePath}}{{else if .PageIsUpload}}{{ctx.Locale.Tr "repo.editor.upload_files_to_dir" .TreePath}}{{else if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.add_tmpl"}}{{else if .PageIsPatch}}{{ctx.Locale.Tr "repo.editor.patch"}}{{else}}{{ctx.Locale.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus>
1315
</div>

0 commit comments

Comments
 (0)