@@ -21,9 +21,16 @@ pr_author=$(echo "$pr_info" | jq -r '.author.login')
2121head_repo=$( echo " $pr_info " | jq -r ' .headRepository.nameWithOwner' )
2222is_fork=$( echo " $pr_info " | jq -r ' .isCrossRepository' )
2323
24- # We'll use AztecBot as the committer
25- author_name=" AztecBot"
26- 24+ # Get the PR author's name and email
25+ author_info=$( gh api " /users/$pr_author " --jq ' {name: .name, email: .email}' )
26+ author_name=$( echo " $author_info " | jq -r ' .name // .login' )
27+ # Use GitHub's noreply email format if no public email
28+ author_email=$( echo " $author_info " | jq -r ' .email // empty' )
29+ if [[ -z " $author_email " || " $author_email " == " null" ]]; then
30+ # Get user ID for noreply email format
31+ user_id=$( gh api " /users/$pr_author " --jq ' .id' )
32+ author_email=" ${user_id} +${pr_author} @users.noreply.github.com"
33+ fi
2734
2835# Create a temporary worktree to do the squashing
2936worktree_dir=$( mktemp -d)
@@ -58,11 +65,11 @@ merge_base=$(git merge-base "$original_head" "origin/$base_branch")
5865# Get all commits between merge_base and HEAD, excluding merges
5966authors_info=$( git log " $merge_base ..$original_head " --no-merges --format=' %an <%ae>' | sort -u)
6067
61- # Build Co-authored-by trailers
68+ # Build Co-authored-by trailers, excluding the main PR author
6269co_authors=" "
6370while IFS= read -r author_line; do
64- # Skip empty lines and AztecBot itself
65- if [[
-n " $author_line " ]]
&& [[
" $author_line " != * " AztecBot" * ]]
&& [[
" $author_line " != * " [email protected] " * ]]
; then 71+ # Skip empty lines, the main PR author, AztecBot, and [email protected] 72+ if [[
-n " $author_line " ]]
&& [[
" $author_line " != * " $author_name " * ]] && [[ " $author_line " != * " $author_email " * ]] && [[ " $author_line " != * " AztecBot" * ]]
&& [[
" $author_line " != * " [email protected] " * ]]
; then 6673 co_authors=" ${co_authors} Co-authored-by: ${author_line}
6774"
6875 fi
0 commit comments