forked from libre-tube/LibreTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog.sh
executable file
·35 lines (28 loc) · 925 Bytes
/
changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
## Usage: ./changelog.sh <text>
TEXT="$1"
# remove everything related to weblate and dependencies
TEXT=$(printf "${TEXT[@]}" | sed -e 's/.*Translations.*//g' -e 's/.*(fix|chore)\(deps\).*//g')
# go through all the lines inside the file
readarray -t y <<< "${TEXT[@]}"
trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
printf '%s' "$var"
}
TRIMMED=`trim "$(echo "$TEXT" | sort)"`
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"
# Output the generated changelog
echo -e "$CHANGELOG"