Skip to content

Commit

Permalink
fix(git): Silence "file not found" logs
Browse files Browse the repository at this point in the history
When trying to open a file in Git for reading which does not (yet)
exist, Git will print an error message to its stderr. This currently
gets forwarded as ERROR level log message. However, since these errors
are also turned into FileNotFoundError exceptions for proper downstream
handling, the logs are usually harmless (and, in fact, quite
misleading).

This commit changes errors that occur when trying to open a file for
reading to DEBUG level.
  • Loading branch information
Wuestengecko committed Oct 25, 2023
1 parent cb5398e commit ffab485
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion capellambse/filehandler/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,9 @@ def __is_lfs(self, path: pathlib.PurePosixPath) -> bool:
return True

def __open_from_index(self, filename: pathlib.PurePosixPath) -> bytes:
return self._git("cat-file", "blob", f"{self.revision}:{filename}")
return self._git(
"cat-file", "blob", f"{self.revision}:{filename}", silent=True
)

def __open_from_lfs(self, filename: pathlib.PurePosixPath) -> bytes:
lfsinfo = self.__open_from_index(filename)
Expand Down

0 comments on commit ffab485

Please sign in to comment.