The use of %b only extract the body of the commit message. When a commit only has one line, the last commit is always empty, because the message only has a subject. Using %B we can match the issue ID all along the message.
In our team, we apply the Conventional Commits Specification, where the use of body in a commit message is optional. Almost all of our regular commit messages are one line and the step is not compatible with them.
You can reproduce the issue making a commit like
git commit -m "fix(AR-252): my description of the changes"
And then run the same command that is used to extract last commit
LAST_COMMIT=$(git log -1 --pretty=format:%b)
LAST_COMMIT will be empty. If we change the %b to %B we can catch this kind of cases, and we are still compatible with the rest of the commits that have subject and body.
The use of
%b
only extract the body of the commit message. When a commit only has one line, the last commit is always empty, because the message only has a subject. Using %B we can match the issue ID all along the message. In our team, we apply the Conventional Commits Specification, where the use of body in a commit message is optional. Almost all of our regular commit messages are one line and the step is not compatible with them.You can reproduce the issue making a commit like
git commit -m "fix(AR-252): my description of the changes"
And then run the same command that is used to extract last commit
LAST_COMMIT=$(git log -1 --pretty=format:%b)
LAST_COMMIT will be empty. If we change the
%b
to%B
we can catch this kind of cases, and we are still compatible with the rest of the commits that have subject and body.Pretty formats docs: https://git-scm.com/docs/pretty-formats