@@ -21,9 +21,9 @@ pr_author=$(echo "$pr_info" | jq -r '.author.login')
21
21
head_repo=$( echo " $pr_info " | jq -r ' .headRepository.nameWithOwner' )
22
22
is_fork=$( echo " $pr_info " | jq -r ' .isCrossRepository' )
23
23
24
- # We'll use AztecBot as the committer
25
- author_name= " AztecBot "
26
- author_email=" 49558828+AztecBot @users.noreply.github.com"
24
+ # Get the PR author's name and email
25
+ user_id= $( gh api " /users/ $pr_author " --jq ' .id ' )
26
+ author_email=" ${user_id} + ${pr_author} @users.noreply.github.com"
27
27
28
28
# Create a temporary worktree to do the squashing
29
29
worktree_dir=$( mktemp -d)
@@ -36,7 +36,7 @@ git worktree add "$worktree_dir" HEAD
36
36
cd " $worktree_dir "
37
37
38
38
# Configure git with author's identity in worktree
39
- git config user.name " $author_name "
39
+ git config user.name " $pr_author "
40
40
git config user.email " $author_email "
41
41
42
42
# Save our current branch commits
@@ -58,11 +58,11 @@ merge_base=$(git merge-base "$original_head" "origin/$base_branch")
58
58
# Get all commits between merge_base and HEAD, excluding merges
59
59
authors_info=$( git log " $merge_base ..$original_head " --no-merges --format=' %an <%ae>' | sort -u)
60
60
61
- # Build Co-authored-by trailers
61
+ # Build Co-authored-by trailers, excluding the main PR author
62
62
co_authors=" "
63
63
while 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
64
+ # Skip empty lines, the main PR author, AztecBot, and [email protected]
65
+ if [[
-n " $author_line " ]]
&& [[
" $author_line " != * " $pr_author " * ]] && [[ " $author_line " != * " $author_email " * ]] && [[ " $author_line " != * " AztecBot" * ]]
&& [[
" $author_line " != * " [email protected] " * ]]
; then
66
66
co_authors=" ${co_authors} Co-authored-by: ${author_line}
67
67
"
68
68
fi
0 commit comments