From 621f2fcadb0ed2b3a97dfc28d8cba7190f6b7914 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 17 Aug 2025 00:24:30 +0800 Subject: [PATCH] Skip "parentsigned" check when the repo is empty (#35292) Fix #35280 --- services/asymkey/sign.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/services/asymkey/sign.go b/services/asymkey/sign.go index f94462ea463..2b77fb92dcc 100644 --- a/services/asymkey/sign.go +++ b/services/asymkey/sign.go @@ -290,16 +290,22 @@ Loop: return false, nil, nil, err } defer gitRepo.Close() - commit, err := gitRepo.GetCommit(parentCommit) + isEmpty, err := gitRepo.IsEmpty() if err != nil { return false, nil, nil, err } - if commit.Signature == nil { - return false, nil, nil, &ErrWontSign{parentSigned} - } - verification := ParseCommitWithSignature(ctx, commit) - if !verification.Verified { - return false, nil, nil, &ErrWontSign{parentSigned} + if !isEmpty { + commit, err := gitRepo.GetCommit(parentCommit) + if err != nil { + return false, nil, nil, err + } + if commit.Signature == nil { + return false, nil, nil, &ErrWontSign{parentSigned} + } + verification := ParseCommitWithSignature(ctx, commit) + if !verification.Verified { + return false, nil, nil, &ErrWontSign{parentSigned} + } } } }