From 1d5a4a89e9aae0155384035ac58d8e2f73068fa7 Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Tue, 16 Jun 2026 15:39:59 +0200 Subject: [PATCH 1/2] fix: resolve PR head branch on merge-queue --- shopware-version/shopware-version.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shopware-version/shopware-version.bash b/shopware-version/shopware-version.bash index 299f69a..221c81d 100755 --- a/shopware-version/shopware-version.bash +++ b/shopware-version/shopware-version.bash @@ -14,8 +14,8 @@ set pipefail get_ref() { PR_NR=$(echo "${1}" | sed -E -n "s|^(refs/heads/)?gh-readonly-queue/[^/]+/pr-([0-9]+)-.*$|\2|p") if [[ -n "${PR_NR}" ]]; then - echo "Merge queue detected. Using REF" - return + echo "Merge queue detected. Using PR_NR: ${PR_NR} to fetch HEAD_REF" + HEAD_REF="$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.headRefName' --json headRefName || true)" fi #remove whitespace from HEAD_REF with bash substitution From 3a50f488ad41bf97793812c7e2abf87b77f0e5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Kr=C3=A4ml?= Date: Wed, 17 Jun 2026 14:49:15 +0200 Subject: [PATCH 2/2] fix: resolve HEAD_REF additionally --- shopware-version/shopware-version.bash | 81 +++++++++++++++++--------- 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/shopware-version/shopware-version.bash b/shopware-version/shopware-version.bash index 221c81d..5caf512 100755 --- a/shopware-version/shopware-version.bash +++ b/shopware-version/shopware-version.bash @@ -14,8 +14,8 @@ set pipefail get_ref() { PR_NR=$(echo "${1}" | sed -E -n "s|^(refs/heads/)?gh-readonly-queue/[^/]+/pr-([0-9]+)-.*$|\2|p") if [[ -n "${PR_NR}" ]]; then - echo "Merge queue detected. Using PR_NR: ${PR_NR} to fetch HEAD_REF" - HEAD_REF="$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.headRefName' --json headRefName || true)" + echo "Merge queue detected. Using REF" + return fi #remove whitespace from HEAD_REF with bash substitution @@ -45,11 +45,28 @@ get_base_ref() { fi } +get_head_ref() { + PR_NR=$(echo "${1}" | sed -E -n "s|^(refs/heads/)?gh-readonly-queue/[^/]+/pr-([0-9]+)-.*$|\2|p") + if [[ -n "${PR_NR}" ]]; then + echo "Merge queue detected. Using PR_NR: ${PR_NR} to fetch HEAD_REF" + HEAD_REF="$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.headRefName' --json baseRefName || true)" + return + fi + + #remove whitespace from HEAD_REF with bash substitution + HEAD_REF=${HEAD_REF// /} + if [[ -n "${HEAD_REF}" ]]; then + HEAD_REF="refs/heads/${HEAD_REF#"refs/heads/"}" + fi +} + ORIGINAL_REF=${REF} get_ref "${ORIGINAL_REF}" echo "ref: ${REF}" get_base_ref "${ORIGINAL_REF}" echo "base ref: ${BASE_REF}" +get_head_ref "${ORIGINAL_REF}" +echo "head ref: ${HEAD_REF}" # Normalize REPO to owner/repo format for gh api REPO="${REPO#"https://github.com/"}" @@ -75,39 +92,51 @@ if ref_exists "${REF}"; then version="${REF#"refs/heads/"}" echo "✓ Found matching REF: ${version}" else + HEAD_REF=${HEAD_REF// /} + if [[ -z "${HEAD_REF}" ]]; then + echo "✗ HEAD_REF not set, using REF '${REF}'" + HEAD_REF="${REF}" + fi + BASE_REF=${BASE_REF// /} if [[ -z "${BASE_REF}" ]]; then echo "✗ BASE_REF not set, using REF '${REF}'" BASE_REF="${REF}" fi - echo "✗ REF not found, checking BASE_REF '${BASE_REF}'" - # Check if BASE_REF exists in target repo - if ref_exists "${BASE_REF}"; then - version="${BASE_REF#"refs/heads/"}" - echo "✓ Found matching BASE_REF: ${version}" + echo "✗ REF not found, checking HEAD_REF '${HEAD_REF}'" + if ref_exists "${HEAD_REF}"; then + version="${HEAD_REF#"refs/heads/"}" + echo "✓ Found matching HEAD_REF: ${version}" else - echo "✗ BASE_REF not found, checking next minor branch" - # Check next minor branch (replace last digit with x) - next_minor=$(echo "${BASE_REF}" | sed -E 's/[0-9]+$/x/') - echo " Checking next minor: ${next_minor}" - if ref_exists "${next_minor}"; then - version="${next_minor#"refs/heads/"}" - echo "✓ Found matching next minor: ${version}" + echo "✗ REF not found, checking BASE_REF '${BASE_REF}'" + # Check if BASE_REF exists in target repo + if ref_exists "${BASE_REF}"; then + version="${BASE_REF#"refs/heads/"}" + echo "✓ Found matching BASE_REF: ${version}" else - echo "✗ Next minor not found, checking next major branch" - # Check next major branch (replace last two digits with x) - next_major=$(echo "${BASE_REF}" | sed -E 's/[0-9]+\.[0-9]+$/x/') - echo " Checking next major: ${next_major}" - if ref_exists "${next_major}"; then - version="${next_major#"refs/heads/"}" - echo "✓ Found matching next major: ${version}" + echo "✗ BASE_REF not found, checking next minor branch" + # Check next minor branch (replace last digit with x) + next_minor=$(echo "${BASE_REF}" | sed -E 's/[0-9]+$/x/') + echo " Checking next minor: ${next_minor}" + if ref_exists "${next_minor}"; then + version="${next_minor#"refs/heads/"}" + echo "✓ Found matching next minor: ${version}" else - echo "✗ No matching branch found, checking fallback: ${FALLBACK}" - - if ref_exists "${FALLBACK}"; then - version="${FALLBACK}" - echo "✓ Found matching fallback: ${FALLBACK}" + echo "✗ Next minor not found, checking next major branch" + # Check next major branch (replace last two digits with x) + next_major=$(echo "${BASE_REF}" | sed -E 's/[0-9]+\.[0-9]+$/x/') + echo " Checking next major: ${next_major}" + if ref_exists "${next_major}"; then + version="${next_major#"refs/heads/"}" + echo "✓ Found matching next major: ${version}" + else + echo "✗ No matching branch found, checking fallback: ${FALLBACK}" + + if ref_exists "${FALLBACK}"; then + version="${FALLBACK}" + echo "✓ Found matching fallback: ${FALLBACK}" + fi fi fi fi