Skip to content
Open
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions modules/changelog.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function changelog {
if [ -d "tests" ]; then
cp -f "/usr/lib/node_modules/@treehouses/cli/CHANGELOG.md" . 2>/dev/null || true
rm -f "/usr/lib/node_modules/@treehouses/cli/CHANGELOG.md"
else
cp -f "/usr/lib/node_modules/@treehouses/cli/CHANGELOG.md" ../. 2>/dev/null || true
rm -f "/usr/lib/node_modules/@treehouses/cli/CHANGELOG.md"
fi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this. This belongs in the changelog.bats

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this. This belongs in the changelog.bats

I deleted the code you mentioned.

local LOGPATH displaymode version1 version2 CURRENT
CURRENT=$(treehouses version)
LOGPATH="$SCRIPTFOLDER/CHANGELOG.md"
Expand Down Expand Up @@ -29,11 +36,27 @@ case "$displaymode" in
case "$version2" in
"")
checkargn $# 2
sed "/^### $CURRENT/!d;s//&\n/;s/.*\n//;:a;/^### $version1/bb;\$!{n;ba};:b;s//\n&/;P;D" $LOGPATH #grabs text between version numbers, print bottom to top
dpkg --compare-versions "$CURRENT" "gt" "$version1"
gt="$?"
if [[ $gt -eq 0 ]]; then
sed "/^### $CURRENT/!d;s//&\n/;s/.*\n//;:a;/^### $version1/bb;\$!{n;ba};:b;s//\n&/;P;D" $LOGPATH #grabs text between version numbers, print bottom to top
else # Needs to specify previous version instead of current
echo "ERROR: Must specify a previous version (less than $CURRENT)"
fi
;;
*)
checkargn $# 3
sed "/^### $version2/!d;s//&\n/;s/.*\n//;:a;/^### $version1/bb;\$!{n;ba};:b;s//\n&/;P;D" $LOGPATH
dpkg --compare-versions "$version2" "gt" "$version1"
gt="$?"
dpkg --compare-versions "$version2" "eq" "$version1"
eq="$?"
if [[ $gt -eq 0 ]]; then
sed "/^### $version2/!d;s//&\n/;s/.*\n//;:a;/^### $version1/bb;\$!{n;ba};:b;s//\n&/;P;D" $LOGPATH
elif [[ $eq -eq 0 ]]; then
echo "ERROR: Must specify different versions for comparisons (cannot compare same version to itself)"
else
sed "/^### $version1/!d;s//&\n/;s/.*\n//;:a;/^### $version2/bb;\$!{n;ba};:b;s//\n&/;P;D" $LOGPATH
fi
;;
esac
;;
Expand Down