2013-06-20 76 views
3

某些IDE的PyCharm提供了使用#TODO標記標記部分源代碼的功能,以便以後可以找到所有標記。從源代碼中提取#TODO標記,並將它們轉換爲Bitbucket/Github上的問題

提交到Butbucket或Github後,有什麼辦法將它們轉換成「問題」?

我發現在編寫代碼的同時創建TODO可能非常有用,因此其他貢獻者可以在線存儲庫(如Bitbucket)上查看它們。

Bitbucket和Github有很多插件或「服務」,但我無法在任何地方找到類似的功能。

+0

我很想看到這個。我一直試圖弄清楚,但沒有運氣。你有什麼地方? –

回答

-2

這是一個漂亮的海峽前鋒python腳本。它使用Githubpy與github進行交互。它通過當前的目錄樹並抓取給定的文件(在本例中爲* .cpp和* .h)。然後通過這些文件中的每一個找到任何#TODO並創建一個github問題。然後,它改變了該行是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 

你可以在我的github訪問誰腳本。 https://github.com/jmeed/todo2github

1

有一個名爲Todofy的雲解決方案(https://todofy.org),它列出了存儲庫中的所有待辦事項,並且一直跟蹤其狀態,直到其完成(從代碼中刪除)。它提供瞭如添加截止日期,提醒,指定某人或使別人討論,prettifiers,標籤等

發表的評論示例(C++風格的註釋)

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

它有一個選項來自動創建問題的更多功能它在Github。

0

我已經創建了一個節點模塊來完成你需要的功能,爲了適應你的使用,你將不得不創建一個package.json文件,在其中提到你的github庫的URL,然後你將會必須創建一個.fixme-to-issue文件幷包含您的github憑證以及註釋的配置(如果模塊發現// TODO,則會產生標籤待辦事項的問題)。 安裝模塊:

npm install -g fixme-to-issue 
相關問題