如何在git存储库中列出我当前的所有TODO消息?
我想查看所有 只有我 编写的并在git管理的当前代码库中存在的TODO注释.
I want to see all TODO comments that only I wrote and that exist in the current code base that is git managed.
到目前为止,正在打印我在完整git历史记录中创建或修改的所有TODO注释:git log -p --author="My name" -S TODO | grep "\+.*TODO"
What I've got so far is printing all TODO comments that I've ever created or modified during the complete git history: git log -p --author="My name" -S TODO | grep "\+.*TODO"
但是这个工具链列出了所有曾经写过的TODO注释,甚至那些我已经解决并因此又从代码中删除的注释.
But this tool chain lists all TODO comments ever written, even those that I've already resolved and thus removed again from code.
什么是合适的工具链,可以逐行搜索当前代码库,检查其中是否包含"TODO",以及该行是否由我创作打印这些行?
What’s a suitable tool chain that can search the current code base line-by-line, check if it contains "TODO" and if this line was authored by me print those lines?
您可以将git blame
与grep结合使用.
You can combine git blame
with grep.
就像这样(不是最好的,但应该可以)
Like this (not the best one, but should work)
git grep -l TODO | xargs -n1 git blame | grep 'Your name' | grep TODO
改进的版本可能将第一个grep发现的行号与git blame
仅显示给定行的功能结合在一起.
Improved versions might combine line numbers found by first grep with git blame
's ability to show only given lines.