-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo2github.py
More file actions
43 lines (35 loc) · 1.33 KB
/
Copy pathtodo2github.py
File metadata and controls
43 lines (35 loc) · 1.33 KB
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
37
38
39
40
41
42
from distutils.core import setup
import sys
import os
import fnmatch
import re
from github import *
from configs import *
import subprocess
def git(*args):
return subprocess.check_output(['git'] + list(args))
r = git("remote", "show", "origin")
project = re.findall("(?<=\/)(.*)(?=\.git)", r, flags=0)[0]
projectAccount = re.findall("(?<=com:)(.*)(?=\/)", r, flags=0)[0]
gh = GitHub(username=user, password=password)
path = '.'
configfiles = [os.path.join(dirpath, f)
for dirpath, dirnames, files in os.walk(path)
for extension in extensions
for f in fnmatch.filter(files, extension)]
import fileinput
for fileName in configfiles:
count = 0
search = fileinput.input(fileName, inplace = 1)
for line in search: #TODO [GH12]: to
line = line.rstrip() # remove '\n' at end of line
if re.match("(.*)(\#)TODO:(.*)", line):
todoInfo= re.sub("(.*)(\#)TODO:\s","", line)
fileNameShort = re.sub("\.\/","", fileName)
subject = fileNameShort+":"+str(count)+" " + todoInfo
# make url that can link to specific place in file
url = "https://github.com/"+projectAccount + "/" + project + "/blob/master/" + fileNameShort + "#L" + str(count)
r = gh.repos(projectAccount)(project).issues.post(title=subject, body=url)
line = re.sub("(\#)TODO:","#TODO [GH"+str(r.number)+"]:", line)
print(line) #write line back to file
count = count + 1