Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treehouses changelog compare <version> [version] upgrade (fixes #2164) #2169

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 19 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
26 changes: 24 additions & 2 deletions modules/changelog.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function changelog {
if [ -d "tests" ]; then
cp "/usr/lib/node_modules/@treehouses/cli/CHANGELOG.md" .
else
cp "/usr/lib/node_modules/@treehouses/cli/CHANGELOG.md" ../.
fi
Copy link
Member

Choose a reason for hiding this comment

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

I may be mistaken but I think @dogi left checking the directory for tests/changelog.bats
Also you didn't remove the CHANGELOG file....

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed - it now removes the duplicate CHANGELOG file.

Copy link
Member Author

Choose a reason for hiding this comment

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

jamiecomparechangelog

The changelog compare still shows the changes between new version first and old version last. I don't know if the requirements are strict with only comparing old first and new last. But I'll probably leave out the changes and keep the "Did you mean..." line.

Anyways it looks a lot better than showing all the changes.

Are you saying you want an error handling message when when comparing changes with the new version first and old version last?

And you're correct, the way the code is written now, the command will 'autocorrect' by displaying the changes as if the versions were switched around, then suggest the correct way to write the command:
image

local LOGPATH displaymode version1 version2 CURRENT
CURRENT=$(treehouses version)
LOGPATH="$SCRIPTFOLDER/CHANGELOG.md"
Expand Down Expand Up @@ -29,11 +34,28 @@ 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
echo "Did you mean: $BASENAME changelog compare $version2 $version1"
fi
;;
esac
;;
Expand Down