Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find unique user based on lowercase email compare #12

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

abij
Copy link
Contributor

@abij abij commented Jan 2, 2025

When multiple users are found, do email check case-insensitive.
In case the email does not match, log the found email address as a set.
Return the user which matches the email address instead of the first in the list.

Fix for #11

When multiple users are found, do email check case-insensitive.
Also when not found, log the found email address as a set.
@abij
Copy link
Contributor Author

abij commented Jan 2, 2025

Note I did this "coding" online github editor, without any checks. I hope you have proper tests ;)

@@ -338,11 +338,12 @@ def get_unique_user_by_name(self, name: str, email: Optional[str]) -> "User":
if len(users) == 0:
raise ValueError(f"author '{name}' not found on {self.endpoint.host}")
elif len(users) > 1:
user = next(filter(lambda u: email and u.email == email, users), None)
user = next(filter(lambda u: email and u.email.lower() == email.lower(), users), None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if u.email is none, this will throw an error.

@mvanholsteijn mvanholsteijn merged commit 146ca33 into binxio:main Jan 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants