Skip to content

Commit

Permalink
Resolve tags in Commit constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
emlun committed Jan 23, 2024
1 parent 0c53530 commit ce40426
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gitbark/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .objects import RuleData
from .util import cmd

from pygit2 import Commit as _Commit, Tree, Repository as _Repository
from pygit2 import Commit as _Commit, Tree, Repository as _Repository, Tag as _Tag
from typing import Union, Tuple, Optional
import yaml
import re
Expand Down Expand Up @@ -72,7 +72,9 @@ def __init__(self, hash: bytes, repo: "Repository") -> None:
if not isinstance(hash, bytes):
raise ValueError(f"Commit hash is not bytes {hash}")
self._object: _Commit = repo._object.get(hash.hex())
if not isinstance(self._object, _Commit):
if isinstance(self._object, _Tag):
self._object = self._object.get_object()
if not isinstance(self._object, (_Commit, _Tag)):
raise ValueError(f"No commit found with hash {hash.hex()}")

@property
Expand Down

0 comments on commit ce40426

Please sign in to comment.