aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-04-07 19:44:09 +0800
committerGitHub <noreply@github.com>2024-04-07 11:44:09 +0000
commit5a6f7353d35a73da3cf6d10203df66180cb0be53 (patch)
treeb5276681b4b468e03acce433bf643d4863f67ccf /models
parenta29e505c15d7f5ee82f5ccdbd052a50d5ae44e77 (diff)
downloadgitea-5a6f7353d35a73da3cf6d10203df66180cb0be53.tar.gz
gitea-5a6f7353d35a73da3cf6d10203df66180cb0be53.zip
Clean up log messages (#30313) (#30318)
Backport #30313 by wxiaoguang `log.Xxx("%v")` is not ideal, this PR adds necessary context messages. Remove some unnecessary logs. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/asymkey/ssh_key_fingerprint.go17
-rw-r--r--models/repo/issue.go2
2 files changed, 5 insertions, 14 deletions
diff --git a/models/asymkey/ssh_key_fingerprint.go b/models/asymkey/ssh_key_fingerprint.go
index b9cfb1b251..1ed3b5df2a 100644
--- a/models/asymkey/ssh_key_fingerprint.go
+++ b/models/asymkey/ssh_key_fingerprint.go
@@ -76,23 +76,14 @@ func calcFingerprintNative(publicKeyContent string) (string, error) {
// CalcFingerprint calculate public key's fingerprint
func CalcFingerprint(publicKeyContent string) (string, error) {
// Call the method based on configuration
- var (
- fnName, fp string
- err error
- )
- if len(setting.SSH.KeygenPath) == 0 {
- fnName = "calcFingerprintNative"
- fp, err = calcFingerprintNative(publicKeyContent)
- } else {
- fnName = "calcFingerprintSSHKeygen"
- fp, err = calcFingerprintSSHKeygen(publicKeyContent)
- }
+ useNative := setting.SSH.KeygenPath == ""
+ calcFn := util.Iif(useNative, calcFingerprintNative, calcFingerprintSSHKeygen)
+ fp, err := calcFn(publicKeyContent)
if err != nil {
if IsErrKeyUnableVerify(err) {
- log.Info("%s", publicKeyContent)
return "", err
}
- return "", fmt.Errorf("%s: %w", fnName, err)
+ return "", fmt.Errorf("CalcFingerprint(%s): %w", util.Iif(useNative, "native", "ssh-keygen"), err)
}
return fp, nil
}
diff --git a/models/repo/issue.go b/models/repo/issue.go
index 6f6b565a00..0dd4fd5ed4 100644
--- a/models/repo/issue.go
+++ b/models/repo/issue.go
@@ -53,7 +53,7 @@ func (repo *Repository) IsDependenciesEnabled(ctx context.Context) bool {
var u *RepoUnit
var err error
if u, err = repo.GetUnit(ctx, unit.TypeIssues); err != nil {
- log.Trace("%s", err)
+ log.Trace("IsDependenciesEnabled: %v", err)
return setting.Service.DefaultEnableDependencies
}
return u.IssuesConfig().EnableDependencies