Skip to content

Commit 1f804d3

Browse files
authored
Stop logging CheckPath returns error: context canceled (#21064) (#21405)
Backport #21064 We should only log CheckPath errors if they are not simply due to context cancellation - and we should add a little more context to the error message. Fix #20709 Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andrew Thornton <[email protected]>
1 parent c83a05f commit 1f804d3

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

modules/git/repo_attribute.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ func (c *CheckAttributeReader) Run() error {
191191
// CheckPath check attr for given path
192192
func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err error) {
193193
defer func() {
194-
if err != nil {
195-
log.Error("CheckPath returns error: %v", err)
194+
if err != nil && err != c.ctx.Err() {
195+
log.Error("Unexpected error when checking path %s in %s. Error: %v", path, c.Repo.Path, err)
196196
}
197197
}()
198198

services/gitdiff/gitdiff.go

-2
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,6 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
14481448
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
14491449
diffFile.Language = language
14501450
}
1451-
} else {
1452-
log.Error("Unexpected error: %v", err)
14531451
}
14541452
}
14551453

0 commit comments

Comments
 (0)