如何在当前的git托管代码库中列出我所有的TODO消息 [英] How to list all my TODO messages in the current git managed code base

查看:130
本文介绍了如何在当前的git托管代码库中列出我所有的TODO消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望看到只有 的所有TODO评论,并且存在于当前git托管的代码库中。

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名称-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,如果这一行是由我创作,然后打印这些行?

Is there a tool that can search the current code base line-by-line, check if it contains "TODO" and if this line was authored by me and then 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.

这篇关于如何在当前的git托管代码库中列出我所有的TODO消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆