From f91ebc0eef85c9e5d9109ba07a79a564626bdb41 Mon Sep 17 00:00:00 2001 From: Matt Walters Date: Sun, 29 Mar 2026 11:54:36 -0500 Subject: [PATCH 1/3] fix: stricter regex and better error logging for sync PR commit type - Require colon (with optional scope) after type keyword to avoid false positives like "feature: ..." or "testing out ..." - Log warning instead of silently swallowing gh api failures Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/on-child-update.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/on-child-update.yml b/.github/workflows/on-child-update.yml index 470e706..12e522b 100644 --- a/.github/workflows/on-child-update.yml +++ b/.github/workflows/on-child-update.yml @@ -37,8 +37,13 @@ jobs: # Extract conventional commit type from child commit message. # Falls back to "fix" if the message doesn't follow conventional commits. COMMIT_MSG=$(gh api "repos/harmony-labs/${REPO_NAME}/commits/${FULL_SHA}" \ - --jq '.commit.message' 2>/dev/null | head -1) - COMMIT_TYPE=$(echo "$COMMIT_MSG" | grep -oE '^(feat|fix|perf|refactor|docs|test|chore|ci|build|style)' | head -1) + --jq '.commit.message' 2>&1 | head -1) || true + if [[ -z "$COMMIT_MSG" || "$COMMIT_MSG" == *"Not Found"* || "$COMMIT_MSG" == *"Bad credentials"* ]]; then + echo "Warning: could not fetch commit message for ${REPO_NAME}@${FULL_SHA}, defaulting to fix:" + COMMIT_MSG="" + fi + # Match type followed by optional scope and colon: feat:, fix(scope):, etc. + COMMIT_TYPE=$(echo "$COMMIT_MSG" | grep -oE '^(feat|fix|perf|refactor|docs|test|chore|ci|build|style)(\([^)]+\))?:' | grep -oE '^[a-z]+' | head -1) COMMIT_TYPE="${COMMIT_TYPE:-fix}" # chore/docs/test/ci/style/build don't trigger release-please — promote to fix case "$COMMIT_TYPE" in From bce6d5821a00936fbbb022870fafa37714598bd9 Mon Sep 17 00:00:00 2001 From: Matt Walters Date: Sun, 29 Mar 2026 12:06:47 -0500 Subject: [PATCH 2/3] fix: use exit code for API error detection, not string matching Check gh api exit code instead of pattern-matching specific error strings. Captures stderr to a temp file for the warning message. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/on-child-update.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on-child-update.yml b/.github/workflows/on-child-update.yml index 12e522b..3ab1022 100644 --- a/.github/workflows/on-child-update.yml +++ b/.github/workflows/on-child-update.yml @@ -36,12 +36,15 @@ jobs: # Extract conventional commit type from child commit message. # Falls back to "fix" if the message doesn't follow conventional commits. + GH_ERR=$(mktemp) COMMIT_MSG=$(gh api "repos/harmony-labs/${REPO_NAME}/commits/${FULL_SHA}" \ - --jq '.commit.message' 2>&1 | head -1) || true - if [[ -z "$COMMIT_MSG" || "$COMMIT_MSG" == *"Not Found"* || "$COMMIT_MSG" == *"Bad credentials"* ]]; then - echo "Warning: could not fetch commit message for ${REPO_NAME}@${FULL_SHA}, defaulting to fix:" + --jq '.commit.message' 2>"$GH_ERR" | head -1) + GH_EXIT=$? + if [[ $GH_EXIT -ne 0 || -z "$COMMIT_MSG" ]]; then + echo "Warning: could not fetch commit message for ${REPO_NAME}@${FULL_SHA} (exit $GH_EXIT: $(head -1 "$GH_ERR")), defaulting to fix:" COMMIT_MSG="" fi + rm -f "$GH_ERR" # Match type followed by optional scope and colon: feat:, fix(scope):, etc. COMMIT_TYPE=$(echo "$COMMIT_MSG" | grep -oE '^(feat|fix|perf|refactor|docs|test|chore|ci|build|style)(\([^)]+\))?:' | grep -oE '^[a-z]+' | head -1) COMMIT_TYPE="${COMMIT_TYPE:-fix}" From 78cc55793dddc455f94f09e9ab532e2699ac01b0 Mon Sep 17 00:00:00 2001 From: Matt Walters Date: Sun, 29 Mar 2026 12:30:51 -0500 Subject: [PATCH 3/3] fix: capture gh api exit code before piping to head The pipe to head masked gh api's exit code ($? was always 0). Split into two steps: capture raw output + exit code first, then extract first line separately. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/on-child-update.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on-child-update.yml b/.github/workflows/on-child-update.yml index 3ab1022..a6c8e5b 100644 --- a/.github/workflows/on-child-update.yml +++ b/.github/workflows/on-child-update.yml @@ -37,9 +37,9 @@ jobs: # Extract conventional commit type from child commit message. # Falls back to "fix" if the message doesn't follow conventional commits. GH_ERR=$(mktemp) - COMMIT_MSG=$(gh api "repos/harmony-labs/${REPO_NAME}/commits/${FULL_SHA}" \ - --jq '.commit.message' 2>"$GH_ERR" | head -1) - GH_EXIT=$? + RAW_COMMIT_MSG=$(gh api "repos/harmony-labs/${REPO_NAME}/commits/${FULL_SHA}" \ + --jq '.commit.message' 2>"$GH_ERR") && GH_EXIT=0 || GH_EXIT=$? + COMMIT_MSG=$(printf '%s\n' "$RAW_COMMIT_MSG" | head -1) if [[ $GH_EXIT -ne 0 || -z "$COMMIT_MSG" ]]; then echo "Warning: could not fetch commit message for ${REPO_NAME}@${FULL_SHA} (exit $GH_EXIT: $(head -1 "$GH_ERR")), defaulting to fix:" COMMIT_MSG=""