mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
ci: leave comment and abort early if commit already exists on target branch in backport workflow (#6326)
Follow up on https://github.com/Comfy-Org/ComfyUI_frontend/pull/6317: Fixes confusing "merge conflicts detected" message when commit already exists on target branch (e.g., PRs #6294 and #6307). ## Changes - Added check to detect if merge commit already exists on target branch before attempting cherry-pick - New failure reason `already-exists` for this case - Clear comment message: "Commit already exists on branch, no backport needed" instead of confusing "Merge conflicts detected" with empty file list ## Before When a commit already existed on the target branch, users would see: > @user Backport to `core/1.30` failed: Merge conflicts detected. > Please manually cherry-pick commit `abc123` to the `core/1.30` branch. > <details><summary>Conflicting files</summary> > > </details> This was confusing because there were no actual conflicts - the commit was already present. ## After Users now see: > @user Commit `abc123` already exists on branch `core/1.30`. No backport needed. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6326-ci-leave-comment-and-abort-early-if-commit-already-exists-on-target-branch-in-backport-w-2996d73d36508167aff3e6783e832c74) by [Unito](https://www.unito.io)
This commit is contained in:
11
.github/workflows/pr-backport.yaml
vendored
11
.github/workflows/pr-backport.yaml
vendored
@@ -234,6 +234,14 @@ jobs:
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if commit already exists on target branch
|
||||
if git branch -r --contains "${MERGE_COMMIT}" | grep -q "origin/${TARGET_BRANCH}"; then
|
||||
echo "::notice::Commit ${MERGE_COMMIT} already exists on ${TARGET_BRANCH}, skipping backport"
|
||||
FAILED="${FAILED}${TARGET_BRANCH}:already-exists "
|
||||
echo "::endgroup::"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Create backport branch
|
||||
git checkout -b "${BACKPORT_BRANCH}" "origin/${TARGET_BRANCH}"
|
||||
|
||||
@@ -328,6 +336,9 @@ jobs:
|
||||
if [ "${reason}" = "branch-missing" ]; then
|
||||
gh pr comment "${PR_NUMBER}" --body "@${PR_AUTHOR} Backport failed: Branch \`${target}\` does not exist"
|
||||
|
||||
elif [ "${reason}" = "already-exists" ]; then
|
||||
gh pr comment "${PR_NUMBER}" --body "@${PR_AUTHOR} Commit \`${MERGE_COMMIT}\` already exists on branch \`${target}\`. No backport needed."
|
||||
|
||||
elif [ "${reason}" = "conflicts" ]; then
|
||||
# Convert comma-separated conflicts back to newlines for display
|
||||
CONFLICTS_LIST=$(echo "${conflicts}" | tr ',' '\n' | sed 's/^/- /')
|
||||
|
||||
Reference in New Issue
Block a user