From 15c70f0e262cdcf55c42cce267a3c232ab079a6a Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Sat, 9 May 2026 15:09:38 -0500 Subject: [PATCH] Fix stage source check to use git parent instead of commit message parsing --- .gitea/workflows/stage.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/stage.yaml b/.gitea/workflows/stage.yaml index 80b636f..bd6f3f4 100644 --- a/.gitea/workflows/stage.yaml +++ b/.gitea/workflows/stage.yaml @@ -43,7 +43,17 @@ jobs: echo "Merge commit: $COMMIT_MSG" # Gitea merge commits: "Merge pull request '...' (#N) from dev into stage" # Direct branch merges: "Merge branch 'dev' into stage" - if echo "$COMMIT_MSG" | grep -qE " from dev into stage$| 'dev' into stage$"; then + # tea pr merge with custom title: any subject line is possible, so + # fall back to checking git parents — if the second parent is on dev + # the merge came from dev regardless of the commit subject. + SECOND_PARENT=$(git log -1 --pretty=format:"%P" HEAD | awk '{print $2}') + FROM_DEV="" + if [ -n "$SECOND_PARENT" ]; then + if git merge-base --is-ancestor "$SECOND_PARENT" origin/dev 2>/dev/null; then + FROM_DEV=1 + fi + fi + if echo "$COMMIT_MSG" | grep -qE " from dev into stage$| 'dev' into stage$" || [ -n "$FROM_DEV" ]; then echo "Source branch check: OK (merged from dev)" else echo "ERROR: stage only accepts merges from dev."