Skip to content

Commit e91dba6

Browse files
authored
Refactor author email retrieval in squash-pr.sh
Simplify author email retrieval by removing checks for public email and directly using noreply format.
1 parent d3af5a1 commit e91dba6

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

scripts/merge-train/squash-pr.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,8 @@ head_repo=$(echo "$pr_info" | jq -r '.headRepository.nameWithOwner')
2222
is_fork=$(echo "$pr_info" | jq -r '.isCrossRepository')
2323

2424
# 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
25+
user_id=$(gh api "/users/$pr_author" --jq '.id')
26+
author_email="${user_id}+${pr_author}@users.noreply.github.com"
3427

3528
# Create a temporary worktree to do the squashing
3629
worktree_dir=$(mktemp -d)
@@ -43,7 +36,7 @@ git worktree add "$worktree_dir" HEAD
4336
cd "$worktree_dir"
4437

4538
# Configure git with author's identity in worktree
46-
git config user.name "$author_name"
39+
git config user.name "$pr_author"
4740
git config user.email "$author_email"
4841

4942
# Save our current branch commits

0 commit comments

Comments
 (0)