Skip to content

Instantly share code, notes, and snippets.

@utisam
Created June 20, 2019 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utisam/1abd2ca30c6b98ae8ad0b2211458985c to your computer and use it in GitHub Desktop.
Save utisam/1abd2ca30c6b98ae8ad0b2211458985c to your computer and use it in GitHub Desktop.
github-tricks
import getpass
import json
import sys
import requests
def main():
username = input('Basic Auth Username: ')
password = getpass.getpass('Basic Auth Password: ')
owner = sys.argv[1]
repository = sys.argv[2]
r = requests.get(
f'https://api.github.com/repos/{owner}/{repository}/pulls',
headers={'Accept': 'application/vnd.github.shadow-cat-preview+json'},
auth=(username, password),
)
assert r.status_code == 200
pulls = r.json()
for pull in pulls:
number = pull['number']
title = pull['title']
if pull['draft'] and 'WIP' not in title:
print(f'Pull Request#{number} ({title}) will be renamed')
r = requests.patch(
f'https://api.github.com/repos/{owner}/{repository}/pulls/{number}',
headers = {'content-type': 'application/json'},
auth=(username, password),
data=json.dumps({'title': '[WIP] ' + title}),
)
assert r.status_code == 200
return 0
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment