From e62cb21ebf5f56bdd7e88d096ba361bdd533e014 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sun, 4 Sep 2022 22:00:10 +0100 Subject: [PATCH 1/2] Stop logging CheckPath returns error: context canceled We should only log CheckPath errors if they are not simply due to context cancellation. Fix #20709 Signed-off-by: Andrew Thornton --- modules/git/repo_attribute.go | 4 ++-- services/gitdiff/gitdiff.go | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index 1305e6f22494e..07290ee625cbd 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -191,8 +191,8 @@ func (c *CheckAttributeReader) Run() error { // CheckPath check attr for given path func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err error) { defer func() { - if err != nil { - log.Error("CheckPath returns error: %v", err) + if err != nil && err != c.ctx.Err() { + log.Error("Unexpected error when checking path %s in %s returns error: %v", path, c.Repo.Path, err) } }() diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 9844992f5b11d..e7362cdcdddcd 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -1178,8 +1178,6 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff } else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" { diffFile.Language = language } - } else { - log.Error("Unexpected error: %v", err) } } From e6d459c8485757d2129b56151579adcb40fcad4b Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 4 Sep 2022 23:07:48 +0100 Subject: [PATCH 2/2] Update modules/git/repo_attribute.go Co-authored-by: delvh --- modules/git/repo_attribute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index 07290ee625cbd..21ff93e498f17 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -192,7 +192,7 @@ func (c *CheckAttributeReader) Run() error { func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err error) { defer func() { if err != nil && err != c.ctx.Err() { - log.Error("Unexpected error when checking path %s in %s returns error: %v", path, c.Repo.Path, err) + log.Error("Unexpected error when checking path %s in %s. Error: %v", path, c.Repo.Path, err) } }()