in sync/commit.py [0:0]
def __init__(self, repo: Repo,
commit: str | Commit | GitPythonCommit | PyGit2Commit | Oid) -> None:
self.repo = repo
self.pygit2_repo = pygit2_get(repo)
self.cinnabar = cinnabar_map.get(repo)
_commit = None
_pygit2_commit = None
if hasattr(commit, "hexsha"):
assert isinstance(commit, GitPythonCommit)
sha1 = commit.hexsha
_commit = commit
elif isinstance(commit, Oid):
sha1 = str(commit)
elif hasattr(commit, "sha1"):
assert isinstance(commit, Commit)
sha1 = commit.sha1
elif isinstance(commit, (bytes, str)):
if isinstance(commit, bytes):
commit_text: str = commit.decode("ascii")
else:
commit_text = commit
commit_obj = self.pygit2_repo.revparse_single(commit_text)
sha1 = str(commit_obj.id)
elif hasattr(commit, "id"):
assert isinstance(commit, PyGit2Commit)
sha1 = commit.id
_pygit2_commit = commit
else:
raise ValueError("Unrecognised commit %r (type %s)" % (commit, type(commit)))
if sha1 not in self.pygit2_repo:
raise ValueError(f"Commit with SHA1 {sha1} not found")
self.sha1: str = sha1
self._commit = _commit
self._pygit2_commit = _pygit2_commit
self._notes: GitNotes | None = None