forked from libre-tube/LibreTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog.sh
executable file
·35 lines (27 loc) · 1 KB
/
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
## Usage: ./changelog.sh <text>
TEXT="$1"
# 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')
# 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"
}
# Print all the found and categorized changes
create_changelog() {
trim "$(echo "$TEXT" | sort)"
[ "$NEWCONTRIBUTORS" ] && echo -e "\n\n## New contributors\n$NEWCONTRIBUTORS"
echo -e "\n\n$FULLCHANGELOG"
}
# generate a new changelog
CHANGELOG=$(create_changelog)
# Output the generated changelog
echo "$CHANGELOG"