Improve compare_perf.yml, cherry_pick.yml (#41606) (cherry-pick) (#41946)

Cherry-pick of #41606

----
Release Notes:

- N/A

---------

Co-authored-by: Nia Espera <nia@zed.dev>

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Nia Espera <nia@zed.dev>
This commit is contained in:
zed-zippy[bot]
2025-11-04 23:01:35 +00:00
committed by GitHub
parent 03a0f9b944
commit 7deac6cd2c
10 changed files with 224 additions and 13 deletions

33
script/cherry-pick Executable file
View File

@@ -0,0 +1,33 @@
# #!/bin/bash
set -euxo pipefail
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <branch-name> <commit-sha>"
exit 1
fi
BRANCH_NAME="$1"
COMMIT_SHA="$2"
SHORT_SHA="${COMMIT_SHA:0:8}"
NEW_BRANCH="cherry-pick-${BRANCH_NAME}-${SHORT_SHA}"
git fetch origin
git checkout "$BRANCH_NAME"
git checkout -b "$NEW_BRANCH"
git cherry-pick "$COMMIT_SHA"
git push origin "$NEW_BRANCH"
COMMIT_TITLE=$(git log -1 --pretty=format:"%s" "$COMMIT_SHA")
COMMIT_BODY=$(git log -1 --pretty=format:"%b" "$COMMIT_SHA")
# Check if commit title ends with (#number)
if [[ "$COMMIT_TITLE" =~ \(#([0-9]+)\)$ ]]; then
PR_NUMBER="${BASH_REMATCH[1]}"
PR_BODY="Cherry-pick of #${PR_NUMBER}"$'\n'$'\n'"----"$'\n'"${COMMIT_BODY}"
else
PR_BODY="Cherry-pick of ${COMMIT_SHA}"$'\n'$'\n'"----"$'\n'"${COMMIT_BODY}"
fi
# Create a pull request
gh pr create --base "$BRANCH_NAME" --head "$NEW_BRANCH" --title "$COMMIT_TITLE (cherry-pick)" --body "$PR_BODY"