From b589b1ad7de7db5fbea727a79295033c4f117dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Levy?= Date: Tue, 11 Jun 2024 15:13:46 +0000 Subject: [PATCH] chore: macos support for generate-changelog.sh (#14583) --- scripts/generate-changelog.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/generate-changelog.sh b/scripts/generate-changelog.sh index d630712214d7..37388e4c0f48 100755 --- a/scripts/generate-changelog.sh +++ b/scripts/generate-changelog.sh @@ -7,22 +7,25 @@ copy_tools=("xclip" "wl-copy" "pbcopy") # Find the first available tool for tool in "${copy_tools[@]}"; do - if command -v "$tool" > /dev/null 2>&1; then - selected_tool="$tool" - break - fi + if command -v "$tool" >/dev/null 2>&1; then + selected_tool="$tool" + break + fi done # Check if a tool was found if [[ -z "$selected_tool" ]]; then - echo "No suitable copy tool found. Please install xclip, wl-copy, or pbcopy." - exit 1 + echo "No suitable copy tool found. Please install xclip, wl-copy, or pbcopy." + exit 1 fi git fetch # Get two most recent release branches -mapfile -t branches < <(git for-each-ref --sort=-committerdate refs/heads/release/ --format='%(refname:short)' | head -n2) +branches=() +while IFS= read -r line; do + branches+=("$line") +done < <(git for-each-ref --sort=-committerdate refs/heads/release/ --format='%(refname:short)' | head -n2) npx generate-changelog -t "${branches[1]}".."${branches[0]}" -a -f - | $selected_tool echo "Changelog copied to clipboard using $selected_tool"