Skip to content

Commit c9d9211

Browse files
fix(core): use exact line matching for duplicate author check
1 parent eee19e6 commit c9d9211

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/edit_python_pe/file_io.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def _write_authors_file(
3434
contents = ""
3535

3636
alias = aliases[0] if aliases else name
37-
file_content = f"\n{name}({alias}) <{email}>"
38-
if file_content.strip() not in contents:
39-
_append_file(file_content, file_path)
37+
candidate = f"{name}({alias}) <{email}>"
38+
normalized_lines = [line.strip() for line in contents.splitlines()]
39+
if candidate not in normalized_lines:
40+
_append_file(f"\n{candidate}", file_path)

tests/unit/test_file_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_write_authors_file(self):
3131
assert email in args[0]
3232

3333
# Case: author already present, should not append
34-
existing_line = f"\\n{name}(alias1) <{email}>"
34+
existing_line = f"\n{name}(alias1) <{email}>"
3535
with (
3636
patch(
3737
"edit_python_pe.file_io._read_file", return_value=existing_line

0 commit comments

Comments
 (0)