mirror of
https://github.com/go-gitea/gitea
synced 2025-09-15 05:08:13 +00:00
Fix SSH signing key path will be displayed in the pull request UI (#35381)
Closes #35361 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ type CommitVerification struct {
|
||||
SigningUser *user_model.User // if Verified, then SigningUser is non-nil
|
||||
CommittingUser *user_model.User // if Verified, then CommittingUser is non-nil
|
||||
SigningEmail string
|
||||
SigningKey *GPGKey
|
||||
SigningKey *GPGKey // FIXME: need to refactor it to a new name like "SigningGPGKey", it is also used in some templates
|
||||
SigningSSHKey *PublicKey
|
||||
TrustStatus string
|
||||
}
|
||||
|
37
models/asymkey/key_display.go
Normal file
37
models/asymkey/key_display.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package asymkey
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
func GetDisplaySigningKey(key *git.SigningKey) string {
|
||||
if key == nil || key.Format == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch key.Format {
|
||||
case git.SigningKeyFormatOpenPGP:
|
||||
return key.KeyID
|
||||
case git.SigningKeyFormatSSH:
|
||||
content, err := os.ReadFile(key.KeyID)
|
||||
if err != nil {
|
||||
log.Error("Unable to read SSH key %s: %v", key.KeyID, err)
|
||||
return "(Unable to read SSH key)"
|
||||
}
|
||||
display, err := CalcFingerprint(string(content))
|
||||
if err != nil {
|
||||
log.Error("Unable to calculate fingerprint for SSH key %s: %v", key.KeyID, err)
|
||||
return "(Unable to calculate fingerprint for SSH key)"
|
||||
}
|
||||
return display
|
||||
}
|
||||
setting.PanicInDevOrTesting("Unknown signing key format: %s", key.Format)
|
||||
return "(Unknown key format)"
|
||||
}
|
Reference in New Issue
Block a user