11#! /bin/bash
22# #################################################################################
33#
4- # Extract release notes for the latest version of Harmony CF Annotator service
4+ # 2025-02-20: Extract release notes for the latest version of Harmony Metadata
5+ # Annotator service
6+ # 2025-09-23: Append git commit messages to release notes.
57#
68# #################################################################################
79
@@ -13,13 +15,34 @@ CHANGELOG_FILE="CHANGELOG.md"
1315VERSION_PATTERN=" ^## [\[]v"
1416
1517# # captures url links
16- # # [unreleased]:https://github.com/nasa/harmony-cf-annotator/compare/1.2.0..HEAD
17- # # [v1.2.0]: https://github.com/nasa/harmony-cf-annotator/compare/1.1.0..1.2.0
18- LINK_PATTERN=" ^\[.*\].*releases/tag/.*"
18+ # # [v1.2.0]: https://github.com/nasa/harmony-metadata-annotator/releases/tags/1.2.0
19+ LINK_PATTERN=" ^\[.*\]:.*https://github.com/nasa"
1920
2021# Read the file and extract text between the first two occurrences of the
2122# VERSION_PATTERN
2223result=$( awk " /$VERSION_PATTERN /{c++; if(c==2) exit;} c==1" " $CHANGELOG_FILE " )
2324
25+ # Get all commit messages since the last release (marked with a git tag). If
26+ # there are no tags, get the full commit history of the repository.
27+ if [[ $( git tag) ]]
28+ then
29+ # There are git tags, so get the most recent one
30+ GIT_REF=$( git describe --tags --abbrev=0)
31+ else
32+ # There are not git tags, so get the initial commit of the repository
33+ GIT_REF=$( git rev-list --max-parents=0 HEAD)
34+ fi
35+
36+ # Retrieve the title line of all commit messages since $GIT_REF, filtering out
37+ # those from the pre-commit-ci[bot] author and any containing the string
38+ # "nasa/pre-commit-ci-update-config", which may result from merge commits.
39+ GIT_COMMIT_MESSAGES=$( git log --oneline --format=" %s" --perl-regexp --author=' ^(?!pre-commit-ci\[bot\]).*$' --grep=" nasa\/pre-commit-ci-update-config" --invert-grep ${GIT_REF} ..HEAD)
40+
41+ # Append git commit messages to the release notes:
42+ if [[ ${GIT_COMMIT_MESSAGES} ]]
43+ then
44+ result+=" \n\n## Commits\n\n${GIT_COMMIT_MESSAGES} "
45+ fi
46+
2447# Print the result
25- echo " $result " | grep -v " $VERSION_PATTERN " | grep -v " $LINK_PATTERN "
48+ echo -e " $result " | grep -v " $VERSION_PATTERN " | grep -v " $LINK_PATTERN "
0 commit comments