Clone the JGit repository using the following command lines:
If you want the exact same output as in this example, reset your master
branch to the following commit, b14a93971837610156e815ae2eee3baaa5b7a44b
:
You are now ready to look through the commit log for commit messages that describe the bugs fixed. First, let's limit the log to only look through the history since the last tag (release). To find the last tag, we can use git describe
:
The preceding output tells us three things:
- The last tag was
v3.1.0.201310021548-r
- The number of commits since the tag were
96
- The current commit in abbreviated form is
b14a939
Now, the log can be parsed from HEAD
to v3.1.0.201310021548-r
. But just running git log 3.1.0.201310021548-r..HEAD
will give us all the 96 commits, and we just want the commits with commit messages that contain "Bug: xxxxxx"
for our release note. The xxxxxx
is an identifier for the bug, for example, a number. We can use the --grep
option with git log
for this purpose: git log --grep "Bug: "
. This will give us all the commits with "Bug: "
in the commit message; all we need now is just to format it to something we can use for our release note.
Let's say we want the release note format to look like the following template:
Our command line so far is as follows:
This gives us all the bug fix commits, but we can format this to a format that is easily parsed with the --pretty
option. First, we will print the abbreviated commit ID %h
, followed by a separator of our choice |
, then the commit subject %s
, (first line of the commit message), followed by a new line %n
, and the body, %b
:
The output of course needs to be parsed, but that's easy with regular Linux tools such as grep
and sed
:
First, we just want the lines that contain "|"
or "Bug: "
:
Then, we replace these with sed
:
The entire command put together gives:
The previous set of commands gives the following output:
Now, we can extract the bug information from the bug tracker and put the preceding code in the release note as well, if necessary.
If we just wanted to extract the bug IDs from the commit messages and didn't care about the commit IDs, we could have just used grep
after the git log
command, still limiting the log to the last tag:
If we just want the commit IDs and their subjects but not the actual bug IDs, we can use the --oneline
feature of git log
combined with the --grep
option: