简体   繁体   English

如何在单个命令中查找存储库的所有发布标记的提交信息?

[英]How to find commit information for all release tag of a repository in a single command?

I can get the commit information using the git log command in one single line as follows:我可以在一行中使用 git 日志命令获取提交信息,如下所示:

git log --pretty='%H,%an,%ae,%cn,%ce,%cd,%s' --date=format:%Y-%m-%dT%H-%M-%S

However, I want to get the similar information for the commits of the release tags.但是,我想获得发布标签提交的类似信息。 Currently, I can solve this problem using two steps: (1) find all the release tag, and (2) for each release tag (revtag) find the commit information目前,我可以使用两个步骤来解决这个问题:(1)找到所有的发布标签,(2)为每个发布标签(revtag)找到提交信息

The following commands are used in these two steps:在这两个步骤中使用了以下命令:

Step 1: Finding all the release tag:第 1 步:查找所有发布标签:

git tag --sort=refname

Step 2: Finding commit information for each tag:第 2 步:查找每个标签的提交信息:

git log revtag -1 --pretty='%H,%an,%ae,%cn,%ce,%cd,%s' --date=format:%Y-%m-%dT%H-%M-%S

The problem in this approach is that I have to iterate each tag and execute the command at step 2. I want one single git command that can get this job done and print all the commit information for each tag in one single line.这种方法的问题是我必须迭代每个标签并在第 2 步执行命令。我想要一个 git 命令来完成这项工作,并在一行中打印每个标签的所有提交信息。 Is there any way this problem can be solved?有什么办法可以解决这个问题吗?

To get information on individual commits (rather than commits and their history) it's often better to use git show .要获取有关单个提交的信息(而不是提交及其历史记录),通常最好使用git show By default show would include a diff of each commit (from its parent), but you can suppress that with --no-patch .默认情况下, show将包含每个提交的差异(来自其父项),但您可以使用--no-patch抑制它。

So:所以:

git show  --pretty='%H,%an,%ae,%cn,%ce,%cd,%s' --date=format:%Y-%m-%dT%H-%M-%S --tags --no-patch

That may not give the ordering you want.这可能不会给出你想要的顺序。 (I notice you sorted the tags in your first step.) If you're just trying to get them in order that they were released chronologically, I believe --date-order would ensure that. (我注意到您在第一步中对标签进行了排序。)如果您只是想让它们按时间顺序发布,我相信--date-order会确保这一点。

Also, you don't mention this being an issue in your case, but since it often would be: If only some tags are releases, then you can use the --tags=<pattern> notation to select only the correct tags此外,您没有提到这在您的情况下是一个问题,但因为它通常是:如果只有一些标签是发布,那么您可以使用--tags=<pattern>符号 select 仅正确的标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM