From e78df65120761f1c2a8ed1257930e97bc356dce7 Mon Sep 17 00:00:00 2001 From: Abbie Jones Date: Mon, 20 Apr 2026 12:41:16 -0700 Subject: [PATCH 1/2] short circuit if there is no difference between source branch and destination branch --- merge/entrypoint.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/merge/entrypoint.sh b/merge/entrypoint.sh index 08e0dcd..6ae275d 100755 --- a/merge/entrypoint.sh +++ b/merge/entrypoint.sh @@ -60,13 +60,25 @@ git remote prune origin failures=() function open_and_merge_pull_request() { + local source_branch="${GITHUB_REF#refs/heads/}" + local ahead_count + echo "DEBUG: making pull request from ${GITHUB_REF} to $1" - # if $1 branch does not exist origin + # if destination branch does not exist on origin if [[ -z "$(git ls-remote origin "$1")" ]]; then echo "Could not find expected branch '$1' on remote 'origin'" fi + # Skip no-op merges so identical branches do not fail PR creation with + # "No commits between ..." validation errors. + ahead_count="$(git rev-list --count "origin/$1..origin/${source_branch}")" + + if [[ "${ahead_count}" == "0" ]]; then + echo "DEBUG: skipping merge of ${GITHUB_REF} into $1; ${source_branch} has no commits ahead of $1" + return 0 + fi + # subshell with +e so we continue on errors ( set +e From fb4d7c34ce404bb0dfd12ee3183ef4925a815d1c Mon Sep 17 00:00:00 2001 From: Abbie Jones Date: Mon, 20 Apr 2026 12:51:43 -0700 Subject: [PATCH 2/2] apply copilot suggestions --- merge/entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/merge/entrypoint.sh b/merge/entrypoint.sh index 6ae275d..f884070 100755 --- a/merge/entrypoint.sh +++ b/merge/entrypoint.sh @@ -61,20 +61,21 @@ failures=() function open_and_merge_pull_request() { local source_branch="${GITHUB_REF#refs/heads/}" - local ahead_count echo "DEBUG: making pull request from ${GITHUB_REF} to $1" # if destination branch does not exist on origin if [[ -z "$(git ls-remote origin "$1")" ]]; then echo "Could not find expected branch '$1' on remote 'origin'" + return 1 fi # Skip no-op merges so identical branches do not fail PR creation with # "No commits between ..." validation errors. - ahead_count="$(git rev-list --count "origin/$1..origin/${source_branch}")" + local ahead_commit + ahead_commit="$(git rev-list --max-count=1 "origin/$1..origin/${source_branch}")" - if [[ "${ahead_count}" == "0" ]]; then + if [[ -z "${ahead_commit}" ]]; then echo "DEBUG: skipping merge of ${GITHUB_REF} into $1; ${source_branch} has no commits ahead of $1" return 0 fi