リモートでリポジトリを作成して複製するタスクを自動化しようとしています。次のコードを実行すると、使用しようとしている方法が非推奨になっている可能性があります。代替方法は何ですか?
from github import Github
import pygit2
name = input("Name of iOS project: ") # repo name
description = input("github description: ") # description
# using username and password establish connection to github
g = Github(username, password)
gituser = g.get_user()
repo = gituser.create_repo(name) #
#create some new files in the repo
repo.create_file("README.md", "init commit", "my description")
#Clone the newly created repo
repoClone = pygit2.clone_repository(repo.git_url, 'https://github.com/scott-lydon/'+name+'.git')
#put the files in the repository here
#Commit it
repoClone.remotes.set_url("origin", repo.clone_url)
index = repoClone.index
index.add_all()
index.write()
author = pygit2.Signature("your name", "your email")
commiter = pygit2.Signature("your name", "your 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(username, password)
remote.credentials = credentials
callbacks=pygit2.RemoteCallbacks(credentials=credentials)
remote.push(['refs/heads/master'],callbacks=callbacks)
出力
Traceback (most recent call last):
File "/Users/---/Python/generateiOSProj/untitled3.py", line 39, in <module>
oid = repoClone.create_commit('refs/heads/master', author, commiter, "init commit",tree,[repoClone.head.get_object().hex])
AttributeError: '_pygit2.Reference' object has no attribute 'get_object'