97
97
regex=$(printf '%s\n' "${patterns[@]}" | sed -e 's/[.[\*^$+?(){|\/\\]/\\&/g' | paste -sd'|' -)
98
98
99
99
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
102
101
if grep -q -E "$regex" <(git diff-tree --no-commit-id --name-only -r "$SHA1"); then
103
102
echo "Touching something not to be upstreamed, skipping commit $SHA1"
104
103
else
@@ -115,13 +114,7 @@ jobs:
115
114
if [ "${COUNT}" -gt "$MAX" ]; then
116
115
echo "Series has $COUNT commits (> $MAX). Not doing anything" >> $GITHUB_STEP_SUMMARY
117
116
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
125
118
126
119
- name : Prepare patch series
127
120
run : |
@@ -138,46 +131,46 @@ jobs:
138
131
N="${COUNT:-0}"
139
132
TITLE="$(printf '[PATCH 0/%d] PR #%s: %s' "$N" "$PR_NUMBER" "$PR_TITLE")"
140
133
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
146
135
echo "upstream visibility and potential drive-by review, as requested by GCC" >> /tmp/description.txt
147
136
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
153
139
echo "" >> /tmp/description.txt
154
140
155
141
mkdir /tmp/series
156
142
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)
181
174
182
175
- name : Send series via git send-email
183
176
env :
0 commit comments