Skip to content

Commit

Permalink
Add omit-labels functionality [DOC-268]
Browse files Browse the repository at this point in the history
When backports are triggered via PR labels, copying the labels to the backport PRs can cause an unexpected cascade.

E.G.:
- a PR is labelled to backport to multiple branches
- an action performs these actions _in parallel_
- the backported, labelled PRs are detected
- more backporting is performed
- etc

Instead it would be easier to _optionally_ omit copying labels to backported PRs.

Fixes: [DOC-268](https://hazelcast.atlassian.net/browse/DOC-268)
  • Loading branch information
JackPGreen committed Nov 22, 2024
1 parent bb31c8e commit cd94c01
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions backport
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function usage() {
echo " -l, --local Skip pushing the branch and creating the PR"
echo " -c, --continue Continue backporting after fixing cherry-pick conflict"
echo " -ni, --non-interactive Headlessly creates the PR automatically, without previewing in web browser"
echo " -ol, --omit-labels Omit copying labels to backport PR"
echo
echo "What does it do:"
echo " '$(basename "$0") master upstream/5.2.z' - will perform the following actions:"
Expand Down Expand Up @@ -57,6 +58,10 @@ get_opts() {
NON_INTERACTIVE=true
shift
;;
-ol | --omit-labels)
OMIT_LABELS=true
shift
;;
-h | --help)
usage
exit
Expand Down Expand Up @@ -163,11 +168,14 @@ if [ -n "$ORIGINAL_PR_NUMBER" ]; then
fi
PR_BODY=$(gh api repos/$REPO_UPSTREAM/pulls/$ORIGINAL_PR_NUMBER --jq '"\n\n" + .body')

LABELS=$(get_pr_labels "${REPO_UPSTREAM}" "${ORIGINAL_PR_NUMBER}")
if [ -n "$LABELS" ]; then
LABELS_ARG=(--label "$LABELS")
if [[ "${OMIT_LABELS}" != "true" ]]; then
LABELS=$(get_pr_labels "${REPO_UPSTREAM}" "${ORIGINAL_PR_NUMBER}")
if [[ -n "${LABELS}" ]]; then
LABELS_ARG=(--label "${LABELS}")
fi
fi
fi

log_info "Creating new PR..."
gh pr create --base "$BASE_BRANCH" --title "$NEW_COMMIT_MSG" \
--body "Backport of $ORIGINAL_PR_URL$(echo -e "\n\n")$PR_BODY" \
Expand Down

0 comments on commit cd94c01

Please sign in to comment.