Skip to content

Commit a3b2167

Browse files
committed
workflow: enhance porting logic to support inline verbiage & audits
1 parent 0b69fea commit a3b2167

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

.github/workflows/port.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Port to release branch
22

33
# Ports flagged commits from master onto release/X.Y branches:
4-
# - trailer line in a commit message pushed to master; accepted forms:
5-
# "Port: 1.5", "Port/1.5", "Port 1.5", "Port - 1.5", "Port: release/1.5"
4+
# - "port 1.5" flag in a commit message pushed to master — own line or
5+
# mid-line; separators : / - or space; "release/1.5" also accepted;
6+
# comma lists ("Port: 1.5, 1.4") work in the own-line form
67
# - "port release/1.5" label on a merged PR
78
# Conflicts are reported to the "Port status: <branch>" tracking issue.
89

@@ -55,11 +56,16 @@ jobs:
5556
# skip merge commits (handled by the label path)
5657
[ "$(git rev-list --no-walk --count --min-parents=2 "$sha")" -eq 0 ] || continue
5758
58-
# extract targets, then keep only version-shaped ones (X.Y[.Z])
59-
targets=$(git log -1 --format=%B "$sha" |
59+
# own-line form (supports comma lists), validated version-shaped
60+
t1=$(git log -1 --format=%B "$sha" |
6061
{ grep -iE '^Port[:/ -]' || true; } | sed -E 's|^port[-:/ ]+||I' | tr ',' '\n' |
6162
sed 's/[[:space:]]//g; /^$/d' | sed 's|^release/||I' |
62-
{ grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' || true; } | sort -u)
63+
{ grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' || true; })
64+
# mid-line form, e.g. "fix thing fixes #2802 port 1.5"
65+
t2=$(git log -1 --format=%B "$sha" |
66+
{ grep -oiE '\bport[-: /]+(release/)?[0-9]+\.[0-9]+(\.[0-9]+)?\b' || true; } |
67+
sed -E 's|^port[-:/ ]+||I' | sed 's|^release/||I')
68+
targets=$(printf '%s\n%s\n' "$t1" "$t2" | sed '/^$/d' | sort -u)
6369
for ver in $targets; do
6470
echo "::group::port $sha -> release/$ver"
6571
bash scripts/port.sh "release/$ver" "$sha"

scripts/port-audit.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ done < <(git log --format=%B "${BASE}..origin/${TARGET}" 2>/dev/null |
3838
# git cherry: "+ sha" = not on target (by patch-id), "- sha" = equivalent exists
3939
fixes=""
4040
others=""
41+
flagged=""
4142
fix_count=0
4243
other_count=0
44+
flagged_count=0
45+
VER="${TARGET#release/}"
46+
FLAG_RE="\\bport[-: /]+(release/)?${VER//./\\.}\\b"
4347
while read -r mark sha; do
4448
[ "$mark" = "+" ] || continue
4549
[ -n "${PORTED[$sha]:-}" ] && continue
@@ -50,7 +54,11 @@ while read -r mark sha; do
5054
short=$(git rev-parse --short "$sha")
5155
pr=$(grep -oE '#[0-9]+' <<<"$subject" | head -1 || true)
5256
line="- [ ] \`${short}\` ${subject} (${author}${pr:+, ${pr}})"
53-
if grep -qiE '^(fix|hotfix|bugfix)([(:! ]|$)|^[a-z0-9_-]+: *fix' <<<"$subject"; then
57+
# explicit "port X.Y" mention anywhere in the message = strongest signal
58+
if git log -1 --format=%B "$sha" | grep -qiE "$FLAG_RE"; then
59+
flagged+="${line}"$'\n'
60+
flagged_count=$((flagged_count + 1))
61+
elif grep -qiE '^(fix|hotfix|bugfix)([(:! ]|$)|^[a-z0-9_./-]+: *fix' <<<"$subject"; then
5462
fixes+="${line}"$'\n'
5563
fix_count=$((fix_count + 1))
5664
else
@@ -59,11 +67,17 @@ while read -r mark sha; do
5967
fi
6068
done < <(git cherry "origin/${TARGET}" origin/master "$BASE")
6169

70+
FLAGGED_SECTION=""
71+
if [ "$flagged_count" -gt 0 ]; then
72+
FLAGGED_SECTION="### :warning: Flagged \"port ${VER}\" but not applied (${flagged_count})"$'\n\n'"${flagged}"
73+
fi
74+
6275
REPORT=$(cat <<EOF
6376
## Port audit: \`${TARGET}\` vs \`master\`
6477
6578
Base: \`$(git rev-parse --short "$BASE")\` · generated $(date -u +%Y-%m-%dT%H:%MZ)
6679
80+
${FLAGGED_SECTION}
6781
### Candidate fixes not ported (${fix_count})
6882
6983
${fixes:-_none — all caught up_ }

0 commit comments

Comments
 (0)