Skip to content

Commit 49c672f

Browse files
authored
Refactor to remove clunky double condition check
1 parent 5bfd6a1 commit 49c672f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/generate_commit_msg.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def generate_commit_msg():
5151
entry.msgid not in old_entries
5252
or old_entries[entry.msgid] != entry.msgstr
5353
):
54-
translator = new_po.metadata.get("Last-Translator")
5554
# Prevent failure on missing Last-Translator field.
5655
# Transifex only adds Last-Translator if someone from
5756
# the team translated. If it was uploaded by an account
58-
# that is not in the team, this field will be missing.
57+
# that is not in the team, this field will be missing.
58+
translator = (
59+
(new_po.metadata.get("Last-Translator") or "").split(",")[0].strip()
60+
)
5961
if translator:
60-
translator = translator.split(",")[0].strip()
61-
if translator:
62-
translators.add(f"Co-Authored-By: {translator}")
62+
translators.add(f"Co-Authored-By: {translator}")
6363
break
6464

6565
print("Update translation\n\n" + "\n".join(translators))
@@ -84,7 +84,7 @@ def chdir(path: Path):
8484
parser.add_argument(
8585
"path",
8686
type=Path,
87-
nargs='?',
87+
nargs="?",
8888
default=".",
8989
help="Path to the Git repository (default: current directory)",
9090
)

0 commit comments

Comments
 (0)