Skip to content

Commit f8fa569

Browse files
authored
fix: squash-pr.sh (#16719)
2 parents 29f0cec + 70ed0e6 commit f8fa569

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/merge-train/squash-pr.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pr_author=$(echo "$pr_info" | jq -r '.author.login')
2121
head_repo=$(echo "$pr_info" | jq -r '.headRepository.nameWithOwner')
2222
is_fork=$(echo "$pr_info" | jq -r '.isCrossRepository')
2323

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"
2727

2828
# Create a temporary worktree to do the squashing
2929
worktree_dir=$(mktemp -d)
@@ -36,7 +36,7 @@ git worktree add "$worktree_dir" HEAD
3636
cd "$worktree_dir"
3737

3838
# Configure git with author's identity in worktree
39-
git config user.name "$author_name"
39+
git config user.name "$pr_author"
4040
git config user.email "$author_email"
4141

4242
# Save our current branch commits
@@ -58,11 +58,11 @@ merge_base=$(git merge-base "$original_head" "origin/$base_branch")
5858
# Get all commits between merge_base and HEAD, excluding merges
5959
authors_info=$(git log "$merge_base..$original_head" --no-merges --format='%an <%ae>' | sort -u)
6060

61-
# Build Co-authored-by trailers
61+
# Build Co-authored-by trailers, excluding the main PR author
6262
co_authors=""
6363
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
6666
co_authors="${co_authors}Co-authored-by: ${author_line}
6767
"
6868
fi

0 commit comments

Comments
 (0)