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

feat: add "-all" option in preview #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions changelog-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ function _changelogsh_raw_to_expanded {

function _changelogsh_expanded_to_raw {
input=$1
split=($(echo $input | fold -w3))

echo $split | sed 's/^0*//g; s/ 0*/./g'
echo $input | fold -w3 | tr '\n' ' ' | sed 's/0*//g' | awk '{ if(NF=2){ $3=$2; $2=$1; $1=0 } if($3==""){ $3=0 } } {print $1 "." $2 "." $3}'
}
27 changes: 26 additions & 1 deletion changelog-preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,26 @@ function _changelogsh_preview {
raw_version=$1
fi

if [ $raw_version != "Unreleased" ]; then
if [ $raw_version == "-all" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if [ $raw_version == "-all" ]; then
if [ $raw_version == "--all" ]; then

single dash is normally for one letter shortcuts like -r for --recursive and -d for --daemon. double dash is more appropriate here for --all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @clrke. Awesome as always!

However, I suggest we keep "-all" like how "find" accepts options since this tool won't be a full blown cli tool and won't be having any other options soon (even short and long version of "all")

But I defer to what @xdgimf @TheoryOfNekomata might think.

echo "# Changelog"
echo ""

for dir in $(ls -rd changelog/*); do
expanded=$(echo ${dir/changelog\//})

if [ $expanded == "unreleased" ]; then
changelogheader="## Unreleased"
else
changelogheader="## [$(_changelogsh_expanded_to_raw $expanded)]"
fi

echo $changelogheader

_changelogsh_preview_expanded $expanded
done;
return

elif [ $raw_version != "Unreleased" ]; then
expanded=$(_changelogsh_raw_to_expanded $raw_version)
fi

Expand All @@ -20,6 +39,12 @@ function _changelogsh_preview {
echo ""
echo "## [$raw_version]"

_changelogsh_preview_expanded $expanded
}

function _changelogsh_preview_expanded {
expanded=$1

for dir in changelog/$expanded/*; do
if [ "$(ls -A $dir)" ]; then
current=$(echo $dir | grep -o '[^/]*$')
Expand Down
1 change: 1 addition & 0 deletions changelog/unreleased/feature/20240712141442
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new option for preview: -all - displays all changelog