Files
gitapi/test.py
2025-11-14 22:22:34 +01:00

13 lines
607 B
Python

from gitapi import *
repo = Git.init(r"C:\Users\Kuba\AppData\Local\Temp\git\new")
blob_hash = repo.create_blob(b"testcontent")
tree = [GitFile(33188, "testfile", blob_hash)]
tree_hash = repo.create_tree(tree)
user = GitUser("Hacker123", "hacker123@example.com", datetime.now())
commit_hash = repo.create_commit("testcommit", Tree(tree_hash, tree), user, user, None)
repo.set_unpacked_ref("main", commit_hash)
tag_hash = repo.create_annotated_tag("Test tag", repo.get_object(commit_hash), "test", user)
if tag_hash: repo.set_unpacked_tag("test", tag_hash)
print(blob_hash, tree_hash, commit_hash, tag_hash)