Skip to content
Merged
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
10 changes: 6 additions & 4 deletions tooling/backport-pr-to-patch-release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -e

# PATCH_RELEASE_NAME should be the name of the release that is being done without the patch number. (e.g. v1.2.x)
PATCH_RELEASE_NAME=$1
PATCH_RELEASE_BRANCH=release/$PATCH_RELEASE_NAME
PR_NUMBER=$2
Expand All @@ -11,7 +12,7 @@ PR_NUMBER=$2
# Check if no arguments are provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <patch-release-name> <pr-number>"
echo "<patch-release-name>: v1.2.x or release/v1.2.x"
echo "<patch-release-name>: v1.2.x"
echo "<pr-number>: PR number to backport"
exit 1
fi
Expand All @@ -20,9 +21,10 @@ if [ -z "$PATCH_RELEASE_NAME" ]; then
echo "Patch release name is not provided: $0 <patch-release-name> <pr-number>"
exit 1
fi
# Check patch release name starts with "release/"
if [[ ! "$PATCH_RELEASE_NAME" =~ ^release/.* ]]; then
PATCH_RELEASE_NAME="release/$PATCH_RELEASE_NAME"
# Check patch release name does not start with "release/"
if [[ "$PATCH_RELEASE_NAME" =~ ^release/.* ]]; then
echo "Patch release name should not be the same as the release branch name. Only include the release name without patch number. (e.g. v1.2.x)"
exit 1
Comment on lines +25 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're enforcing the patch release name to be in the v1.2.x format, you should test it then.
Bash can do regexp testing 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested this locally, trying to backport a PR with PATCH_RELEASE_NAME=release/1.50.2 and it got caught in the proper check. On the contrary, doing PATCH_RELEASE_NAME=1.50.2 skips that check.

@PerfectSlayer Is this what you mean by testing the regexp testing?

Copy link
Contributor

@PerfectSlayer PerfectSlayer Jul 9, 2025

Choose a reason for hiding this comment

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

No, I meant you should test that the arg is following the ^v[0-9]\.....$ pattern.
I made #9127 as follow up.

fi
# Check PR number is provided
if [ -z "$PR_NUMBER" ]; then
Expand Down