I am trying to write a python script to automatically delete a tag from github. My overall goal is to have a script that can push binaries to a dev release. If the release exists already, I can delete it through the github API. However, making a release also makes a tag, and I need to delete that tag before making a new release. If the tag is not deleted before remaking the release, the release will be listed under the wrong commit, because it will be assigned to the existing tag.
I know that I can delete a tag by running git push --delete origin :tagname
as a subprocess. However, I need to pass it a username+password or authorization key in order to do so. This was my attempt to do so.
proc = subprocess.Popen(['git','push','--delete','origin',tag_name],
stdin=subprocess.PIPE,stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.communicate(access_token()+'\n\n')
However, this fails because while it captures the output of git
, it does not capture the output of git-remote-https
which is launched by git, and so I can't supply the access token. Is there a way to communicate with the subprocess of a subprocess so that I can provide the login details to git?