I'm currently running the following python script. The intention is to be able to automatically create a PR.
if new_repo != None: #if there are files within the repo
current = new_repo.create_head(new_branch)
new_repo.git.checkout(current)
new_repo.git.rm('file.yml') #remove the file
print("deleting file")
new_repo.git.commit("-m",'deleting file') #apply a commit message
print("changes are being commited")
new_repo.git.push('--set-upstream', new_repo.remote().name, new_branch) #set an upstream for the branch to remote
print("changes are being pushed")
new_repo.create_pull(title="deleting file", body="just a line to test", head=new_branch, base="master")
The code is working up until I try to create a PR. I end up with the following error:
AttributeError: 'Repo' object has no attribute 'create_pull'
Currently I am using python3 and it's version is Python 3.8.2. I'm unsure about the version on pygithub. I know I have installed it because when I run pip3 install pygithub
I get the following output:
Requirement already satisfied: pygithub in /usr/local/lib/python3.9/site-packages (1.55) Requirement already satisfied: requests>=2.14.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (2.25.1) Requirement already satisfied: pynacl>=1.4.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (1.4.0) Requirement already satisfied: deprecated in /usr/local/lib/python3.9/site-packages (from pygithub) (1.2.12) Requirement already satisfied: pyjwt>=2.0 in /usr/local/lib/python3.9/site-packages (from pygithub) (2.1.0) Requirement already satisfied: cffi>=1.4.1 in /usr/local/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub) (1.14.4) Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub) (1.15.0) Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.4.1->pynacl>=1.4.0->pygithub) (2.20) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (2021.5.30) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (1.26.6) Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (4.0.0) Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.14.0->pygithub) (2.10) Requirement already satisfied: wrapt<2,>=1.10 in ./Library/Python/3.9/lib/python/site-packages (from deprecated->pygithub) (1.12.1)
Is there something that I am missing with my troubleshooting? Is the code incorrect? As far as I know, I've been looking at the following SO postand this PyGithub post.
Could someone help me out? If someone could provide an explanation as well that'll be amazing.
Thanks!