Skylight
Skylight

Reputation: 221

Extract # TODO tags from source code and convert them into Issues on Bitbucket / Github

Some IDE's like PyCharm offer ability to mark parts of source code with # TODO tags with further ability to locate all the tags later on.

Is there any way to convert them into "Issues" after commit was made to Butbucket or Github?

I find it might be very useful to create TODO's on the fly while writing code, so then other contributors may view them on online repository, like Bitbucket.

Bitbucket and Github have a lot of addons or "services", but I couldn't find similar functionality anywhere.

Upvotes: 5

Views: 2108

Answers (3)

Aymen Mouelhi
Aymen Mouelhi

Reputation: 2396

I have created a node module to do exactly what you needed, to adapt it to your usage, you will have to create a package.json file, in which you mention the url of your github repository, and then you will have to create a .fixme-to-issue file and include your github credentials as well as the configuration for the annotations (if the module finds a //TODO, it creates an issue with label todos for example). to install the module:

npm install -g fixme-to-issue

Upvotes: 0

Minhaz
Minhaz

Reputation: 977

There is a cloud based solution called Todofy (https://todofy.org), it lists out all the todos in the repository, and keep tracking its state untill its finished (removed from code). It provides more features like adding deadline, reminders, assigning someone or bringing someone to discussion, labels etc.

Example comment with prettifiers (C++ style comment)

// TODO: something has to be done quickly @deadline: 1 week
// @assign: mebjas @priority: high

It has an option to auto create issue for it in Github.

Upvotes: 3

jmeed
jmeed

Reputation: 1

Here is a pretty strait forward python script. It uses Githubpy to interact with github. It goes through your current directory tree and grabs the given files (in this case *.cpp and *.h). It then goes through each one of those files finds any #TODO and creates a github issue. It then changes that line to be TODO [GH]:

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, ["*.cpp", "*.h")]

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

You can access the who script on my github. https://github.com/jmeed/todo2github

Upvotes: -2

Related Questions