0

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?

Eldritch Cheese
  • 1,177
  • 11
  • 21
  • 1
    I suspect you need to arrange for a pty. See http://stackoverflow.com/q/15911290/1256452 and/or http://stackoverflow.com/a/20128598/1256452 – torek Feb 26 '14 at 04:09
  • password/password prompt may be [read/written from/to terminal directly](http://stackoverflow.com/q/20980965/4279) without going through the pipe. As @torek said, you could [allocate pseudo-TTY to capture such output](http://stackoverflow.com/a/12471855/4279) – jfs Feb 26 '14 at 07:05
  • I'd recommend adding a ssh key to the github account in question and either not use a password (keep the key save then!) or unlock it prior to running the script (using a ssh agent) or unlock it in the script (again using an ssh agent) – Sekuraz Mar 05 '17 at 15:50

0 Answers0