2023-08-13 17:05:15 +05:30
|
|
|
## Usage: ./changelog.sh <text>
|
2023-01-06 00:55:59 +05:30
|
|
|
|
2023-08-13 17:05:15 +05:30
|
|
|
TEXT="$1"
|
2023-01-06 00:55:59 +05:30
|
|
|
|
2023-07-08 18:52:26 +05:30
|
|
|
# the link containing the full commit history
|
|
|
|
FULLCHANGELOG=$(echo "$TEXT{@}" | tail -n 1)
|
|
|
|
NEWCONTRIBUTORS=$(echo "$TEXT{@}" | grep 'first contribution')
|
|
|
|
|
|
|
|
# remove everything related to weblate and dependencies
|
|
|
|
TEXT=$(printf "${TEXT[@]}" | sed -e 's/.*Weblate.*//g' -e 's/.*dependency.*//g' -e 's/^\*\*Full//g' -e 's/.*first contribution.*//g' -e 's/##.*//g')
|
2023-01-06 00:55:59 +05:30
|
|
|
|
|
|
|
# go through all the lines inside the file
|
|
|
|
readarray -t y <<< "${TEXT[@]}"
|
|
|
|
|
2023-07-08 18:52:26 +05:30
|
|
|
trim() {
|
|
|
|
local var="$*"
|
|
|
|
# remove leading whitespace characters
|
|
|
|
var="${var#"${var%%[![:space:]]*}"}"
|
|
|
|
# remove trailing whitespace characters
|
|
|
|
var="${var%"${var##*[![:space:]]}"}"
|
|
|
|
printf '%s' "$var"
|
2023-01-14 20:32:03 +05:30
|
|
|
}
|
|
|
|
|
2023-01-06 00:55:59 +05:30
|
|
|
# Print all the found and categorized changes
|
2023-01-14 20:32:03 +05:30
|
|
|
create_changelog() {
|
2023-07-08 18:52:26 +05:30
|
|
|
trim "$(echo "$TEXT" | sort)"
|
|
|
|
[ "$NEWCONTRIBUTORS" ] && echo -e "\n\n## New contributors\n$NEWCONTRIBUTORS"
|
|
|
|
echo -e "\n\n$FULLCHANGELOG"
|
2023-01-14 20:32:03 +05:30
|
|
|
}
|
2023-01-06 00:55:59 +05:30
|
|
|
|
2023-01-14 20:32:03 +05:30
|
|
|
# generate a new changelog
|
|
|
|
CHANGELOG=$(create_changelog)
|
2023-01-06 00:55:59 +05:30
|
|
|
|
2023-07-08 18:52:26 +05:30
|
|
|
# Output the generated changelog
|
|
|
|
echo "$CHANGELOG"
|