From 71a18cad0ee49a57599e42f22090d420640220a5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 4 Jun 2022 21:06:22 +0800 Subject: [PATCH 1/2] Fix GetNote --- modules/git/notes_nogogit.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go index e3f0a3fee9ec..e6919d257d0a 100644 --- a/modules/git/notes_nogogit.go +++ b/modules/git/notes_nogogit.go @@ -44,8 +44,7 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note) tree, err = tree.SubTree(commitID[0:2]) path += commitID[0:2] + "/" commitID = commitID[2:] - } - if err != nil { + } else if err != nil { log.Error("Unable to find git note corresponding to the commit %q. Error: %v", originalCommitID, err) return err } From 8c7498a95fa39c14d9785101f311b17ca164302c Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 4 Jun 2022 18:09:36 +0100 Subject: [PATCH 2/2] Only log errors if the error is not ErrNotExist Signed-off-by: Andrew Thornton --- modules/git/notes_nogogit.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go index e6919d257d0a..1476805dcdc0 100644 --- a/modules/git/notes_nogogit.go +++ b/modules/git/notes_nogogit.go @@ -44,8 +44,12 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note) tree, err = tree.SubTree(commitID[0:2]) path += commitID[0:2] + "/" commitID = commitID[2:] - } else if err != nil { - log.Error("Unable to find git note corresponding to the commit %q. Error: %v", originalCommitID, err) + } + if err != nil { + // Err may have been updated by the SubTree we need to recheck if it's again an ErrNotExist + if !IsErrNotExist(err) { + log.Error("Unable to find git note corresponding to the commit %q. Error: %v", originalCommitID, err) + } return err } }