diff --git a/scripts/get-compare-link.sh b/scripts/get-compare-link.sh index 5fdaccccf..90424abff 100755 --- a/scripts/get-compare-link.sh +++ b/scripts/get-compare-link.sh @@ -16,12 +16,22 @@ git fetch --tags || { echo "Failed to fetch tags"; exit 1; } latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)") || { echo "Failed to get latest tag"; exit 1; } # Get the owner and repository name from the remote URL -repo_url=$(git config --get remote.origin.url) -IFS='/' read -ra parts <<< "$repo_url" -owner="${parts[-2]}" -repo="${parts[-1]%.git}" # Remove the .git extension if it exists +# Get the remote URL +remote_url=$(git config --get remote.origin.url) + +# Extract owner/repo from the URL +if [[ $remote_url =~ ^https://github.com/ ]]; then + # For HTTPS URLs + owner_repo=$(echo $remote_url | sed -E 's|https://github.com/||' | sed -E 's/\.git$//') +elif [[ $remote_url =~ ^git@ ]]; then + # For SSH URLs + owner_repo=$(echo $remote_url | sed -E 's/^git@github.com://' | sed -E 's/\.git$//') +else + echo "Unrecognized GitHub URL format" + exit 1 +fi # Create a link to compare the latest tag and the main branch -comparison_link="https://github.com/$owner/$repo/compare/$latest_tag...main" +comparison_link="https://github.com/$owner_repo/compare/$latest_tag...main" echo "Comparison Link: $comparison_link"