_pygit2.GitError: reference 'refs/heads/master' not found
Đang mở
Chưa có ai nhận issue này.
support
- 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ả
import pygit2
from github import Github
github_username = "user"
github_password = "password"
github_email = "email"
# login to github and
authenticated_github_user = Github(github_username, github_password)
user = authenticated_github_user.get_user()
is_org: bool = False
# create the new repository
if is_org:
org = authenticated_github_user.get_organization('someorg')
repo = org.create_repo('projectname', description='somedescription')
else:
repo = user.create_repo('testrepo_github_api', description='this is a test')
# clone the repository
repoClone = pygit2.clone_repository(repo.git_url, '/tmp/test_clone')
#create some new files in the repo
repo.create_file("README.md", "init commit", 'readmeText')
# Commit it
repoClone.remotes.set_url("origin", repo.clone_url)
index = repoClone.index
index.add_all()
index.write()
author = pygit2.Signature("Jesus Christ", github_email)
commiter = pygit2.Signature("Jesus Christ", github_email)
tree = index.write_tree()
oid = repoClone.create_commit('refs/heads/master', author, commiter, "init commit", tree, [repoClone.head.get_object().hex])
remote = repoClone.remotes["origin"]
credentials = pygit2.UserPass(github_username, github_password)
remote.credentials = credentials
callbacks = pygit2.RemoteCallbacks(credentials=credentials)
remote.push(['refs/heads/master'], callbacks=callbacks)
This results in
oid = repoClone.create_commit('HEAD', author, commiter, "init commit", tree, [repoClone.head.get_object().hex])
_pygit2.GitError: reference 'refs/heads/master' not found
git show-ref is empty, but this is pretty much expected, no?
This commit and push still go through, but the error is nevertheless thrown.
Am I doing something wrong?
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
Bắt đầu bằng việc tái hiện xung quanh pygit2.clone_repository, repoClone.create_commit và remote.push; kiểm tra trạng thái trống của git show-ref và tham chiếu được truyền vào create_commit. Xác nhận lý do commit và push có vẻ thành công mặc dù có exception được báo cáo, sau đó kiểm tra để bảo đảm cùng script đó hoàn tất mà không có lỗi.
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
- tooling
- 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
- 35/100