The port of ticket_branch.py now has key and title from the first colon. Next comes the branch name: fix/ followed by the lowercased key and the title’s first six words, joined with hyphens. Python does it with split() and "-".join(), and JavaScript does both differently.
Split the Title Into Six Words
The Python helper cleans the title, splits it, and takes the first six words:
key = "PAY-2291"
title = "Refund emails show the wrong currency: EUR shown as USD"
words = title.lower().replace(":", "").split()
branch = f"fix/{key.lower()}-{'-'.join(words[:6])}"
print(f"Branch: {branch}")
The cleaning ports as .toLowerCase() and .replaceAll(). The split doesn’t. Python’s split() with no argument splits on runs of whitespace, but JavaScript’s .split() has no default separator, so with nothing to cut at, it returns the whole string as one piece: