@@ -46,67 +46,74 @@ jobs:
4646 declare -a MAINTENANCE # docs, style, test, build, ci, chore
4747 declare -a OTHER # anything else (except revert which is omitted)
4848
49- # Process each commit
50- while IFS= read -r line; do
51- [ -z "$line" ] && continue
49+ # Get list of commit SHAs
50+ COMMIT_SHAS=$(git log ${COMMIT_RANGE} --pretty=format:"%H" --no-merges)
5251
53- SHA=$(echo "$line" | cut -d'|' -f1)
54- SUBJECT=$(echo "$line" | cut -d'|' -f2)
55- SHORT_SHA=$(echo "$line" | cut -d'|' -f3)
56- BODY=$(echo "$line" | cut -d'|' -f4-)
52+ # Track processed PRs to avoid duplicates
53+ declare -A PROCESSED_PRS
5754
55+ # Process each commit
56+ for SHA in $COMMIT_SHAS; do
5857 echo "Processing commit: $SHA"
5958
60- # Skip revert commits
61- if echo "$SUBJECT" | grep -qE "^revert(\(|:)"; then
62- echo " Skipping revert commit"
59+ # Find the PR associated with this commit
60+ PR_DATA=$(gh pr list --search "$SHA" --state merged --json number,title --limit 1 2>/dev/null || echo "[]")
61+
62+ if [ "$PR_DATA" = "[]" ] || [ -z "$PR_DATA" ]; then
63+ echo " No PR found, skipping"
6364 continue
6465 fi
6566
66- # Check for PR and /release-note comments
67- PR_DATA=$(gh pr list --search "$SHA" --state merged --json number --limit 1 2>/dev/null || echo "[]")
68- if [ "$PR_DATA" != "[]" ] && [ -n "$PR_DATA" ]; then
69- PR_NUMBER=$(echo "$PR_DATA" | jq -r '.[0].number // empty')
70- if [ -n "$PR_NUMBER" ]; then
71- echo " Found PR #$PR_NUMBER"
72-
73- # Check for /release-note in PR comments
74- PR_COMMENTS=$(gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body' 2>/dev/null || echo "")
75- RELEASE_NOTE=$(echo "$PR_COMMENTS" | grep "^/release-note " | sed 's|^/release-note ||' | head -1 || echo "")
76- if [ -n "$RELEASE_NOTE" ]; then
77- echo " Found /release-note: $RELEASE_NOTE"
78- HIGHLIGHTS+=("$RELEASE_NOTE")
79- fi
80- fi
67+ PR_NUMBER=$(echo "$PR_DATA" | jq -r '.[0].number // empty')
68+ PR_TITLE=$(echo "$PR_DATA" | jq -r '.[0].title // empty')
69+
70+ if [ -z "$PR_NUMBER" ] || [ -z "$PR_TITLE" ]; then
71+ echo " Could not get PR details, skipping"
72+ continue
8173 fi
8274
83- # Extract issue number from commit body for sorting
84- ISSUE_NUM=$(echo "$BODY" | grep -oiE "(fixes|closes|resolves)\s*#[0-9]+" | grep -oE "[0-9]+" | head -1 || echo "99999")
85- ISSUE_REF=$(echo "$BODY" | grep -oiE "(fixes|closes|resolves)\s*#[0-9]+" | head -1 || echo "")
75+ # Skip if we've already processed this PR
76+ if [ -n "${PROCESSED_PRS[$PR_NUMBER]}" ]; then
77+ echo " PR #$PR_NUMBER already processed, skipping"
78+ continue
79+ fi
80+ PROCESSED_PRS[$PR_NUMBER]=1
8681
87- # Build commit entry
88- if [ -n "$ISSUE_NUM" ] && [ "$ISSUE_NUM" != "99999" ]; then
89- ENTRY="- #${ISSUE_NUM} - $SUBJECT ($SHORT_SHA)"
90- else
91- ENTRY="- $SUBJECT ($SHORT_SHA)"
82+ echo " Found PR #$PR_NUMBER: $PR_TITLE"
83+
84+ # Skip revert PRs
85+ if echo "$PR_TITLE" | grep -qE "^revert(\(|:)"; then
86+ echo " Skipping revert PR"
87+ continue
9288 fi
9389
94- # Store with issue number prefix for sorting
95- SORTABLE_ENTRY="${ISSUE_NUM}|${ENTRY}"
90+ # Check for /release-note in PR comments
91+ PR_COMMENTS=$(gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body' 2>/dev/null || echo "")
92+ RELEASE_NOTE=$(echo "$PR_COMMENTS" | grep "^/release-note " | sed 's|^/release-note ||' | head -1 || echo "")
93+ if [ -n "$RELEASE_NOTE" ]; then
94+ echo " Found /release-note: $RELEASE_NOTE"
95+ HIGHLIGHTS+=("$RELEASE_NOTE")
96+ fi
97+
98+ # Build entry using PR number and title
99+ ENTRY="- #${PR_NUMBER} - $PR_TITLE"
100+
101+ # Store with PR number prefix for sorting
102+ SORTABLE_ENTRY="${PR_NUMBER}|${ENTRY}"
96103
97- # Categorize by conventional commit prefix
98- if echo "$SUBJECT " | grep -qE "^fix(\(|:)"; then
104+ # Categorize by conventional commit prefix in PR title
105+ if echo "$PR_TITLE " | grep -qE "^fix(\(|:)"; then
99106 BUGS+=("$SORTABLE_ENTRY")
100- elif echo "$SUBJECT " | grep -qE "^(perf|refactor)(\(|:)"; then
107+ elif echo "$PR_TITLE " | grep -qE "^(perf|refactor)(\(|:)"; then
101108 IMPROVEMENTS+=("$SORTABLE_ENTRY")
102- elif echo "$SUBJECT " | grep -qE "^feat(\(|:)"; then
109+ elif echo "$PR_TITLE " | grep -qE "^feat(\(|:)"; then
103110 FEATURES+=("$SORTABLE_ENTRY")
104- elif echo "$SUBJECT " | grep -qE "^(docs|style|test|build|ci|chore)(\(|:)"; then
111+ elif echo "$PR_TITLE " | grep -qE "^(docs|style|test|build|ci|chore)(\(|:)"; then
105112 MAINTENANCE+=("$SORTABLE_ENTRY")
106113 else
107114 OTHER+=("$SORTABLE_ENTRY")
108115 fi
109- done < <(git log ${COMMIT_RANGE} --pretty=format:"%H|%s|%h|%b---END---" --no-merges | sed 's/---END---/\n/g')
116+ done
110117
111118 # Helper function to sort entries by issue number and format output
112119 sort_entries() {
0 commit comments