Skip to content

Commit 0400f6b

Browse files
author
Aaron Schlesinger
committed
fix(generate-changelog.sh): update changelog generation script
1 parent e5754d3 commit 0400f6b

1 file changed

Lines changed: 18 additions & 36 deletions

File tree

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!/usr/bin/env bash
22
# vim: et tw=0 sw=4 ts=4
33

4+
REPOROOT=${REPOROOT:=https://github.com/deis/workflow}
5+
TYPES=${TYPES:=feat(;Features fix(;Fixes docs(;Documentation chore(;Maintenance}
6+
47
usage() {
5-
echo "Usage: $0 <from> [to]"
6-
echo "The REPOROOT and TYPES variables may be used to customize"
7-
echo "what is scraped from the commit logs. Current settings are:"
8-
echo
9-
echo " REPOROOT = $REPOROOT"
10-
echo " TYPES = $TYPES"
11-
echo
8+
echo "Usage: $0 <from> [to]
9+
The REPOROOT and TYPES variables may be used to customize what links are
10+
generated and what is scraped from the commit logs. Current settings are:
11+
REPOROOT=$REPOROOT
12+
TYPES=$TYPES
13+
"
1214
}
1315

1416
# Print the information scraped from git
1517
retrieve() {
16-
while read commit hash message
17-
do
18+
while read -r commit hash message; do
1819
# Extract the subsystem where type(subsystem): message
19-
SUBSYSTEM=$(echo $message | cut -d'(' -f2 | cut -d')' -f1 | sed 's/\*/\(all\)/g')
20+
SUBSYSTEM=$(echo "$message" | cut -d'(' -f2 | cut -d')' -f1 | sed 's/\*/\(all\)/g')
2021
# Extract the message where type(subsystem): message
21-
MESSAGE=$(echo $message | awk -F ")" '{ print $2}' | sed 's/://' | cut -f2- -d' ')
22+
MESSAGE=$(echo "$message" | awk -F ")" '{ print $2}' | sed 's/://' | cut -f2- -d' ')
2223
# Generate a link to the full legal commit on GitHub
2324
LINK="$REPOROOT/commit/$hash"
2425
# Echo all this in a way that makes the commit hash and message a link
@@ -37,47 +38,28 @@ subheading() {
3738
}
3839

3940
main() {
40-
# if REPOROOT is already in the environment, don't overload it and use that
41-
if [ -z "$REPOROOT" ];
42-
then
43-
REPOROOT="https://github.com/deis/deis"
44-
fi
45-
46-
# if TYPES is already in the environment, don't overload it and use that
47-
if [ -z "$TYPES" ];
48-
then
49-
# Based on https://github.com/deis/deis/blob/master/CONTRIBUTING.md
50-
# The format is in the form of $shortname;$longname $shortname;longname.
51-
TYPES="feat(;Features fix(;Fixes docs(;Documentation chore(;Maintenance"
52-
fi
53-
5441
# Print usage summary if user didn't specify a beginning
55-
if [ -z "$1" ];
56-
then
42+
if [ -z "$1" ]; then
5743
usage
5844
exit 1
5945
fi
6046

6147
FROM=$1
6248
TO=${2:-"HEAD"}
6349

64-
printf "### $FROM -> $TO\n\n"
50+
printf "### %s -> %s\n\n" "$FROM" "$TO"
6551

6652
# Iterate over the types of messages specified
67-
for LEGALTYPE in $TYPES
68-
do
53+
for LEGALTYPE in $TYPES; do
6954
SHORT=$(echo "$LEGALTYPE" | cut -f1 -d';')
7055
LONG=$(echo "$LEGALTYPE" | cut -f2 -d';')
71-
72-
subheading $LONG $SHORT
56+
subheading "$LONG" "$SHORT"
7357
done
7458
}
7559

76-
if (( $SHLVL == 2 ))
77-
then
60+
if [ $SHLVL -eq 2 ]; then
7861
# If this is being run as a command
79-
main $*
80-
exit
62+
main "$@"
8163
else
8264
# Otherwise this is being sourced
8365
unset -f main

0 commit comments

Comments
 (0)