Useless dichotomy between oid and commit
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- git, python
- Lĩnh vực
- developer-experience
Hướng nghiên cứu
Bắt đầu với reproducer và các entry point repo.branches.local.create và resolve_refish được hiển thị trong issue. Theo dõi cách create xử lý đối số commit và cách một Oid được resolve, sau đó xác minh hành vi dự kiến dựa trên TypeError được hiển thị. Hoàn tất có nghĩa là hành vi API đối với một Oid tham chiếu đến một commit được xác định và được bao phủ bằng một kiểm tra hồi quy phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
code
import tempfile
import pygit2
import subprocess
import shutil
import sys
print(f"python: {sys.version}")
print(f"libgit2: {pygit2.LIBGIT2_VERSION}")
print(f"pygit2: {pygit2.__version__}")
repodir = tempfile.mkdtemp()
repo = pygit2.init_repository(repodir, bare=True)
sig = pygit2.Signature('Test User', 'testuser@nowhere.net')
data = 'blah blah master'
tree = repo.TreeBuilder()
tree.insert('file', repo.create_blob(data.encode()), pygit2.GIT_FILEMODE_BLOB)
master_commit_oid = repo.create_commit('HEAD', sig, sig, 'master commit', tree.write(), [])
repo.lookup_branch('master').set_target(master_commit_oid)
print(f"dullahan: {repo.head_is_detached}")
repo.head.set_target(master_commit_oid) # no effect?
print(f"dullahan: {repo.head_is_detached}")
subprocess.run(['cat', repodir + '/HEAD'])
data = 'blah blah feature'
tree = repo.TreeBuilder()
tree.insert('file', repo.create_blob(data.encode()), pygit2.GIT_FILEMODE_BLOB)
feature_commit_oid = repo.create_commit('HEAD', sig, sig, 'feature commit', tree.write(), [master_commit_oid])
feature_commit = repo.resolve_refish(feature_commit_oid.hex)[0] # why is this needed?!
repo.branches.local.create('feature', feature_commit_oid)
subprocess.run(['git', '--no-pager', '--git-dir', repodir, 'log'])
hutil.rmtree(repodir)
output
python: 3.11.8 (main, Feb 29 2024, 12:19:47) [GCC]
libgit2: 1.8.0
pygit2: 1.14.1
dullahan: False
dullahan: False
ref: refs/heads/master
Traceback (most recent call last):
File "/home/hramrach/kbuild/testrepo.py", line 41, in <module>
repo.branches.local.create('feature', feature_commit_oid)
File "/usr/lib64/python3.11/site-packages/pygit2/branches.py", line 78, in create
return self._repository.create_branch(name, commit, force)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument 2 must be _pygit2.Commit, not _pygit2.Oid
Why?!
Clearly the Oid can be deterministically converted to a commit so long as it refers to one. The code already needs to access the on-disk repository and is inspecting the parameter, throwing an exception when it does not like it. Why can't it determine if the Oid refers to a commit, and convert it automatically when it does?
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 408
- Merge trung bình
- 2 ngày 57 phút
- Pull request đã merge (30 ngày)
- 7
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của libgit2/pygit2
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Feature Request: Support app-level temporary config overrides using libgit2's backend supprt Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
-
merge_bases not wrapped Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Tất cả issue của libgit2/pygit2
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·