merge-pr.py: Fix random emails appearing in commit logs

...my good friend Claude was probably drunk when he wrote that code.
This commit is contained in:
Pekka Enberg 2025-01-16 14:52:58 +02:00
parent e2cf5cf145
commit 38f7dec9e7

View file

@ -41,13 +41,7 @@ def get_user_email(g, username):
name = user.name if user.name else username
if user.email:
return f"{name} <{user.email}>"
# If public email is not available, try to get from events
events = user.get_events()
for event in events:
if event.type == "PushEvent" and event.payload.get("commits"):
for commit in event.payload["commits"]:
if commit.get("author") and commit["author"].get("email"):
return f"{name} <{commit['author']['email']}>"
return f"{name} (@{username})"
except Exception as e:
print(f"Error fetching email for user {username}: {str(e)}")