Skip to content

Commit 409e94b

Browse files
committed
build: avoid including PR authors' emails in commit footers
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent fb571fb commit 409e94b

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

.github/workflows/scripts/generate_pr_commit_message

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,30 @@ main() {
153153
# Resolve the PR author's name and email using .mailmap:
154154
pr_author_resolved=$(resolve_user "$pr_author_login")
155155

156+
pr_author_id=$(echo "$pr_details" | jq -r '.user.id')
157+
pr_author_emails=$(
158+
{
159+
# 1) the address obtained via .mailmap
160+
echo "$pr_author_resolved"
161+
162+
# 2) the default GitHub‑generated noreply address
163+
echo "$pr_author_login@users.noreply.github.com"
164+
165+
# 3) ID+login GitHub noreply address (needed for bots & private e‑mails)
166+
echo "${pr_author_id}+${pr_author_login}@users.noreply.github.com"
167+
168+
# 4) any address that appears in commits whose author *login* matches
169+
echo "$pr_commits" | jq -r --arg login "$pr_author_login" '
170+
.[]
171+
| select(.author.login==$login or .committer.login==$login)
172+
| .commit.author.email
173+
'
174+
} |
175+
sed -E 's/^.*<([^>]+)>.*/\1/' | # Keep only the e‑mail part
176+
tr "[:upper:]" "[:lower:]" |
177+
sort -u
178+
)
179+
156180
# Extract reviewers:
157181
pr_reviews=$(github_api "GET" "/repos/$REPO_OWNER/$REPO_NAME/pulls/$pr_number/reviews")
158182
reviewers=$(echo "$pr_reviews" | jq -r '.[] | select(.state == "APPROVED" ) | .user.login' | sort -u)
@@ -173,8 +197,12 @@ main() {
173197
email=$(echo "$name_email" | sed -E 's/^.*<(.*)>$/\1/' | xargs)
174198
resolved_author=$(resolve_name_email "$name" "$email")
175199

176-
# Skip if the resolved author matches the resolved PR author:
177-
if [ "$resolved_author" == "$pr_author_resolved" ]; then
200+
# Skip if the resolved author's email matches any of the resolved PR author's emails:
201+
resolved_email=$(echo "$resolved_author" |
202+
sed -E 's/^.*<([^>]+)>.*/\1/' |
203+
tr '[:upper:]' '[:lower:]')
204+
205+
if echo "$pr_author_emails" | grep -Fxq "$resolved_email"; then
178206
continue
179207
fi
180208
processed_co_authors+="Co-authored-by: $resolved_author"$'\n'
@@ -198,8 +226,16 @@ main() {
198226
# Resolve name and email using .mailmap:
199227
resolved_author=$(resolve_name_email "$name" "$email")
200228

201-
# Skip if the resolved author matches the resolved PR author:
202-
if [ "$resolved_author" == "$pr_author_resolved" ]; then
229+
230+
echo $resolved_email
231+
echo $pr_author_emails
232+
233+
# Skip if the resolved commit author's email matches any of the resolved PR author's emails:
234+
resolved_email=$(echo "$resolved_author" |
235+
sed -E 's/^.*<([^>]+)>.*/\1/' |
236+
tr '[:upper:]' '[:lower:]')
237+
238+
if echo "$pr_author_emails" | grep -Fxq "$resolved_email"; then
203239
continue
204240
fi
205241

0 commit comments

Comments
 (0)