Open hramrach opened 2 months ago
import pygit2
from pygit2.enums import FileMode
from pathlib import Path
import tempfile
import shutil
import sys
print(f"python: {sys.version}")
print(f"libgit2: {pygit2.LIBGIT2_VERSION}")
print(f"pygit2: {pygit2.__version__}")
data = {
'longterm': '6.6',
'master': '6.11-rc6',
'stable': '6.10',
}
base = Path(tempfile.mkdtemp())
repo = pygit2.init_repository(base, bare=True)
sig = pygit2.Signature('Test User', 'testuser@nowhere.net')
commit = None
for branch in data:
tree = repo.TreeBuilder()
version = data[branch]
tree.insert('version', repo.create_blob(version.encode()), FileMode.BLOB)
commit = repo[repo.create_commit('HEAD', sig, sig, f'{branch} commit', tree.write(), [commit.oid] if commit else [])]
if branch == 'master':
try:
repo.lookup_branch(branch).set_target(commit)
except pygit2.GitError as e:
print(repr(e))
None
else:
repo.branches.local.create(branch, commit)
shutil.rmtree(base, ignore_errors=True)
python: 3.11.9 (main, Apr 18 2024, 16:44:43) [GCC]
libgit2: 1.8.0
pygit2: 1.14.1
GitError('no error')
Traceback (most recent call last): File "/home/hramrach/kbuild/python/tests/test_branch_graph.py", line 32, in setUp self.repo.lookup_branch(branch).set_target(commit) _pygit2.GitError: no error
???