GIT:按作者组筛选日志 [英] GIT: filter log by group of authors

查看:248
本文介绍了GIT:按作者组筛选日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们公司分成小组,我们在将代码发送给QA人员之前,先进行代码审查。

通常,我们所触及的任何代码都是由(A),但在某些情况下,我们也需要触摸另一个团队的代码(B)。

对于这些情况,代码审查应该是双重的:其中一部分由A组审核,另一部分由B组审核



我们的问题在于A组多次不发送代码将被B队审查,这导致B队不知道这个新的代码。

我想要做的是定期运行一个脚本在代码的某些部分(通常是我们团队处理的模块的子目录)中发现任何不属于我们团队的人的提交,但不幸的是 - 不是 git log 中的$ c>参数似乎不适用于 - author ,所以我不能愉快地运行 git log --not --authorJ ohn--authorPaul--authorRingo模块/ A模块/ B模块/ C



例如列出所有提交触摸模块/ A,模块/ B或模块/ C由不是约翰,保罗或Ringo的人完成



有没有办法使用官方工具来做到这一点?我也会对一个开放源代码脚本感兴趣,如果这意味着这样做的结果是一个单行或接近的结果。

解决方案

<编辑:这应该显示提交作者名称不包含约翰保罗或Ringo。 git log --perl-regexp --author ='^(?!(。*(John)需要使用PCRE构建git。
$ b

|保罗| Ringo)))



我会留下以前的变体,因为它们仍然可能有用:






如果您的git是使用PCRE支持编译的,那么您应该可以使用负面的后置断言。这样的事情应该做你想做的:



git log --perl-regexp --author ='(?<!(john |请注意,正则表达式实际上是寻找 @ 获得这个名称的工作将会更有效率,因为没有一个方便的方法可以找到一个没有被排除的名字的锚点。



你可以尝试在作者行的开始处锚定并仅显示不能以 John | Paul | Ringo 开始中间名仍然会显示):
$ b $ g $ git log --perl-regexp --author ='^(?!(John | Paul | Ringo))'


Our company is divided in teams and we perform code reviews before sending our code to the QA guys.

Usually, any code we touch is reviewed by someone inside the same team (A), but in some cases we also need to touch code from another team (B).

For those cases, the code review should be two-fold: one part reviewed by team A, and another part reviewed by team B.

Our problem is that many times the team A does not send the code to be reviewed by team B and this causes team B to be ignorant of this new code.

What I'd like to do is to periodically run a script to find commits inside certain parts of the code (usually subdirectories with modules our team handles) made by any person not belonging to our team, but unfortunately the --not argument in git log does not seem to work with --author so I cannot happily run git log --not --author "John" --author "Paul" --author "Ringo" module/A module/B module/C

My requirement translates to something like "list all commits touching module/A, module/B or module/C done by someone that's not John, Paul or Ringo"

Is there any way to do this using "official" tools? I would be interested in an open-source script too if it means doing this results in a one-liner or close to that.

解决方案

EDIT: This should show commits with author names that do not contain "John" "Paul" or "Ringo". Requires git to be built with PCRE.

git log --perl-regexp --author='^(?!(.*(John|Paul|Ringo)))'

I'll leave previous variants below as they still may be of some use:


You should be able to do it using negative look-behind assertion, if your git is compiled with PCRE support. Something like this should do what you want:

git log --perl-regexp --author='(?<!(john|paul|ringo))@'

Note that the regex is actually looking for @ not preceded by john|paul|ringo. Getting this to work with names will be tricker as there may not be a convenient way to find an 'anchor' that's not preceded by the name you want to exclude.

You can try anchoring off beginning of the author line and show only commits that do not start with John|Paul|Ringo (i.e commits with John as the middle name would still be shown):

git log --perl-regexp --author='^(?!(John|Paul|Ringo))'

这篇关于GIT:按作者组筛选日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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