-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix: bug in github username for reviewers) #153
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,7 @@ | |
from pyosmeta.file_io import clean_export_yml, load_pickle | ||
from pyosmeta.github_api import GitHubAPI | ||
from pyosmeta.models import PersonModel | ||
|
||
|
||
def get_clean_user(username: str) -> str: | ||
"""A small helper that removes whitespace and ensures username is | ||
lower case""" | ||
return username.lower().strip() | ||
from pyosmeta.utils_clean import get_clean_user | ||
|
||
|
||
def main(): | ||
|
@@ -61,7 +56,9 @@ def main(): | |
|
||
if gh_user not in contribs.keys(): | ||
print("Found a new contributor!", gh_user) | ||
new_contrib = process_contribs.get_user_info(gh_user) | ||
new_contrib = process_contribs.return_user_info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the cause of the actual first bug in CI |
||
gh_user | ||
) | ||
new_contrib["date_added"] = datetime.now().strftime( | ||
"%Y-%m-%d" | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,39 @@ | |
from typing import Any | ||
|
||
|
||
def get_clean_user(username: str) -> str: | ||
"""Cleans a GitHub username provided in a review issue by removing any | ||
additional text after a space and converting to lowercase. | ||
|
||
This function assumes that a valid username should not contain spaces. If a | ||
space is detected, only the part before the first space is considered the | ||
username. The resulting string is then trimmed of whitespace and converted | ||
to lowercase. | ||
|
||
Parameters | ||
---------- | ||
username : str | ||
The input username string which may contain extra text or spaces. | ||
|
||
Returns | ||
------- | ||
str | ||
The cleaned username in lowercase without any extra text or spaces. | ||
|
||
Examples | ||
-------- | ||
>>> get_clean_user("@githubusername") | ||
'githubusername' | ||
|
||
>>> get_clean_user("@githubusername name after text") | ||
'githubusername' | ||
""" | ||
|
||
if len(username.split()) > 1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the above bug was fixed another bug popped up related to a github username entered with a name after (and only a space). |
||
username = username.split()[0] | ||
return username.lower().strip() | ||
|
||
|
||
def clean_date(source_date: str | None) -> datetime | str: | ||
"""Cleans up a date string to a consistent datetime format. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def get_clean_user(username: str) -> str: | ||
"""A small helper that removes whitespace and ensures username is | ||
lower case""" | ||
# If the github username has spaces there is an error which might be | ||
# that someone added a name after the username. Only return the github | ||
# username | ||
if len(username.split()) > 1: | ||
username = username.split()[0] | ||
return username.lower().strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved this to the utils module as it makes more sense there.