2024-03-17 18:10:27 +05:30
|
|
|
#!/bin/bash
|
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
|
|
|
# remove everything related to weblate and dependencies
|
2023-12-30 21:41:51 +05:30
|
|
|
TEXT=$(printf "${TEXT[@]}" | sed -e 's/.*Translations.*//g' -e 's/.*(fix|chore)\(deps\).*//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-12-30 21:41:51 +05:30
|
|
|
TRIMMED=`trim "$(echo "$TEXT" | sort)"`
|
2023-01-06 00:55:59 +05:30
|
|
|
|
2023-12-30 21:41:51 +05:30
|
|
|
CHANGELOG=()
|
|
|
|
CURRENTSECTION=""
|
|
|
|
while IFS= read -r line; do
|
|
|
|
SECTION=$(echo "$line" | cut -d ":" -f 1 | tr -d "*" | tr -d " " | sed "s/(.*)//g")
|
|
|
|
if [ "$SECTION" != "$CURRENTSECTION" ]; then
|
|
|
|
CHANGELOG+="\n## ${SECTION^}\n"
|
|
|
|
CURRENTSECTION="$SECTION"
|
|
|
|
fi
|
|
|
|
CHANGELOG+="$line\n"
|
|
|
|
done <<< "$TRIMMED"
|
2023-01-06 00:55:59 +05:30
|
|
|
|
2023-07-08 18:52:26 +05:30
|
|
|
# Output the generated changelog
|
2023-12-30 21:41:51 +05:30
|
|
|
echo -e "$CHANGELOG"
|