mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
## 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"
|