0

The GNU coding standard requires every conforming source distribution to ship a NEWS file containing a summary of changes. I think this is a good idea (but that does not matter here) and since I am using git I thought it would be great to autogenerate that file. My idea was to use the message of annotated tags (when I create a tag I also write a summary of changes) and put them into this file. However, I did not find a way to access the message in an easy way. I used the following code:

git tag -l -n100 <tag-name>

Which gives me

<tag-name>           Message-Header 1

    - foo
    - bar
    - bla
    - blup

I would like to get the message without <tag-name> and those spaces. For commit messages I can use

git --format='%s %b' <id> # %s = subject, %b = body of commit message

Is there a similar command for the messages of annotated commit tags or is it not meant for such purposes?

4

1 回答 1

0

I finally found out how to do this myself, git for-each-ref --format='...' refs/tags is what I was looking for:

git for-each-ref --sort='-*committerdate' --format \
    'News for %(refname:short):%0a===============%0a%0a%(body)' \
    refs/tags > NEWS

This adds an entry for each git tag into the NEWS file in the following format:

News for <git-tag-name>:
========================

Annotation for the tag

The entries are inversely sorted so that the topmost one is also the most recent.

于 2012-07-23T14:10:23.430 回答