From 6e62792199dde7bd761eb12dac7ba77fb2bceea5 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Tue, 31 May 2022 22:40:49 +0300 Subject: [PATCH] pygit2: use obj.size for blobs --- scmrepo/git/backend/pygit2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scmrepo/git/backend/pygit2.py b/scmrepo/git/backend/pygit2.py index aff2d2c4..a668a3c2 100644 --- a/scmrepo/git/backend/pygit2.py +++ b/scmrepo/git/backend/pygit2.py @@ -64,6 +64,9 @@ def mode(self): @cached_property def size(self) -> int: # pylint: disable=invalid-overridden-method + # NOTE: obj.size is currently only available for blobs + if self.obj.type_str == "blob": + return self.obj.size try: return len(self.obj.read_raw()) except KeyError: