Cannot detach head
Đang mở
Chưa có ai nhận issue này.
- 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
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)
subprocess.run(['git', '--no-pager', '--git-dir', repodir, 'log'])
shutil.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
commit fd24ce9e6e104d9a3379bd533d1fc77c7ed4c171 (HEAD -> master, feature)
Author: Test User <testuser@nowhere.net>
Date: Mon Apr 29 18:56:30 2024 +0200
feature commit
commit f46e8132e419552a55edaceda91346b9ebdf2a45
Author: Test User <testuser@nowhere.net>
Date: Mon Apr 29 18:56:30 2024 +0200
master commit
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.
Hướng nghiên cứu
Chạy bản tái hiện Python được cung cấp với các phiên bản pygit2 và libgit2 đã nêu, sau đó kiểm tra hành vi của Repository.head, head_is_detached, lookup_branch và resolve_refish. So sánh các tham chiếu HEAD và branch quan sát được với ngữ nghĩa detached HEAD dự kiến; công việc được xem là hoàn tất khi hành vi được báo cáo đã được sửa hoặc được tài liệu hóa rõ ràng, kèm theo coverage cho bản tái hiện này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- git, python
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100