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

normalize gitconfig's author field to UTF-8 NFC #8798

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,12 @@ def _format_requirements(self, requirements: list[dict[str, str]]) -> Requiremen

return requires

def _validate_author(self, author: str, default: str) -> str | None:
@staticmethod
def _validate_author(author: str, default: str) -> str | None:
from poetry.core.packages.package import AUTHOR_REGEX
from poetry.core.utils.helpers import combine_unicode

author = author or default
author = combine_unicode(author or default)

if author in ["n", "no"]:
return None
Expand Down
16 changes: 16 additions & 0 deletions tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,22 @@ def test_validate_package_invalid(name: str) -> None:
assert InitCommand._validate_package(name)


@pytest.mark.parametrize(
"author",
[
str(b"Jos\x65\xcc\x81 Duarte", "utf-8"),
str(b"Jos\xc3\xa9 Duarte", "utf-8"),
],
)
def test_validate_author(author: str) -> None:
"""
This test was added following issue #8779, hence, we're looking to see if the test
no longer throws an exception, hence the seemingly "useless" test of just running
the method.
"""
InitCommand._validate_author(author, "")


@pytest.mark.parametrize(
"package_name, include",
(
Expand Down