Skip to content

Commit afc3997

Browse files
committed
chore: improve changelog generator
1 parent 626f7f5 commit afc3997

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

generate-changelog.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
#!/bin/bash
22
# usage: generate-changelog.sh previous_tag next_tag
33
# example: generate-changelog.sh v2.7.2 v2.7.3 > CHANGELOG.new.md
4-
log=$(git log "$1..HEAD" --pretty='format:* [%h](https://github.com/api-platform/core/commit/%H) %s' --no-merges)
4+
lowerbranch=$(git branch --merged HEAD | grep '[[:digit:]]\.[[:digit:]]' | grep -v '*' | sort -rg | head -n 1)
5+
log=$(git log "$1..HEAD" --no-merges --not $lowerbranch --pretty='format:* [%h](https://github.com/api-platform/core/commit/%H) %s')
56

67
diff=$(
78
printf "# Changelog\n\n"
89
printf "## %s\n\n" "$2"
910
10-
if [[ 0 != $(echo "$log" | grep fix | grep -v chore | wc -l) ]];
11+
fixes=$(echo "$log" | grep 'fix(\|fix:')
12+
if [[ 0 != $(echo "$fixes" | wc -l) ]];
1113
then
1214
printf "### Bug fixes\n\n"
13-
printf "$log" | grep fix | grep -v chore | sort
15+
printf "$fixes" | sort
1416
printf "\n\n"
1517
fi
1618
17-
if [[ 0 != $(echo "$log" | grep feat | grep -v chore | wc -l) ]];
19+
feat=$(echo "$log" | grep 'feat(\|feat:')
20+
if [[ 0 != $(echo "$feat" | wc -l) ]];
1821
then
1922
printf "### Features\n\n"
20-
printf "$log" | grep feat | grep -v chore | sort
23+
printf "$feat" | sort
2124
fi
2225
)
2326

0 commit comments

Comments
 (0)