简体   繁体   中英

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 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

The following commands are used in these two steps:

Step 1: Finding all the release tag:

git tag --sort=refname

Step 2: Finding commit information for each tag:

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. 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 . By default show would include a diff of each commit (from its parent), but you can suppress that with --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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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