Skip to content

Commit 73060d4

Browse files
committed
ci: don't do cover letter, don't group by PR
Looks like merge queues are interacting with the pull_request trigger. The GHA is executed once for a group of PR, making the emails confusing. Revert back to sending all emails in sequence and add a banner in every mail, with a pointer to the github commit page. ChangeLog: * .github/workflows/send-emails.yml: Adjust.
1 parent 094ca2b commit 73060d4

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

.github/workflows/send-emails.yml

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ jobs:
9797
regex=$(printf '%s\n' "${patterns[@]}" | sed -e 's/[.[\*^$+?(){|\/\\]/\\&/g' | paste -sd'|' -)
9898
9999
rm -f /tmp/commits.txt
100-
101-
git log --format="%H" "$PR_BASE_REF..HEAD" | while read SHA1; do
100+
git log --reverse --format="%H" "$PR_BASE_REF..HEAD" | while read SHA1; do
102101
if grep -q -E "$regex" <(git diff-tree --no-commit-id --name-only -r "$SHA1"); then
103102
echo "Touching something not to be upstreamed, skipping commit $SHA1"
104103
else
@@ -115,13 +114,7 @@ jobs:
115114
if [ "${COUNT}" -gt "$MAX" ]; then
116115
echo "Series has $COUNT commits (> $MAX). Not doing anything" >> $GITHUB_STEP_SUMMARY
117116
exit 0
118-
else if [ "${COUNT}" -eq 1 ]; then
119-
echo "Single commit PR, don't do the cover letter"
120-
echo "DO_COVER=0" >> $GITHUB_ENV
121-
else
122-
echo "Multiple commits ($COUNT) in PR, create a cover letter"
123-
echo "DO_COVER=1" >> $GITHUB_ENV
124-
fi fi
117+
fi
125118
126119
- name: Prepare patch series
127120
run: |
@@ -138,46 +131,46 @@ jobs:
138131
N="${COUNT:-0}"
139132
TITLE="$(printf '[PATCH 0/%d] PR #%s: %s' "$N" "$PR_NUMBER" "$PR_TITLE")"
140133
141-
echo "PR: $PR_URL" > /tmp/description.txt
142-
echo "Merged by: ${{ github.actor }}" >> /tmp/description.txt
143-
echo "Base: $PR_TARGET_BRANCH" >> /tmp/description.txt
144-
echo "" >> /tmp/description.txt
145-
echo "This series was merged into the gccrs repository and is posted here for" >> /tmp/description.txt
134+
echo "This change was merged into the gccrs repository and is posted here for" >> /tmp/description.txt
146135
echo "upstream visibility and potential drive-by review, as requested by GCC" >> /tmp/description.txt
147136
echo "release managers." >> /tmp/description.txt
148-
echo "" >> /tmp/description.txt
149-
echo " Notes:" >> /tmp/description.txt
150-
echo " - Source branch: $(jq -r '.pull_request.head.label' /tmp/gh_event.json)" >> /tmp/description.txt
151-
echo " - Merge commit: $PR_MERGE_COMMIT" >> /tmp/description.txt
152-
echo " - Commit count: $N" >> /tmp/description.txt
137+
echo "Each commit email contains a link to its details on github from where you can" >> /tmp/description.txt
138+
echo "find the Pull-Request and associated discussions." >> /tmp/description.txt
153139
echo "" >> /tmp/description.txt
154140
155141
mkdir /tmp/series
156142
157-
if [ "$DO_COVER" = "1" ]; then
158-
# Generate series + cover letter
159-
git format-patch \
160-
--subject-prefix="gccrs COMMIT" \
161-
--cover-letter \
162-
--description-file=/tmp/description.txt \
163-
--base="$PR_BASE_REF" \
164-
--output-directory /tmp/series \
165-
"$PR_BASE_REF"..HEAD
166-
167-
awk -v CONTENT="$PR_TITLE" '{gsub(/\*\*\* SUBJECT HERE \*\*\*/, CONTENT); print}' /tmp/series/0000-cover-letter.patch > /tmp/temp
168-
mv /tmp/temp /tmp/series/0000-cover-letter.patch
169-
else
170-
# Generate series + cover letter
171-
git format-patch \
172-
--subject-prefix="gccrs COMMIT" \
173-
--no-cover-letter \
174-
--base="$PR_BASE_REF" \
175-
--output-directory /tmp/series \
176-
"$PR_BASE_REF"..HEAD
177-
178-
# for every patch file, insert the github header right after the '---'.
179-
sed '/^---$/ r /tmp/description.txt' -i /tmp/series/*
180-
fi
143+
# Generate series + cover letter
144+
git format-patch \
145+
--subject-prefix="gccrs COMMIT" \
146+
--no-cover-letter \
147+
--base="$PR_BASE_REF" \
148+
--output-directory /tmp/series \
149+
"$PR_BASE_REF"..HEAD
150+
151+
echo "" >> /tmp/description.txt
152+
153+
cp /tmp/commits.txt /tmp/commits_stack.txt
154+
while IFS= read -r -d '' f;do
155+
# Read next SHA1...
156+
SHA1=$(head -n1 /tmp/commits_stack.txt)
157+
158+
# ... and pop it from the stack
159+
sed -i '1d' /tmp/commits_stack.txt
160+
161+
echo "SHA1: $SHA1"
162+
echo "patch file: $f"
163+
echo ""
164+
165+
cp /tmp/description.txt "/tmp/tmp_descr.txt"
166+
echo "Commit on github: https://github.com/rust-GCC/gccrs/commit/$SHA1" >> "/tmp/tmp_descr.txt"
167+
168+
# insert the github header right after the '---'.
169+
sed '/^---$/ r /tmp/tmp_descr.txt' -i "$f"
170+
171+
# loop over the patches and make sure to do that in numerical order
172+
# 0001-..., 0002-...., ...
173+
done < <(find /tmp/series/ -maxdepth 1 -type f -print0|sort -z -n)
181174
182175
- name: Send series via git send-email
183176
env:

0 commit comments

Comments
 (0)