-
Notifications
You must be signed in to change notification settings - Fork 0
/
githubissuesglobal.py
36 lines (32 loc) · 1.2 KB
/
githubissuesglobal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import requests
import subprocess
import re
def getissues():
"""
Gets all git issues in this repository and creates a todo stub to be added to a file.
"""
out = subprocess.Popen("git remote show origin".split(),
stdout=subprocess.PIPE).communicate()[0]
out = str(out.decode('utf8'))
prt = re.findall(r'https://.*', out)
repo = os.path.basename(prt[0])
repo = repo[:-4]
# extract repository name from this folder
request = requests.get("https://api.github.com/repos/dustinknopoff/{}/issues".format(repo),
headers={
'Authorization': 'token '}) # insert oauth token
# get all issues related to this repository
string = ""
for issue in request.json():
# Generate formatted string for use
string += "TODO: {}\n{}\n{}\n".format(
issue['title'], issue['html_url'], issue['body'])
if string != "":
# create txt file holding all templates
with open(os.getcwd() + "/issues.txt", 'w+', encoding='utf8') as f:
f.write(string)
else:
print("This repository has no open issues.")
if __name__ == '__main__':
getissues()