From f7d8e2b56c83040faa43d1a62a277d538c199f55 Mon Sep 17 00:00:00 2001 From: purian23 Date: Fri, 10 Jul 2026 11:57:36 -0400 Subject: [PATCH] workflow: enhance porting logic to support inline verbiage & audits (cherry picked from commit a3b2167e58f8f2efd3681037b2059c9892d25023) --- .github/workflows/port.yml | 16 +++++++++++----- scripts/port-audit.sh | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/port.yml b/.github/workflows/port.yml index ef11d4275..a17d609ed 100644 --- a/.github/workflows/port.yml +++ b/.github/workflows/port.yml @@ -1,8 +1,9 @@ name: Port to release branch # Ports flagged commits from master onto release/X.Y branches: -# - trailer line in a commit message pushed to master; accepted forms: -# "Port: 1.5", "Port/1.5", "Port 1.5", "Port - 1.5", "Port: release/1.5" +# - "port 1.5" flag in a commit message pushed to master — own line or +# mid-line; separators : / - or space; "release/1.5" also accepted; +# comma lists ("Port: 1.5, 1.4") work in the own-line form # - "port release/1.5" label on a merged PR # Conflicts are reported to the "Port status: " tracking issue. @@ -55,11 +56,16 @@ jobs: # skip merge commits (handled by the label path) [ "$(git rev-list --no-walk --count --min-parents=2 "$sha")" -eq 0 ] || continue - # extract targets, then keep only version-shaped ones (X.Y[.Z]) - targets=$(git log -1 --format=%B "$sha" | + # own-line form (supports comma lists), validated version-shaped + t1=$(git log -1 --format=%B "$sha" | { grep -iE '^Port[:/ -]' || true; } | sed -E 's|^port[-:/ ]+||I' | tr ',' '\n' | sed 's/[[:space:]]//g; /^$/d' | sed 's|^release/||I' | - { grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' || true; } | sort -u) + { grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' || true; }) + # mid-line form, e.g. "fix thing fixes #2802 port 1.5" + t2=$(git log -1 --format=%B "$sha" | + { grep -oiE '\bport[-: /]+(release/)?[0-9]+\.[0-9]+(\.[0-9]+)?\b' || true; } | + sed -E 's|^port[-:/ ]+||I' | sed 's|^release/||I') + targets=$(printf '%s\n%s\n' "$t1" "$t2" | sed '/^$/d' | sort -u) for ver in $targets; do echo "::group::port $sha -> release/$ver" bash scripts/port.sh "release/$ver" "$sha" diff --git a/scripts/port-audit.sh b/scripts/port-audit.sh index 1f6a486eb..7e20669d2 100755 --- a/scripts/port-audit.sh +++ b/scripts/port-audit.sh @@ -38,8 +38,12 @@ done < <(git log --format=%B "${BASE}..origin/${TARGET}" 2>/dev/null | # git cherry: "+ sha" = not on target (by patch-id), "- sha" = equivalent exists fixes="" others="" +flagged="" fix_count=0 other_count=0 +flagged_count=0 +VER="${TARGET#release/}" +FLAG_RE="\\bport[-: /]+(release/)?${VER//./\\.}\\b" while read -r mark sha; do [ "$mark" = "+" ] || continue [ -n "${PORTED[$sha]:-}" ] && continue @@ -50,7 +54,11 @@ while read -r mark sha; do short=$(git rev-parse --short "$sha") pr=$(grep -oE '#[0-9]+' <<<"$subject" | head -1 || true) line="- [ ] \`${short}\` ${subject} (${author}${pr:+, ${pr}})" - if grep -qiE '^(fix|hotfix|bugfix)([(:! ]|$)|^[a-z0-9_-]+: *fix' <<<"$subject"; then + # explicit "port X.Y" mention anywhere in the message = strongest signal + if git log -1 --format=%B "$sha" | grep -qiE "$FLAG_RE"; then + flagged+="${line}"$'\n' + flagged_count=$((flagged_count + 1)) + elif grep -qiE '^(fix|hotfix|bugfix)([(:! ]|$)|^[a-z0-9_./-]+: *fix' <<<"$subject"; then fixes+="${line}"$'\n' fix_count=$((fix_count + 1)) else @@ -59,11 +67,17 @@ while read -r mark sha; do fi done < <(git cherry "origin/${TARGET}" origin/master "$BASE") +FLAGGED_SECTION="" +if [ "$flagged_count" -gt 0 ]; then + FLAGGED_SECTION="### :warning: Flagged \"port ${VER}\" but not applied (${flagged_count})"$'\n\n'"${flagged}" +fi + REPORT=$(cat <