Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions .github/workflows/send-emails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types:
- closed
branches:
- "master"
- "test"

jobs:
send_patches:
Expand Down Expand Up @@ -97,8 +97,7 @@ jobs:
regex=$(printf '%s\n' "${patterns[@]}" | sed -e 's/[.[\*^$+?(){|\/\\]/\\&/g' | paste -sd'|' -)

rm -f /tmp/commits.txt

git log --format="%H" "$PR_BASE_REF..HEAD" | while read SHA1; do
git log --reverse --format="%H" "$PR_BASE_REF..HEAD" | while read SHA1; do
if grep -q -E "$regex" <(git diff-tree --no-commit-id --name-only -r "$SHA1"); then
echo "Touching something not to be upstreamed, skipping commit $SHA1"
else
Expand All @@ -115,13 +114,9 @@ jobs:
if [ "${COUNT}" -gt "$MAX" ]; then
echo "Series has $COUNT commits (> $MAX). Not doing anything" >> $GITHUB_STEP_SUMMARY
exit 0
else if [ "${COUNT}" -eq 1 ]; then
echo "Single commit PR, don't do the cover letter"
echo "DO_COVER=0" >> $GITHUB_ENV
else
echo "Multiple commits ($COUNT) in PR, create a cover letter"
echo "DO_COVER=1" >> $GITHUB_ENV
fi fi
fi

echo "DO_COVER=0" >> $GITHUB_ENV

- name: Prepare patch series
run: |
Expand All @@ -138,18 +133,11 @@ jobs:
N="${COUNT:-0}"
TITLE="$(printf '[PATCH 0/%d] PR #%s: %s' "$N" "$PR_NUMBER" "$PR_TITLE")"

echo "PR: $PR_URL" > /tmp/description.txt
echo "Merged by: ${{ github.actor }}" >> /tmp/description.txt
echo "Base: $PR_TARGET_BRANCH" >> /tmp/description.txt
echo "" >> /tmp/description.txt
echo "This series was merged into the gccrs repository and is posted here for" >> /tmp/description.txt
echo "This change was merged into the gccrs repository and is posted here for" >> /tmp/description.txt
echo "upstream visibility and potential drive-by review, as requested by GCC" >> /tmp/description.txt
echo "release managers." >> /tmp/description.txt
echo "" >> /tmp/description.txt
echo " Notes:" >> /tmp/description.txt
echo " - Source branch: $(jq -r '.pull_request.head.label' /tmp/gh_event.json)" >> /tmp/description.txt
echo " - Merge commit: $PR_MERGE_COMMIT" >> /tmp/description.txt
echo " - Commit count: $N" >> /tmp/description.txt
echo "Each commit email contains a link to its details on github from where you can" >> /tmp/description.txt
echo "find the Pull-Request and associated discussions." >> /tmp/description.txt
echo "" >> /tmp/description.txt

mkdir /tmp/series
Expand All @@ -175,8 +163,29 @@ jobs:
--output-directory /tmp/series \
"$PR_BASE_REF"..HEAD

# for every patch file, insert the github header right after the '---'.
sed '/^---$/ r /tmp/description.txt' -i /tmp/series/*
echo "" >> /tmp/description.txt

cp /tmp/commits.txt /tmp/commits_stack.txt
while IFS= read -r -d '' f;do
# Read next SHA1...
SHA1=$(head -n1 /tmp/commits_stack.txt)

# ... and pop it from the stack
sed -i '1d' /tmp/commits_stack.txt

echo "SHA1: $SHA1"
echo "patch file: $f"
echo ""

cp /tmp/description.txt "/tmp/tmp_descr.txt"
echo "Commit on github: https://github.com/rust-GCC/gccrs/commit/$SHA1" >> "/tmp/tmp_descr.txt"

# insert the github header right after the '---'.
sed '/^---$/ r /tmp/tmp_descr.txt' -i "$f"

# loop over the patches and make sure to do that in numerical order
# 0001-..., 0002-...., ...
done < <(find /tmp/series/ -maxdepth 1 -type f -print0|sort -z -n)
fi

- name: Send series via git send-email
Expand Down
Empty file added a
Empty file.
Empty file added b
Empty file.
Empty file added c
Empty file.