Skip to content

Commit 9ed05eb

Browse files
committed
chore: enhance cherry-pick PR format with original context
- Make cherry-pick PRs easier to understand with descriptive titles - Preserve original PR context to maintain decision history - Improve reviewer experience with linked source PR Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent 478d30f commit 9ed05eb

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/cherry-pick-command.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
112112
# Get PR information
113113
echo "Fetching PR #$PR_NUMBER information..."
114-
PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json state,mergeCommit,mergedAt)
114+
PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json state,mergeCommit,mergedAt,title,body)
115115
116116
# Check if PR is merged
117117
PR_STATE=$(echo "$PR_DATA" | jq -r '.state')
@@ -122,7 +122,10 @@ jobs:
122122
fi
123123
124124
MERGE_COMMIT=$(echo "$PR_DATA" | jq -r '.mergeCommit.oid')
125+
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title')
126+
PR_BODY=$(echo "$PR_DATA" | jq -r '.body')
125127
echo "Found merge commit: $MERGE_COMMIT"
128+
echo "PR title: $PR_TITLE"
126129
127130
# Fetch target branch
128131
echo "Fetching target branch: $TARGET_BRANCH..."
@@ -169,12 +172,23 @@ jobs:
169172
170173
# Create pull request
171174
echo "Creating pull request..."
175+
176+
# Prepare PR body with original content
177+
PR_BODY_CONTENT=$(cat <<EOF
178+
This is a cherry-pick of #$PR_NUMBER
179+
180+
---
181+
182+
$PR_BODY
183+
EOF
184+
)
185+
172186
gh pr create \
173187
--repo ${{ github.repository }} \
174188
--base "$TARGET_BRANCH" \
175189
--head "$CHERRY_PICK_BRANCH" \
176-
--title "Cherry-pick #$PR_NUMBER to $TARGET_BRANCH" \
177-
--body "Automatic cherry-pick of #$PR_NUMBER to \`$TARGET_BRANCH\`"
190+
--title "[cherry-pick: $TARGET_BRANCH] $PR_TITLE" \
191+
--body "$PR_BODY_CONTENT"
178192

179193
echo "✅ Cherry-pick completed successfully!"
180194
} 2>&1 | tee "$OUTPUT_FILE"

0 commit comments

Comments
 (0)