Skip to content

Commit

Permalink
Add support for GNU Sort being named sort
Browse files Browse the repository at this point in the history
Closes issue [1314](beautifier#1314).
  • Loading branch information
jyn514 committed Jan 8, 2018
1 parent 688d00b commit a77e655
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/generate-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ main()
exit 1
fi

jq --version || {
local JQ
JQ=$(command -v jq) || {
echo "Required tool 'jq' missing. Failed."
exit 1
}

gsort --version || {
echo "Required tool 'gsort' missing. Failed."
local GSORT
GSORT=$(command -v gsort || command -v sort) || {
echo "Required tool 'GNU sort' missing. Failed."
exit 1
}

IFS=$'\n'
echo "# Changelog" > CHANGELOG.md

for m in $(curl -s "https://api.github.com/repos/$1/milestones?state=closed" | jq -c '.[] | [.title, .number, .description]' | gsort -r -V); do
for m in $(curl -s "https://api.github.com/repos/$1/milestones?state=closed" | "$JQ" -c '.[] | [.title, .number, .description]' | "$GSORT" -r -V); do
mid=$(echo $m | sed 's/\[".*",\(.*\),".*"\]/\1/')
title=$(echo $m | sed 's/\["\(.*\)",.*,".*"\]/\1/')

Expand All @@ -39,7 +41,7 @@ main()
echo $m | sed 's/\[".*",.*,"\(.*\)"\]/\1/' | sed -e 's/\\"/"/g' | sed -e 's/\\r\\n/\\n/g' | sed -e 's/\\n/\'$'\n/g' >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo '### Closed Issues' >> CHANGELOG.md
for i in $(curl -s "https://api.github.com/repos/$1/issues?milestone=$mid&state=closed" | jq -c '.[] | [.html_url, .number, .title]'); do
for i in $(curl -s "https://api.github.com/repos/$1/issues?milestone=$mid&state=closed" | "$JQ" -c '.[] | [.html_url, .number, .title]'); do
echo $i | sed 's/\["\(.*\)",\(.*\),\"\(.*\)\"\]/* \3 ([#\2](\1))/' | sed 's/\\"/"/g' >> CHANGELOG.md
done
echo "" >> CHANGELOG.md
Expand Down

0 comments on commit a77e655

Please sign in to comment.